pub struct Normal { /* private fields */ }Expand description
A continuous distribution characterized by its mean, mu, and standard deviation, sigma.
Mathematical Properties:
- Support: (-∞, +∞)
- PDF: f(x) = (1/(σ√(2π))) × exp(-0.5 × ((x-μ)/σ)²)
- Mean: μ
- Variance: σ²
- 68-95-99.7 rule: ~68% within 1σ, ~95% within 2σ, ~99.7% within 3σ
Example:
// Standard normal (mean=0, std=1)
let standard = sample(addr!("z"), Normal::new(0.0, 1.0).unwrap());
// Parameter with prior
let theta = sample(addr!("theta"), Normal::new(0.0, 2.0).unwrap());
// Likelihood with observation
let likelihood = observe(addr!("y"), Normal::new(1.5, 0.5).unwrap(), 2.0);
// Measurement error model
let true_value = sample(addr!("true_val"), Normal::new(100.0, 10.0).unwrap());
let measurement = true_value.bind(|val| {
observe(addr!("measured"), Normal::new(val, 2.0).unwrap(), 98.5)
});Implementations§
Source§impl Normal
impl Normal
Sourcepub fn new(mu: f64, sigma: f64) -> FugueResult<Self>
pub fn new(mu: f64, sigma: f64) -> FugueResult<Self>
Create a new Normal distribution with validated parameters.
Trait Implementations§
impl Copy for Normal
Source§impl Distribution<f64> for Normal
impl Distribution<f64> for Normal
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 Normal
impl RefUnwindSafe for Normal
impl Send for Normal
impl Sync for Normal
impl Unpin for Normal
impl UnsafeUnpin for Normal
impl UnwindSafe for Normal
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