Skip to main content

polars-sdist

Statistical distributions as native Polars expressions. Built with Rust and PyO3 for zero-copy, vectorized computation over Polars DataFrames.

Install

pip install polars-sdist

Quick start

import polars as pl
from polars_sdist import SdistNamespace as sdist

df = pl.DataFrame({"x": [-1.96, 0.0, 1.96]})

# CDF, PDF, PPF, SF, ln_pdf — all as expressions
df.with_columns(
    cdf=sdist(pl.col("x")).normal_cdf(mu=0, sigma=1),
    pdf=sdist(pl.col("x")).normal_pdf(mu=0, sigma=1),
    sf=sdist(pl.col("x")).normal_sf(mu=0, sigma=1),
)

Inverse CDF (PPF)

df = pl.DataFrame({"p": [0.025, 0.5, 0.975]})
df.with_columns(
    z=sdist(pl.col("p")).normal_ppf(mu=0, sigma=1),
)

Discrete distributions

df = pl.DataFrame({"k": [0, 1, 2, 3, 4, 5]}).cast({"k": pl.Float64})
df.with_columns(
    pmf=sdist(pl.col("k")).poisson_pmf(lambda_=3.0),
    cdf=sdist(pl.col("k")).poisson_cdf(lambda_=3.0),
)

Random sampling (fixed parameters)

import polars_sdist

s = polars_sdist.sample_normal(n=10_000, mu=0, sigma=1, seed=42)
s = polars_sdist.sample_beta(n=10_000, alpha=2, beta=5, seed=42)

Random sampling (column parameters)

df = pl.DataFrame({
    "mu": [0.0, 10.0, -10.0],
    "sigma": [1.0, 0.5, 2.0],
})
df.with_columns(
    sample=sdist(pl.col("mu")).sample_normal(sigma=pl.col("sigma"), seed=42),
)

Supported distributions

Continuous

Distribution Parameters PDF CDF PPF SF ln_pdf
Normal mu, sigma x x x x x
Log-Normal mu, sigma x x x x x
Beta alpha, beta x x x x x
Gamma shape, rate x x x x x
Exponential lambda_ x x x x x
Cauchy location, scale x x x x x
Chi-Squared df x x x x x
Student's t df x x x x x
Fisher-Snedecor (F) d1, d2 x x x x x
Gumbel location, scale x x x x x
Inverse Gamma shape, scale x x x x x
Laplace location, scale x x x x x
Pareto shape, scale x x x x x
Triangular min, max, mode x x x x x
Uniform a, b x x x x x
Weibull shape, scale x x x x x

Discrete

Distribution Parameters PMF CDF PPF SF
Bernoulli p x x x x
Binomial n, p x x x x
Geometric p x x x x
Hypergeometric pop_size, success_states, draws x x x x
Negative Binomial r, p x x x x
Poisson lambda_ x x x x
Discrete Uniform a, b x x x x

Sampling-only

These distributions support random sampling but not PDF/CDF:

PERT, Skew-Normal, Inverse Gaussian, Frechet, Zeta, Zipf

Performance

Benchmarked end-to-end against scipy/numpy on 1M elements. Median of 5 runs after warmup.

Distribution Operation polars-sdist scipy Speedup
normal pdf 8.6 ms 36.8 ms 4.3x
normal ppf 20.9 ms 48.4 ms 2.3x
normal sample 3.6 ms 7.6 ms 2.1x
normal cdf 23.3 ms 37.2 ms 1.6x
lognormal pdf 17.1 ms 63.8 ms 3.7x
lognormal sample 7.2 ms 12.7 ms 1.8x
lognormal ppf 27.8 ms 42.3 ms 1.5x
lognormal cdf 32.5 ms 41.4 ms 1.3x
binomial pmf 32.0 ms 86.2 ms 2.7x
binomial sample 20.1 ms 30.5 ms 1.5x
chi-squared sample 10.0 ms 16.7 ms 1.7x
chi-squared pdf 49.2 ms 60.9 ms 1.2x
chi-squared cdf 90.3 ms 110.9 ms 1.2x
beta ppf 517.8 ms 601.1 ms 1.2x
beta pdf 80.3 ms 89.5 ms 1.1x

