Skip to main content

qmc-sampler

PyPI GitHub Dataset

Quasi-Monte Carlo point sampling from spectral optimisation.

qmc-sampler provides several sampling methods for generating quasi-Monte Carlo (QMC) point sets, by minimising the spectral loss over all wave vectors within an exclusion region. 3 kinds of exclusion regions, with different geometrical shape, are available: l2, l1, wd. It was used to generate an extensive dataset of hyperuniform samples, published on Zenodo.

Installation

Install from PyPI:

pip install qmc-sampler

Available sampling methods

The package provides three sampling methods:

  • sample_l2(N, D, **kwargs) — uses a classical isotropic L_2-ball as the spectral exclusion region.
  • sample_l1(N, D, **kwargs) — uses an L_1-ball, producing an anisotropic spectral exclusion region that can be useful when exploiting low effective dimensionality.
  • sample_wd(N, D, **kwargs) — uses the wrap-around discrepancy (WD), a criterion designed to further exploit low-effective-dimensionality structure.

Here, N denotes the number of points and D the dimension.

Basic usage

from qmc_sampler import sample_l1, sample_l2, sample_wd

N = 1000
D = 2

points_l2 = sample_l2(N, D)
points_l1 = sample_l1(N, D)
points_wd = sample_wd(N, D)

Additional keyword arguments e.g. "Chi = 0.4" can be passed to the sampling functions and forwarded to the underlying implementation.

Backends (KeOps, torch, FINUFFT)

All heavy computations go through one of three backends, which the user can controll. e.g., to use the finufft backend in 2D and 3D:

pip install finufft          # or: pip install "qmc-sampler[finufft]"
import qmc_sampler

qmc_sampler.select_backend(dimensions={2, 3}, backend="finufft")
backend method complexity dimensions accuracy
"keops" direct sums, pykeops (GPU if available) O(N M) any exact up to machine precision
"torch" direct sums, torch (cuda if available) O(N M) any exact up to machine precision
"finufft" non-uniform FFT O(N log N + M) D <= 3 relative tolerance 1e-4 (float32), 1e-8 (float64)

Here M is the number of wave vectors, which grows like N.

By default, FINUFFT is not enabled: the backend is "keops" if pykeops is available, otherwise "torch", and "finufft" only if neither is installed. This guarantees that, unless you ask otherwise, every Fourier sum is computed exactly, up to machine precision.

FINUFFT is nevertheless strongly recommended in 2D and 3D: it reduces the cost of each iteration from O(N^2) to O(N log N), which typically makes sampling one to several orders of magnitude faster, and makes large N reachable. Enable it manually:

Plotting utilities

The package also exposes plotting functions (adapted from blue_sampler):

from qmc_sampler import plot, plot_structure_factor

plot(...)
plot_structure_factor(...)

Like the samplers, plot_structure_factor uses the backend selected for the dimension of the points (see above).

License

MIT

Metadata

Release files for qmc-sampler 3.0.0

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

Source distribution (sdist)

Source distribution for qmc-sampler 3.0.0
File Size Uploaded Provenance Actions
qmc_sampler-3.0.0.tar.gz 18.3 kB Without provenance Details for qmc_sampler-3.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qmc-sampler 3.0.0
File Interpreter ABI Platform Actions
qmc_sampler-3.0.0-py3-none-any.whl Python 3 none any Details for qmc_sampler-3.0.0-py3-none-any.whl

Total release size: 40.2 kB

Release files / qmc_sampler-3.0.0.tar.gz

Download URL qmc_sampler-3.0.0.tar.gz
Size 18.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1138bc2ae6531b391df8906feb795f845591c50dbd795b551ebf4866215ab47e
BLAKE2b-256 checksum
How to use checksums
e779887e38c3d664fa267ab1d9cb89f31a41f79d82bc7849c31f067457abeedb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / qmc_sampler-3.0.0-py3-none-any.whl

Download URL qmc_sampler-3.0.0-py3-none-any.whl
Size 21.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
932e43ffe7df8555793c78f84063ecb9739d76fb7c2fe4c9409f41a9f2b4382d
BLAKE2b-256 checksum
How to use checksums
1bfbb86e8de9d6f7d53e4c0701308dae66561e486adb6745cafc4fec42296490
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for qmc-sampler 3.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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