Skip to main content

moments: population genetic analyses and inference using diversity statistics

Please see the documentation for more details, examples, tutorials and API usage.

moments provides a suite of methods for demographic history and selection inference from genetic data, based on diffusion approximations to the one- and two-locus allele frequency spectrum. moments is modeled after the ∂a∂i open source package developed by Ryan Gutenkunst. For SFS-based methods, we largely reuse ∂a∂i's API, but introduce a new simulation engine. This new method is based on the direct computation of the frequency spectrum without solving the diffusion system, removing the need for frequency grids as used in ∂a∂i. moments.LD, packaged within moments, implements methods for computing linkage disequilibrium statistics and running multi-population demographic inference using patterns of LD.

Getting started

moments requires Python 3.11 or newer (up to 3.15).

The simplest way to install moments is using pip:

pip install moments-popgen

moments can then be imported using import moments.

Important note: pip install moments installs a different package named moments, and our pypi package is named moments-popgen.

moments is also available from Bioconda:

conda install -c conda-forge -c bioconda moments

We can install the development branch directly from Github by running

pip install git+https://github.com/MomentsLD/moments.git@devel

Alternatively, you can clone the git repository and install from source (use pip install -e . for an editable, development install):

git clone https://github.com/MomentsLD/moments.git
cd moments
pip install .

Dependencies

Installing with pip installs the required dependencies automatically:

  • numpy (>= 2.0, < 3.0)
  • scipy (>= 1.13)
  • cython (>= 3.1)
  • mpmath (>= 1.0, < 1.4)
  • demes (>= 0.2)

Some features need additional packages:

  • Plotting: matplotlib
  • Parsing VCFs with moments.LD.Parsing: scikit-allel, h5py, and pandas

We also recommend installing ipython for interactive analyses.

For development, requirements.txt lists the dependencies:

pip install -r requirements.txt

or, with conda:

conda install -c conda-forge --file requirements.txt

To build the documentation locally, install moments along with the packages in requirements/docs.txt, and then run make html in the docs directory:

python -m pip install . -r requirements/docs.txt
cd docs
make html

More details on installation can be found in the documentation. If you have trouble installing moments, please open an issue.

Citing moments

If you use moments in your research, please cite:

  • Jouganous, J., Long, W., Ragsdale, A. P., & Gravel, S. (2017). Inferring the joint demographic history of multiple populations: beyond the diffusion approximation. Genetics, 206(3), 1549-1567.

If you use moments.LD in your research, please cite:

  • Ragsdale, A. P. & Gravel, S. (2019). Models of archaic admixture and recent history from two-locus statistics. PLoS Genetics, 15(6), e1008204.

  • Ragsdale, A. P. & Gravel, S. (2020). Unbiased estimation of linkage disequilibrium from unphased data. Mol Biol Evol, 37(3), 923-932.

If you use moments.TwoLocus in your research, please cite:

  • Ragsdale, A. P. (2022). Local fitness and epistatic effects lead to distinct patterns of linkage disequilibrium in protein-coding genes. Genetics, 221(4), iyac097.

If you use the Godambe-based uncertainty methods (in moments.Godambe or moments.LD.Godambe), please cite:

  • Coffman, A. J., Hsieh, P. H., Gravel, S., & Gutenkunst, R. N. (2016). Computationally efficient composite likelihood statistics for demographic inference. Molecular biology and evolution, 33(2), 591-593.

moments is developed in the Simon Gravel and Aaron Ragsdale research groups, at McGill University and UW-Madison, respectively. For any issues, questions or bug reports, please open an issue on Github.

Changelog

All changes are detailed in the documentation.

Metadata

Release files for moments-popgen 1.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moments-popgen 1.7.1
File Size Uploaded Provenance Actions
moments_popgen-1.7.1.tar.gz 4.7 MB With provenance Details for moments_popgen-1.7.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for moments-popgen 1.7.1
File Actions
moments_popgen-1.7.1-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.15 CPython 3.15 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for moments_popgen-1.7.1-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
moments_popgen-1.7.1-cp315-cp315-macosx_11_0_arm64.whl CPython 3.15 CPython 3.15 macOS 11.0+ ARM64 Details for moments_popgen-1.7.1-cp315-cp315-macosx_11_0_arm64.whl
moments_popgen-1.7.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for moments_popgen-1.7.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
moments_popgen-1.7.1-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for moments_popgen-1.7.1-cp314-cp314-macosx_11_0_arm64.whl
moments_popgen-1.7.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for moments_popgen-1.7.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
moments_popgen-1.7.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for moments_popgen-1.7.1-cp313-cp313-macosx_11_0_arm64.whl
moments_popgen-1.7.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for moments_popgen-1.7.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
moments_popgen-1.7.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for moments_popgen-1.7.1-cp312-cp312-macosx_11_0_arm64.whl
moments_popgen-1.7.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.5+ x86-64 Details for moments_popgen-1.7.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
moments_popgen-1.7.1-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for moments_popgen-1.7.1-cp311-cp311-macosx_11_0_arm64.whl

