Struct stats::OnlineStats

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

Online state for computing mean, variance and standard deviation.

Implementations§

source§

impl OnlineStats

source

pub fn new() -> OnlineStats

Create initial state.

Population size, variance and mean are set to 0.

source

pub fn from_slice<T: ToPrimitive>(samples: &[T]) -> OnlineStats

Initializes variance from a sample.

source

pub const fn mean(&self) -> f64

Return the current mean.

source

pub fn stddev(&self) -> f64

Return the current standard deviation.

source

pub fn variance(&self) -> f64

Return the current variance.

source

pub fn add<T: ToPrimitive>(&mut self, sample: &T)

Add a new sample.

source

pub fn add_null(&mut self)

Add a new NULL value to the population.

This increases the population size by 1.

source

pub const fn len(&self) -> usize

Returns the number of data points.

source

pub const fn is_empty(&self) -> bool

Returns if empty.

Trait Implementations§

source§

impl Clone for OnlineStats

source§

fn clone(&self) -> OnlineStats

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Commute for OnlineStats

source§

fn merge(&mut self, v: OnlineStats)

Merges the value other into self.
source§

fn consume<I: Iterator<Item = Self>>(&mut self, other: I)

Merges the values in the iterator into self.
source§

impl Debug for OnlineStats

source§

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

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

impl Default for OnlineStats

source§

fn default() -> OnlineStats

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for OnlineStats

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T: ToPrimitive> Extend<T> for OnlineStats

source§

fn extend<I: IntoIterator<Item = T>>(&mut self, it: I)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<T: ToPrimitive> FromIterator<T> for OnlineStats

source§

fn from_iter<I: IntoIterator<Item = T>>(it: I) -> OnlineStats

Creates a value from an iterator. Read more
source§

impl PartialEq for OnlineStats

source§

fn eq(&self, other: &OnlineStats) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for OnlineStats

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for OnlineStats

source§

impl StructuralPartialEq for OnlineStats

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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

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>,

§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,