pub struct LogNormal { /* private fields */ }Expand description
A continuous distribution where the logarithm follows a normal distribution.
Useful for modeling positive-valued quantities that are naturally multiplicative or skewed.
Mathematical Properties:
- Support: (0, +∞)
- PDF: f(x) = (1/(xσ√(2π))) × exp(-0.5 × ((ln(x)-μ)/σ)²)
- Mean: exp(μ + σ²/2)
- Variance: (exp(σ²) - 1) × exp(2μ + σ²)
- Relationship: If X ~ LogNormal(μ, σ), then ln(X) ~ Normal(μ, σ)
Example:
// Standard log-normal (median = 1)
let standard = sample(addr!("x"), LogNormal::new(0.0, 1.0).unwrap());
// Positive scale parameter
let scale = sample(addr!("scale"), LogNormal::new(0.0, 0.5).unwrap());
// Income distribution
let income = sample(addr!("income"), LogNormal::new(10.0, 0.8).unwrap())
.map(|x| x.round() as u64); // Convert to dollars
// Multiplicative error model
let true_value = 100.0;
let measured = sample(addr!("error"), LogNormal::new(0.0, 0.1).unwrap())
.map(move |error| true_value * error);Implementations§
Trait Implementations§
impl Copy for LogNormal
Source§impl Distribution<f64> for LogNormal
impl Distribution<f64> for LogNormal
Source§fn sample(&self, rng: &mut dyn RngCore) -> f64
fn sample(&self, rng: &mut dyn RngCore) -> f64
Generate a random sample (with its natural type),
T, from the distribution, using the provided random number generator, rng. Read moreAuto Trait Implementations§
impl Freeze for LogNormal
impl RefUnwindSafe for LogNormal
impl Send for LogNormal
impl Sync for LogNormal
impl Unpin for LogNormal
impl UnsafeUnpin for LogNormal
impl UnwindSafe for LogNormal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more