Total release size: 39.9 MB

Release files / moments_popgen-1.7.1.tar.gz

Download URL moments_popgen-1.7.1.tar.gz
Size 4.7 MB
Tags Source
SHA-256 checksum
How to use checksums
0cd55d00f30058f0a878ad5862751ea70331d2f752528c8655631a028a7aaa33
BLAKE2b-256 checksum
How to use checksums
d3f407fa18c8aa489f0ebb03ad1c0b323cb8465722e48cc3aada5b0d59d5bbd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / moments_popgen-1.7.1-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL moments_popgen-1.7.1-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 4.9 MB
Tags CPython 3.15 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
a0a348cd92d3b5290d313ede1490d92fa8fdab232f3555ab5585fd5745a91ee9
BLAKE2b-256 checksum
How to use checksums
b10f5c8594877f6be5c83bfe1c9e4866e51b03f49be5f300d137ec6346fc73d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / moments_popgen-1.7.1-cp315-cp315-macosx_11_0_arm64.whl

Download URL moments_popgen-1.7.1-cp315-cp315-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.15 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9137212151cc54d9469f99dd8a9d50ad5d9f97e14fdc1b77aba6441121502948
BLAKE2b-256 checksum
How to use checksums
c134440be200ffaa68cb01ff4fe9957867b20d311cc9a5190cab9aa17903b598
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / moments_popgen-1.7.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL moments_popgen-1.7.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 5.0 MB
Tags CPython 3.14 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
abc8a34c63e7da7a683158f0ab7f29f78af0c7f6fa7bb025dc40d79cb89307f9
BLAKE2b-256 checksum
How to use checksums
f7d02fbcaeaf0056092e2ad08e6e30bedd4705620c40b7f690f8934cf657b06c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / moments_popgen-1.7.1-cp314-cp314-macosx_11_0_arm64.whl

Download URL moments_popgen-1.7.1-cp314-cp314-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
01d677728f5977e3183f65a33149cd1f13403e78af32e3806050c78f4f06f2b8
BLAKE2b-256 checksum
How to use checksums
adcff2496c0897ef590efc01ebfd84388d121c8f4ee6ffd16e084d69b29a95de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / moments_popgen-1.7.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL moments_popgen-1.7.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 5.0 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
976c2e019925edc70006663876ae2f440639fbd0cf98c9bb293c9d6fdccaee44
BLAKE2b-256 checksum
How to use checksums
4efff1f6d4869f630f634132f9e551170e23072ac5a994fab1d9492573104736
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / moments_popgen-1.7.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL moments_popgen-1.7.1-cp313-cp313-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f1f904943073667432400db853a0dd2458657668de6537cd6af12f66f5109f9a
BLAKE2b-256 checksum
How to use checksums
766f3b9e89fe33f52d806f931f3fdc3043a44d59f3258dd8b2a63c2270859389
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / moments_popgen-1.7.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL moments_popgen-1.7.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 5.1 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
8aee41135c936d74798e25903d1afef942629c5e8b2af795964cd2560d28f80c
BLAKE2b-256 checksum
How to use checksums
ae57d86c0eaaf8ea28764d36d1d7b9ac9bbdcc44bdfc20087def6015d5e1af76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / moments_popgen-1.7.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL moments_popgen-1.7.1-cp312-cp312-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5fed2e1d05609e88da405c8f45a2bfa39325047f9739f2329916842d8319fec5
BLAKE2b-256 checksum
How to use checksums
6c2edbd1e567112bb01adf5c4e4db79300ae669639489dd6ce8b88c7c1701b05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / moments_popgen-1.7.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL moments_popgen-1.7.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 4.9 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
9bbda9397e1c79150ff07a75ea4c5edbb465043d62fe738fb405d3d2e00ad7c0
BLAKE2b-256 checksum
How to use checksums
21da33a2f503b1ac714c4fff324b5c1a60dffc8d2106a8877661c69bad9aecc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / moments_popgen-1.7.1-cp311-cp311-macosx_11_0_arm64.whl

Download URL moments_popgen-1.7.1-cp311-cp311-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3ff09d0d00750c1bab4c27e42b633a99bc490214e4ef2f314fca14a122e5663d
BLAKE2b-256 checksum
How to use checksums
00127c6351aad7231e3653c11e71e42fa5e4dec76822a39878a302cda5585f65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for moments-popgen 1.7.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 11 files in this release have been uploaded with provenance metadata.

Select from 11 files

Attestation for moments_popgen-1.7.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page