# Function documentation¶

fwdpy11.infinite_sites(rng: fwdpy11._fwdpy11.GSLrng, pop: fwdpy11._fwdpy11.PopulationBase, mu: float)int
Parameters
• rng (fwdpy11.GSLrng) – Random number generator

• pop (fwdpy11.Population) – A population

• mu (float) – The mutation rate, per haploid genome per generation

Returns

Number of mutations added

Return type

int

fwdpy11.simplify(pop: fwdpy11._fwdpy11.PopulationBase, samples: List[int])tuple

Simplify a TableCollection stored in a Population.

Parameters
• samples – A list of samples (node indexes).

Returns

The simplified tables and array mapping input sample IDs to output IDS

Return type

tuple

Note that the samples argument is agnostic with respect to the time of the nodes in the input tables. Thus, you may do things like simplify to a set of “currently-alive” nodes plus some or all ancient samples by including some node IDs from fwdpy11.TableCollection.preserved_nodes.

If the input contains ancient samples, and you wish to include them in the output, then you need to include their IDs in the samples argument.

Note

Due to node ID remapping, the metadata corresponding to nodes becomes a bit more difficult to look up. You need to use the output ID map, the original IDs, and the population’s metadata containers.

Deprecated since version 0.3.0: Prefer fwdpp.simplify_tables()

Changed in version 0.3.0: Ancient samples are no longer kept by default

Changed in version 0.5.0: No longer requires a MutationVector argument.

fwdpy11.simplify_tables(tables: fwdpy11._fwdpy11.TableCollection, samples: List[int])tuple

Simplify a TableCollection.

Parameters
Returns

A simplified TableCollection and an array containing remapped sample ids.

Return type

tuple

New in version 0.3.0.

fwdpy11.evolvets(rng, pop, params, simplification_interval, recorder=None, post_simplification_recorder=None, suppress_table_indexing=False, record_gvalue_matrix=False, stopping_criterion=None, track_mutation_counts=False, remove_extinct_variants=True, preserve_first_generation=False, check_demographic_event_timings=True)

Evolve a population with tree sequence recording

Parameters
• rng (fwdpy11.GSLrng) – random number generator

• pop (fwdpy11.DiploidPopulation) – A population

• params (fwdpy11.ModelParams) – simulation parameters

• simplification_interval (int) – Number of generations between simplifications.

• recorder (typing.Callable) – (None) A temporal sampler/data recorder.

• post_simplification_recorder (typing.Callable) – (None) A temporal sampler

• suppress_table_indexing (bool) – (False) Prevents edge table indexing until end of simulation

• record_gvalue_matrix (bool) – (False) Whether to record genetic values into fwdpy11.PopulationBase.genetic_values.

• preserve_first_generation (bool) – (False) Whether to record generation 0 as ancient samples. Must be True for tree sequence “recapitation”. See finishwithmsprime.

• check_demographic_event_timings (bool) – (True) If True, then issue warnings if demographic events will occur prior to the current generation of the population.

The recording of genetic values into fwdpy11.PopulationBase.genetic_values is suppressed by default. First, it is redundant with fwdpy11.DiploidMetadata.g for the common case of mutational effects on a single trait. Second, we save some memory by not tracking these matrices. However, it is useful to track these data for some cases when simulating multivariate mutational effects (pleiotropy).

For a detailed description of post_simplification_recorder, see tstimeseries.

Note

If recorder is None, then fwdpy11.NoAncientSamples will be used.

If post_simplification_recorder is None, then fwdpy11.RecordNothing will be used.

Changed in version 0.5.2: Added post_simplification_recorder.

Changed in version 0.7.1: Added preserve_first_generation.

Changed in version 0.8.0: Update to refactored ModelParams. Added check_demographic_event_timings.

fwdpy11.exponential_growth_rate(N0, Nt, time)
Parameters
• N0 – Population size at onset of size change

• Nt – Population size to reach at end of size change

• time – Time (in generations) to get from N0 to Nt

Returns

A list of integers representing population size over time.

New in version 0.6.0.

fwdpy11.migration_matrix_single_extant_deme(ndemes, focal_deme)

Sets up a migration matrix for a system of ndemes but where only one deme has a size > 0. This is a convenience function for simulations where demes will appear later on and have migration amongst them.

Parameters
• ndemes – The number of demes that will eventually exist.

• focal_deme – The index of the initial extant deme.

Return type

numpy.ndarray

New in version 0.6.0.