The summary statistic calculates the nucleotide diversity (*π*)
per locus, which is the mean number of pairwise difference for
two individuals. It is a commonly used estimator for the scaled
mutation rate *θ*.

1 2 | ```
sumstat_nucleotide_div(name = "pi", population = 1,
transformation = identity)
``` |

`name` |
The name of the summary statistic. When simulating a model, the value of the statistics are written to an entry of the returned list with this name. Summary statistic names must be unique in a model. |

`population` |
The population for which the statistic is calculated. Can also be "all" to calculate it from all populations. |

`transformation` |
An optional function for transforming the results of the statistic. If specified, the results of the transformation are returned instead of the original values. |

The nucleotide diversity was introduced by

Nei and Li (1979). "Mathematical Model for Studying Genetic Variation in Terms of Restriction Endonucleases". PNAS 76 (10): 5269-73. doi:10.1073/pnas.76.10.5269.

On simulation, this returns a vector with the value of pi for each locus.

To create a demographic model: `coal_model`

To calculate this statistic from data: `calc_sumstats_from_data`

Other summary statistics: `sumstat_dna`

,
`sumstat_file`

,
`sumstat_four_gamete`

,
`sumstat_ihh`

, `sumstat_jsfs`

,
`sumstat_mcmf`

, `sumstat_omega`

,
`sumstat_seg_sites`

,
`sumstat_sfs`

,
`sumstat_tajimas_d`

,
`sumstat_trees`

1 2 3 4 5 | ```
model <- coal_model(5, 2) +
feat_mutation(5) +
sumstat_nucleotide_div()
stats <- simulate(model)
print(stats$pi)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.