Struct russell_stat::DistributionUniform

source ·
pub struct DistributionUniform { /* private fields */ }
Expand description

Defines the Uniform / Type II Extreme Value Distribution (largest value)

Implementations§

source§

impl DistributionUniform

source

pub fn new(xmin: f64, xmax: f64) -> Result<Self, StrError>

Creates a new Uniform distribution

§Input
  • xmin – min x value
  • xmax – max x value
Examples found in repository?
examples/distribution_uniform.rs (line 6)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fn main() -> Result<(), StrError> {
    // generate samples
    let mut rng = rand::thread_rng();
    let dist = DistributionUniform::new(-10.0, 10.0)?;
    let nsamples = 10_000;
    let mut data = vec![0.0; nsamples];
    for i in 0..nsamples {
        data[i] = dist.sample(&mut rng);
    }
    println!("{}", statistics(&data));

    // text-plot
    let stations = (0..21).map(|i| -10.0 + (i as f64)).collect::<Vec<f64>>();
    let mut hist = Histogram::new(&stations)?;
    hist.set_bar_char('🟪').set_bar_max_len(30);
    hist.count(&data);
    println!("{:.2}", hist);
    Ok(())
}

Trait Implementations§

source§

impl ProbabilityDistribution for DistributionUniform

source§

fn pdf(&self, x: f64) -> f64

Implements the Probability Density Function (CDF)

source§

fn cdf(&self, x: f64) -> f64

Implements the Cumulative Density Function (CDF)

source§

fn mean(&self) -> f64

Returns the Mean

source§

fn variance(&self) -> f64

Returns the Variance

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64

Generates a pseudo-random number belonging to this probability distribution

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V