Skip to main content

Normal

Struct Normal 

Source
pub struct Normal<T> { /* private fields */ }
Expand description

Normal distribution

Fore more information: https://en.wikipedia.org/wiki/Normal_distribution

Implementations§

Source§

impl<T> Normal<T>
where T: Real,

Source

pub fn new(mean: T, variance: T) -> Self

Creates a probability distribution

§Arguments
  • mean: Expected value
  • variance: variance > 0.0
§Panics

if variance <= 0.0

§Example
use mathru::statistics::distrib::Normal;

let distrib: Normal<f64> = Normal::new(0.3, 0.2);
Source

pub fn from_data(data: &[T]) -> Self

It is assumed that data are normal distributed.

Trait Implementations§

Source§

impl<T: Clone> Clone for Normal<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Continuous<T> for Normal<T>
where T: Real + Gamma + Error,

Source§

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

Probability density function

§Arguments
  • x: x ∈ &#x2115
§Example
use mathru::statistics::distrib::{Continuous, Normal};

let distrib: Normal<f64> = Normal::new(0.3, 0.2);
let x: f64 = 5.0;
let p: f64 = distrib.pdf(x);
Source§

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

Cumulative distribution function

§Arguments
  • x:
§Example
use mathru::statistics::distrib::{Continuous, Normal};

let distrib: Normal<f64> = Normal::new(0.3, 0.2);
let x: f64 = 0.4;
let p: f64 = distrib.cdf(x);
Source§

fn quantile(&self, p: T) -> T

Quantile: function of inverse cdf

The Percentage Points of the Normal Distribution Author(s): Michael J. Wichura Year 1988 Journal of the Royal Statistical Society 0.0 < p < 1.0

§Panics

if p <= 0.0 || p >= 1.0

Source§

fn mean(&self) -> T

Expected value

§Example
use mathru::{
    self,
    statistics::distrib::{Continuous, Normal},
};

let distrib: Normal<f64> = Normal::new(0.0, 0.2);
let mean: f64 = distrib.mean();
Source§

fn variance(&self) -> T

Variance

§Example
use mathru::{
    self,
    statistics::distrib::{Continuous, Normal},
};

let distrib: Normal<f64> = Normal::new(0.0, 0.2);
let var: f64 = distrib.variance();
Source§

fn skewness(&self) -> T

Skewness

§Example
use mathru::{
    self,
    statistics::distrib::{Continuous, Normal},
};
let mean: f64 = 1.0;
let variance: f64 = 0.5;
let distrib: Normal<f64> = Normal::new(mean, variance);
assert_eq!(0.0, distrib.skewness());
Source§

fn median(&self) -> T

Median

§Example
use mathru::{
    self,
    statistics::distrib::{Continuous, Normal},
};

let mean: f64 = 0.0;

let distrib: Normal<f64> = Normal::new(mean, 0.2);
let median: f64 = distrib.median();
Source§

fn entropy(&self) -> T

Entropy

§Example
use mathru::{
    self,
    statistics::distrib::{Continuous, Normal},
};
use std::f64::consts::{E, PI};

let mean: f64 = 1.0;
let variance: f64 = 0.5;
let distrib: Normal<f64> = Normal::new(mean, variance);

let entropy: f64 =  distrib.entropy();
Source§

impl<T: Copy> Copy for Normal<T>

Source§

impl<T: Debug> Debug for Normal<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Distribution<T> for Normal<T>
where T: Real,

Source§

fn random(&self) -> T

See Knuth The Art of Computer Programming Vol 2 3.4.1 C Algorithm P

Source§

fn random_sequence(&self, size: u32) -> Vec<T>

Auto Trait Implementations§

§

impl<T> Freeze for Normal<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Normal<T>
where T: RefUnwindSafe,

§

impl<T> Send for Normal<T>
where T: Send,

§

impl<T> Sync for Normal<T>
where T: Sync,

§

impl<T> Unpin for Normal<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Normal<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Normal<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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