Expand description
§ProDeF - Probability Density Functions
A simple Rust crate for handling probability distributions, primarily intended for use with Bayesian inference. Provides efficient, type-safe APIs for evaluating, sampling, and manipulating probability densities across univariate, multivariate, and non-parametric representations.
All probability density functions (PDFs) implement the Density trait, the core trait of this crate, providing common operations like:
- Evaluation: Compute probability density (non-normalized) for a given sample point
- Sampling: Generate random samples according to the given distribution
- Domain queries: Checking valid input ranges
The Domain type defines the valid input space for any density function.
A domain may be bounded, unbounded, or have a special structure. Currently only unbounded domains or hypercubes are supported.
§Distribution Types
MultivariateDensityCombines multiple independent univariate distributions into a multivariate distribution. Use when the individual dimensions are statistically independent.MultivariateNormalDensityA multivariate normal distribution with arbitrary covariance. Use when modeling correlated multi-dimensional data.ParticleDensityA non-parametric density represented by weighted particles / samples. Use for complex distributions that can’t be expressed analytically or for particle filters.
For the univariate case, one can use the following distributions directly:
ConstantDensity- A degenerate distribution at a fixed valueCosineDensity- Cosine distribution over the interval [-π/2, π/2]LogUniformDensity- Uniform distribution in log-space (for positive values)NormalDensity- Normal distributionUniformDensity- Uniform distribution over an interval
§Disclaimer
Some documentation and tests were created or enhanced using AI assistance. All code has been manually reviewed and verified to ensure correctness and adherence to project standards.
Modules§
- pytypes
- Python types to be used with
pyo3.
Structs§
- Constant
Density - A constant (point mass) PDF.
- Cosine
Density - A cosine PDF defined on [-π/2, π/2].
- LogUniform
Density - A loguniform PDF.
- Lognormal
Density - A lognormal PDF.
- Multivariate
Density - A
D-dimensional distribution where each dimension is independent with potentially different univariate distributions. This is a product distribution: - Multivariate
Normal Density - A
D-dimensional Gaussian distribution N(μ, Σ) with: - Normal
Density - A univariate normal PDF.
- Particle
Density - A non-parametric distribution defined by a population of
D-dimensional particles. - Uniform
Density - A uniform PDF.
Enums§
- Domain
- A generic function domain specifying valid input regions for PDFs.
- Sampling
Mode - Sampling mode for the
Density::samplefunction. - Univariate
Density - An algebraic data type (ADT) that contains all univariate PDFs.
Traits§
- Density
- A trait that is shared by all probability density functions.
- Rejection
Sampler - Helper for implementing acceptance-rejection sampling with configurable modes.