Skip to main content

DescrStatsW

Struct DescrStatsW 

Source
pub struct DescrStatsW { /* private fields */ }
Expand description

Weighted descriptive statistics for a 1-D sample.

Wraps a data vector and (optional) case weights and exposes the weighted mean, (co)variance with a configurable degrees-of-freedom correction, and a one-sample t-test of the mean. Mirrors the reference DescrStatsW.

Implementations§

Source§

impl DescrStatsW

Source

pub fn new(data: Array1<f64>, weights: Option<Array1<f64>>, ddof: f64) -> Self

Construct from data and optional weights (defaulting to all-ones), with degrees-of-freedom correction ddof (default convention 0).

Source

pub fn sum_weights(&self) -> f64

Sum of the weights (the effective number of observations).

Source

pub fn nobs(&self) -> f64

Number of observations, equal to the sum of weights.

Source

pub fn sum(&self) -> f64

Weighted sum of the data.

Source

pub fn mean(&self) -> f64

Weighted mean of the data.

Source

pub fn sumsquares(&self) -> f64

Weighted sum of squares of the demeaned data.

Source

pub fn var_ddof(&self, ddof: f64) -> f64

Variance with denominator sum_weights - ddof_override.

Source

pub fn var(&self) -> f64

Variance with the instance’s default ddof.

Source

pub fn std_ddof(&self, ddof: f64) -> f64

Standard deviation with denominator sum_weights - ddof_override.

Source

pub fn std(&self) -> f64

Standard deviation with the instance’s default ddof.

Source

pub fn std_mean(&self) -> f64

Standard error of the weighted mean.

Uses the ddof-adjusted standard deviation rescaled to the population form and divided by sqrt(sum_weights - 1), exactly as the reference.

Source

pub fn ttest_mean(&self, value: f64, alternative: Alternative) -> TTestResult

One-sample t-test that the (weighted) mean equals value.

Returns the statistic (mean - value) / std_mean, its t-distribution p-value with sum_weights - 1 degrees of freedom, and that d.o.f.

Trait Implementations§

Source§

impl Clone for DescrStatsW

Source§

fn clone(&self) -> DescrStatsW

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 Debug for DescrStatsW

Source§

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

Formats the value using the given formatter. Read more

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