polars_rng
Random number generation in Polars.
Usage
All random number generators are implmented as Polars expressions and can be used anywhere that expressions are allowed, including in lazy contexts.
import polars as pl
import polars_rng as prng
# simulate data from a linear model
# y = x^2 + N(0, 3^2)
(
pl.DataFrame(dict(x = [-3, 0, 2, 3, 4, 6, 11]))
.with_columns(
y = prng.normal(mu = pl.col("x").pow(2), sigma = 3)
)
)
# shape: (7, 2)
# ┌─────┬────────────┐
# │ x ┆ y │
# │ --- ┆ --- │
# │ i64 ┆ f64 │
# ╞═════╪════════════╡
# │ -3 ┆ 8.623695 │
# │ 0 ┆ -7.884036 │
# │ 2 ┆ 2.864818 │
# │ 3 ┆ 5.348727 │
# │ 4 ┆ 19.721068 │
# │ 6 ┆ 37.855376 │
# │ 11 ┆ 123.532992 │
# └─────┴────────────┘
# lazily simulate from binomial
lazy = (
pl.LazyFrame()
.select(n_coins = pl.repeat(10, 6))
.with_columns(
n_heads = prng.binomial(p = .5, n = "n_coins")
)
)
lazy
# <LazyFrame at 0x1150E94F0>
lazy.collect()
# shape: (6, 2)
# ┌─────────┬─────────┐
# │ n_coins ┆ n_heads │
# │ --- ┆ --- │
# │ i32 ┆ f64 │
# ╞═════════╪═════════╡
# │ 10 ┆ 4.0 │
# │ 10 ┆ 7.0 │
# │ 10 ┆ 6.0 │
# │ 10 ┆ 3.0 │
# │ 10 ┆ 2.0 │
# │ 10 ┆ 5.0 │
# └─────────┴─────────┘
Available Distributions
A full list of implmented distributions is available in the main namespace:
from polars_rng import DISTRIBUTIONS
DISTRIBUTIONS
# ['normal',
# 'uniform',
# 'bernoulli',
# 'binomial',
# 'exponential',
# 'poisson',
# 'weibull',
# 'laplace',
# 'gamma',
# 'beta']
Metadata
Release files for polars_rng 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| polars_rng-0.1.0.tar.gz | 28.4 kB | Without provenance | Details for polars_rng-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| polars_rng-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details for polars_rng-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl |
Total release size: 4.0 MB
Release files / polars_rng-0.1.0.tar.gz
| Download URL | polars_rng-0.1.0.tar.gz |
|---|---|
| Size | 28.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9092b5685692794d4aa7a4e16c96d11d19b194bed5a22593a8c2e37363c343fe
|
|
BLAKE2b-256 checksum How to use checksums |
468ffd7120d7fd84723dc5433c3ca1e9555c1f60c35439729fe15faee9af8682
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.10
|
Release files / polars_rng-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | polars_rng-0.1.0-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 |
4dda309af180fa49d93b6f5e59fd0f04e05cdbf5f2dd659fde8049214f5b6adc
|
|
BLAKE2b-256 checksum How to use checksums |
dbc94d992296b04ba2c82664a6ab1a6c5fb6d342ce64dbcad1d9845976363b89
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.10
|
Security for polars_rng 0.1.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.