pub struct WeightedUniform<T: PartialOrd + SampleUniform + Copy + Into<f64>> { /* private fields */ }

Implementations

Create a new weighted uniform distribution

Examples
extern crate peroxide;
use peroxide::fuga::*;
 
fn main() {
    let weights = vec![1f64, 3f64, 0f64, 2f64];
    let intervals = vec![0f64, 1f64, 2f64, 4f64, 5f64];
    let w = WeightedUniform::new(weights, intervals);
    assert_eq!(w.weights(), &vec![1f64, 3f64, 2f64]);
    assert_eq!(w.intervals(), &vec![(0f64, 1f64), (1f64, 2f64), (4f64, 5f64)]);
}

Create WeightedUniform from max pooling

Examples
extern crate peroxide;
use peroxide::fuga::*;
 
fn main() {
    let w = WeightedUniform::from_max_pool_1d(f, (-2f64, 3f64), 10, 1e-3);
    w.weights().print();
}
 
fn f(x: f64) -> f64 {
    if x.abs() < 1f64 {
        (1f64 - x.abs())
    } else {
       0f64
    }
}

Trait Implementations

Extract samples of distributions
Probability Distribution Function Read more
Cumulative Distribution Function Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.