Skip to content

Weird behaviour of ts.diversity with a single sample #2037

Closed
@hyanwong

Description

@hyanwong

It should be impossible to calculate the diversity of a single sample, because we need to pick at least one pair of distinct samples to calculate it. So this is expected:

ts = msprime.sim_ancestry(10, ploidy=1)
ts = msprime.sim_mutations(ts, rate=0.1)
print(ts.diversity([0], mode="branch"))  # prints "array(nan)"

But looks what happens if there's only one sample in the ts:

ts = msprime.sim_ancestry(1, ploidy=1)
ts = msprime.sim_mutations(ts, rate=0.1)
print(ts.diversity([0], mode="branch"))  # prints "array(0.)"  <- er, what?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions