Skip to main content

Sampling methods for design of experiments in Python (random, LHS, Halton, Sobol).

Project description

pysampling

python license

Sampling methods for design of experiments in Python. pysampling generates well-spread point sets in the unit hypercube [0, 1]^d and provides a suite of measures to assess their uniformity.

Detailed documentation: https://anyoptimization.com/projects/pysampling

Algorithms

Key Method
random Uniform random sampling
lhs Latin Hypercube Sampling
halton Halton sequence
sobol Sobol sequence
riesz Riesz s-energy (maximin)

Installation

pip install -U pysampling

Usage

Import the sample function and pick an algorithm. Here we draw 50 points in 2 dimensions with Latin Hypercube Sampling:

from pysampling.sample import sample

X = sample("lhs", 50, 2)

To visualize the result (requires the optional plot extra, pip install pysampling[plot]):

import matplotlib.pyplot as plt

plt.scatter(X[:, 0], X[:, 1], s=30, facecolors="none", edgecolors="r")
plt.show()

See examples/plot_sampling.py for a runnable demo.

Development

This project uses pyclawd as its dev toolkit.

pip install -e . --group dev
pyclawd check        # format-check -> lint -> typecheck -> test
pyclawd test fast    # quick test run

Documentation

The docs are built by a cached pipeline (see docs/):

pip install -e . --group docs   # one-time: install the docs toolchain
pyclawd docs build              # compile -> execute (cached) -> render HTML
pyclawd docs serve              # serve docs/build/html locally

Contact

Questions, bugs, or feature requests? Please open an issue on GitHub.

Maintained by Julian Blank.

License

Apache License 2.0 — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysampling-0.2.0.tar.gz (3.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysampling-0.2.0-py3-none-any.whl (38.8 kB view details)

Uploaded Python 3

File details

Details for the file pysampling-0.2.0.tar.gz.

File metadata

  • Download URL: pysampling-0.2.0.tar.gz
  • Upload date:
  • Size: 3.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for pysampling-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c6739e87d16d65fa03df105d9067b010107bc5e93618c7612cec25c210fa2d0a
MD5 63d0895a87b648d0c14a0e897868c021
BLAKE2b-256 39b290cf1c318d4b2c08ee36ec1284a223eb8ef14f108fef4c1905910ddd1a35

See more details on using hashes here.

File details

Details for the file pysampling-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pysampling-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 38.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for pysampling-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 824378a25793b3ad09eb26f19ed5deafa2a0995d25dfde70155bfedfd7ee392f
MD5 e606fd2846cf70931f57adafbadbf89e
BLAKE2b-256 541804c8501d6e95ed3802903965d329fad07cf6a0245d0bad6cb8b701889dac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page