Struct statrs::statistics::Data

source ·
pub struct Data<D>(_);

Implementations§

source§

impl<D: AsMut<[f64]> + AsRef<[f64]>> Data<D>

source

pub fn new(data: D) -> Self

source

pub fn swap(&mut self, i: usize, j: usize)

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn iter(&self) -> Iter<'_, f64>

Trait Implementations§

source§

impl<D: Clone> Clone for Data<D>

source§

fn clone(&self) -> Data<D>

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<D: Debug> Debug for Data<D>

source§

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

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

impl<D: AsMut<[f64]> + AsRef<[f64]>> Distribution<f64> for Data<D>

source§

fn mean(&self) -> Option<f64>

Evaluates the sample mean, an estimate of the population mean.

Remarks

Returns f64::NAN if data is empty or an entry is f64::NAN

Examples
#[macro_use]
extern crate statrs;

use statrs::statistics::Distribution;
use statrs::statistics::Data;

let x = [];
let x = Data::new(x);
assert!(x.mean().unwrap().is_nan());

let y = [0.0, f64::NAN, 3.0, -2.0];
let y = Data::new(y);
assert!(y.mean().unwrap().is_nan());

let z = [0.0, 3.0, -2.0];
let z = Data::new(z);
assert_almost_eq!(z.mean().unwrap(), 1.0 / 3.0, 1e-15);
source§

fn variance(&self) -> Option<f64>

Estimates the unbiased population variance from the provided samples

Remarks

On a dataset of size N, N-1 is used as a normalizer (Bessel’s correction).

Returns f64::NAN if data has less than two entries or if any entry is f64::NAN

Examples
use statrs::statistics::Distribution;
use statrs::statistics::Data;

let x = [];
let x = Data::new(x);
assert!(x.variance().unwrap().is_nan());

let y = [0.0, f64::NAN, 3.0, -2.0];
let y = Data::new(y);
assert!(y.variance().unwrap().is_nan());

let z = [0.0, 3.0, -2.0];
let z = Data::new(z);
assert_eq!(z.variance().unwrap(), 19.0 / 3.0);
source§

fn std_dev(&self) -> Option<T>

Returns the standard deviation, if it exists. Read more
source§

fn entropy(&self) -> Option<T>

Returns the entropy, if it exists. Read more
source§

fn skewness(&self) -> Option<T>

Returns the skewness, if it exists. Read more
source§

impl<D: AsRef<[f64]>> Distribution<f64> for Data<D>

source§

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

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<D: AsRef<[f64]>> Index<usize> for Data<D>

§

type Output = f64

The returned type after indexing.
source§

fn index(&self, i: usize) -> &f64

Performs the indexing (container[index]) operation. Read more
source§

impl<D: AsMut<[f64]> + AsRef<[f64]>> IndexMut<usize> for Data<D>

source§

fn index_mut(&mut self, i: usize) -> &mut f64

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<D: AsMut<[f64]> + AsRef<[f64]>> Max<f64> for Data<D>

source§

fn max(&self) -> f64

Returns the maximum value in the data

Remarks

Returns f64::NAN if data is empty or an entry is f64::NAN

Examples
use statrs::statistics::Max;
use statrs::statistics::Data;

let x = [];
let x = Data::new(x);
assert!(x.max().is_nan());

let y = [0.0, f64::NAN, 3.0, -2.0];
let y = Data::new(y);
assert!(y.max().is_nan());

let z = [0.0, 3.0, -2.0];
let z = Data::new(z);
assert_eq!(z.max(), 3.0);
source§

impl<D: AsMut<[f64]> + AsRef<[f64]> + Clone> Median<f64> for Data<D>

source§

fn median(&self) -> f64

Returns the median value from the data

Remarks

Returns f64::NAN if data is empty

Examples
use statrs::statistics::Median;
use statrs::statistics::Data;

let x = [];
let x = Data::new(x);
assert!(x.median().is_nan());

let y = [0.0, 3.0, -2.0];
let y = Data::new(y);
assert_eq!(y.median(), 0.0);
source§

impl<D: AsMut<[f64]> + AsRef<[f64]>> Min<f64> for Data<D>

source§

fn min(&self) -> f64

Returns the minimum value in the data

Remarks

Returns f64::NAN if data is empty or an entry is f64::NAN

Examples
use statrs::statistics::Min;
use statrs::statistics::Data;

let x = [];
let x = Data::new(x);
assert!(x.min().is_nan());

let y = [0.0, f64::NAN, 3.0, -2.0];
let y = Data::new(y);
assert!(y.min().is_nan());

let z = [0.0, 3.0, -2.0];
let z = Data::new(z);
assert_eq!(z.min(), -2.0);
source§

impl<D: AsMut<[f64]> + AsRef<[f64]>> OrderStatistics<f64> for Data<D>

source§

fn order_statistic(&mut self, order: usize) -> f64

Returns the order statistic (order 1..N) from the data Read more
source§

fn median(&mut self) -> f64

Returns the median value from the data Read more
source§

fn quantile(&mut self, tau: f64) -> f64

Estimates the tau-th quantile from the data. The tau-th quantile is the data value where the cumulative distribution function crosses tau. Read more
source§

fn percentile(&mut self, p: usize) -> f64

Estimates the p-Percentile value from the data. Read more
source§

fn lower_quartile(&mut self) -> f64

Estimates the first quartile value from the data. Read more
source§

fn upper_quartile(&mut self) -> f64

Estimates the third quartile value from the data. Read more
source§

fn interquartile_range(&mut self) -> f64

Estimates the inter-quartile range from the data. Read more
source§

fn ranks(&mut self, tie_breaker: RankTieBreaker) -> Vec<f64>

Evaluates the rank of each entry of the data. Read more
source§

impl<D: PartialEq> PartialEq<Data<D>> for Data<D>

source§

fn eq(&self, other: &Data<D>) -> 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<D: Eq> Eq for Data<D>

source§

impl<D> StructuralEq for Data<D>

source§

impl<D> StructuralPartialEq for Data<D>

Auto Trait Implementations§

§

impl<D> RefUnwindSafe for Data<D>where D: RefUnwindSafe,

§

impl<D> Send for Data<D>where D: Send,

§

impl<D> Sync for Data<D>where D: Sync,

§

impl<D> Unpin for Data<D>where D: Unpin,

§

impl<D> UnwindSafe for Data<D>where D: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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 Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V