polars-sdist is faster in 15 of 19 benchmarks. Areas where scipy is faster (beta CDF/sample, chi-squared PPF, binomial CDF) use highly optimized C/Fortran special-function implementations.

Run it yourself:

pip install scipy
python benchmarks/bench_distributions.py --sizes 1000000

License

MIT

Metadata

Release files for polars-sdist 0.1.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 polars-sdist 0.1.1
File Size Uploaded
polars_sdist-0.1.1.tar.gz 38.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for polars-sdist 0.1.1
File
polars_sdist-0.1.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl PyPy 3.11 PyPy 3.11 7.3 Linux glibc 2.17+ x86-64 Details
polars_sdist-0.1.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
polars_sdist-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
polars_sdist-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
polars_sdist-0.1.1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
polars_sdist-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 25.2 MB

Release files / polars_sdist-0.1.1.tar.gz

Download URL polars_sdist-0.1.1.tar.gz
Size 38.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2720efd6dfaca6e0d0e839b933e3de7b1d32cbc11c65b6b0643645039cd1f3d2
BLAKE2b-256 checksum
How to use checksums
4ace1858cce0724e3c731377422a891243bebe6c9dd3986eb7aac1b96bee3b12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 13, 2026.

Transparency log

Release files / polars_sdist-0.1.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL polars_sdist-0.1.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.4 MB
Tags Linux glibc 2.17+ x86-64 PyPy 3.11 PyPy 3.11 7.3
SHA-256 checksum
How to use checksums
7c5c371d22ed61dd807c117ecc393e43908d6848246cda1b3358dab0b6bee98e
BLAKE2b-256 checksum
How to use checksums
4be32126c37a2d4b3b160b2ff357a02c36550a3f6f5345a3b2fb717c4be4478e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 13, 2026.

Transparency log

Release files / polars_sdist-0.1.1-cp39-abi3-win_amd64.whl

Download URL polars_sdist-0.1.1-cp39-abi3-win_amd64.whl
Size 4.6 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
dd18bddaaac491701571e48054c4cd2104e5dd11029d5bf73241b9b73fe1cf4d
BLAKE2b-256 checksum
How to use checksums
1248fa36bcd542aa428356f37a7390801fcd7701ba284670c8ee5b81195a3451
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 13, 2026.

Transparency log

Release files / polars_sdist-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL polars_sdist-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.4 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
2b94f0868d9a921bf408e528114120ea98fa2e6da2a557d51d4638bc6b6720f7
BLAKE2b-256 checksum
How to use checksums
fe8b428e1d06b540828c69c5f1266a5e22b68de556b8e24c2b17c9d160199509
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 13, 2026.

Transparency log

Release files / polars_sdist-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL polars_sdist-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 4.0 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
2f7546ee8c75cfbdaf8f499f9ac74d89bd5626915fed6fa6201e8ecffb88d6a7
BLAKE2b-256 checksum
How to use checksums
7b34176c8abd45dd0f92caa0a6008a4187111ee98ced3ff99c72cd87d9459178
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 13, 2026.

Transparency log

Release files / polars_sdist-0.1.1-cp39-abi3-macosx_11_0_arm64.whl

Download URL polars_sdist-0.1.1-cp39-abi3-macosx_11_0_arm64.whl
Size 3.7 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
284f44ef2b46c2d371fe437b679f5f0b7adc8889ddea92e02187c8b3dbd1e895
BLAKE2b-256 checksum
How to use checksums
3b166dc62757ee40c502d7e3079656610e13777fceea4c07a8ee6e0975d22cd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 13, 2026.

Transparency log

Release files / polars_sdist-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl

Download URL polars_sdist-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl
Size 4.0 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
2c77f01b7d6521644b293b2eaa8229bf4d949b454f341c05e746b0423f21737a
BLAKE2b-256 checksum
How to use checksums
c73286d2c5d6d396db0b158613d63824cf0dc2cdac9ac999db589b070d77d3f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

7 release files

0.1.0

6 release files

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