Expand description
Standard probability distributions, bridging rand_distr into the
tpt_math_prob_core trait ecosystem.
This crate wraps the rand_distr distributions and makes them sampleable
through the minimal tpt_math_prob_core::Rng/Distribution
traits used across the tpt-math-prob-* family. Because our Rng is far
smaller than rand’s RngCore, we provide CoreRng: a thin adapter
that turns any of our RNGs into a rand::RngCore so that every
rand_distr distribution can be sampled without pulling in rand’s own
generators.
The distributions themselves are not directly re-implemented. Instead the
local Dist wrapper (and the small AsU64 helper for counts) adapts a
rand_distr distribution to our Distribution
trait. Constructor functions (normal, uniform, poisson, …) give
ergonomic, documented entry points, and the raw rand_distr module is
re-exported so advanced users can reach under the bridge.
The crate is no_std-compatible; all float math is delegated to
rand_distr (which uses num-traits’s libm fallback), and std-only
conveniences are gated behind the default std feature.
§Examples
use tpt_math_prob_core::{Distribution, Rng, SplitMix64};
use tpt_math_prob_dist::{normal, Dist};
let mut rng = SplitMix64::seed_from_u64(0);
let gauss = normal((0.0, 1.0)).unwrap();
let x: f64 = Dist::new(gauss).sample(&mut rng);
// or, equivalently, with the explicit bridge type:
let y: f64 = Dist::new(normal((2.0, 3.0)).unwrap()).sample(&mut rng);
let _ = x + y;Re-exports§
pub use rand_distr;
Modules§
- density
- Densities, probability mass functions, CDFs and quantiles. Needs
std(the default) for the special functions intpt-math-prob-core. Densities, probability mass functions, CDFs and quantiles. - multivariate
- The multivariate normal distribution.
Structs§
- AsU64
- Wrap a float-producing
rand_distrdistribution and emit integer counts. - CoreRng
- Adapter turning one of our
Rngs into arand::RngCore. - Dist
- A
rand_distrdistribution adapted to ourDistributiontrait. - Split
Mix64 SplitMix64: a tiny, fast, deterministic 64-bit PRNG.- Standard
- The standard uniform distribution over the type’s natural range.
Traits§
- Distribution
- A distribution that can produce samples of type
T. - Rng
- A source of pseudo-random bits.
- Sampler
- Bulk sampling for any
Distribution.
Functions§
- beta
Betadistribution with shape parametersalpha,beta.- cauchy
Cauchydistribution withmedianandscale.- chi_
squared ChiSquareddistribution withkdegrees of freedom.- exp
Exp(exponential) distribution with ratelambda.- gamma
Gammadistribution with shape and scale.- lognormal
LogNormaldistribution.- normal
Normal(Gaussian) distribution,N(mean, std_dev).- poisson
Poissondistribution with ratelambda(samples returned asu64).- student_
t - Student’s
tdistribution withnudegrees of freedom. - uniform
Uniformdistribution over an inclusive-exclusive range[low, high).
Type Aliases§
- Beta
Betadistribution with shape parametersalpha,beta.- Cauchy
Cauchydistribution withmedianandscale.- ChiSquared
ChiSquareddistribution withkdegrees of freedom.- Exp
Exp(exponential) distribution with ratelambda.- Gamma
Gammadistribution with shape and scale.- LogNormal
LogNormaldistribution.- Normal
Normal(Gaussian) distribution,N(mean, std_dev).- Poisson
Poissondistribution with ratelambda(samples returned asu64).- StudentT
- Student’s
tdistribution withnudegrees of freedom.