Struct stats_ci::mean::Arithmetic

source ·
pub struct Arithmetic<F: Float> { /* private fields */ }
Expand description

Represents the state of the computation of the arithmetic mean. This is a simple implementation that accumulates information about the samples, such as sum and sum of squares.

It is best used through the StatisticsOps trait.

Implementations§

source§

impl<F: Float> Arithmetic<F>

source

pub fn new() -> Self

Create a new empty state

Example
use stats_ci::*;
let mut stats = mean::Arithmetic::new();
stats.append(10.);
assert_eq!(stats.sample_count(), 1);
assert_eq!(stats.sample_mean(), 10.);
source

pub fn sample_variance(&self) -> F

Variance of the sample \( \frac{1}{n-1}\left(\sum_{i=1}^n x_i^2 - \frac{1}{n} \left(\sum_{i=1}^n x_i\right)^2 \right) \)

Complexity: \( O(1) \)

source

pub fn sample_std_dev(&self) -> F

Standard deviation of the sample

Complexity: \( O(1) \)

source

pub fn sample_mean(&self) -> F

Mean of the sample

Complexity: \( O(1) \)

source

pub fn sample_sem(&self) -> F

Standard error of the sample mean

Complexity: \( O(1) \)

source

pub fn ci_mean(&self, confidence: Confidence) -> CIResult<Interval<F>>

Confidence interval of the sample mean

Complexity: \( O(1) \)

source

pub fn sample_count(&self) -> usize

Number of samples

Complexity: \( O(1) \)

source

pub fn add(self, rhs: Self) -> Self

Combine two states

Complexity: \( O(1) \)

source

pub fn ci<I>(confidence: Confidence, data: I) -> CIResult<Interval<F>>where I: IntoIterator<Item = F>,

Compute the confidence interval on the mean of a sample

Arguments
  • confidence - The confidence level of the interval
  • data - The data to compute the confidence interval on
Output
  • Ok(interval) - The confidence interval on the mean of the sample
Errors

Trait Implementations§

source§

impl<F: Float> Add<Arithmetic<F>> for Arithmetic<F>

§

type Output = Arithmetic<F>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl<F: Float> AddAssign<Arithmetic<F>> for Arithmetic<F>

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl<F: Clone + Float> Clone for Arithmetic<F>

source§

fn clone(&self) -> Arithmetic<F>

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<F: Debug + Float> Debug for Arithmetic<F>

source§

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

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

impl<F: Float> Default for Arithmetic<F>

source§

fn default() -> Self

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

impl<F: Float> MeanCI<F> for Arithmetic<F>

source§

fn ci<I>(confidence: Confidence, data: I) -> CIResult<Interval<F>>where I: IntoIterator<Item = F>,

Compute the confidence interval on the mean of a sample Read more
source§

impl<F: PartialEq + Float> PartialEq<Arithmetic<F>> for Arithmetic<F>

source§

fn eq(&self, other: &Arithmetic<F>) -> 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<F: Float> StatisticsOps<F> for Arithmetic<F>

source§

fn append(&mut self, x: F) -> CIResult<()>

Append a new sample to the data Read more
source§

fn sample_mean(&self) -> F

Mean of the sample Read more
source§

fn sample_sem(&self) -> F

Standard error of the sample mean Read more
source§

fn ci_mean(&self, confidence: Confidence) -> CIResult<Interval<F>>

Confidence interval of the sample mean Read more
source§

fn sample_count(&self) -> usize

Number of samples Read more
source§

fn ci<I>(confidence: Confidence, data: I) -> CIResult<Interval<F>>where I: IntoIterator<Item = F>,

Compute the confidence interval on the mean of a sample Read more
source§

fn from_iter<I: IntoIterator<Item = F>>(data: I) -> CIResult<Self>

Create a new state and “populates” it with data from an iterator Read more
source§

fn extend<I: IntoIterator<Item = F>>(&mut self, data: I) -> CIResult<()>

Extend the data with additional sample data. Read more
source§

impl<F: Copy + Float> Copy for Arithmetic<F>

source§

impl<F: Float> StructuralPartialEq for Arithmetic<F>

Auto Trait Implementations§

§

impl<F> RefUnwindSafe for Arithmetic<F>where F: RefUnwindSafe,

§

impl<F> Send for Arithmetic<F>where F: Send,

§

impl<F> Sync for Arithmetic<F>where F: Sync,

§

impl<F> Unpin for Arithmetic<F>where F: Unpin,

§

impl<F> UnwindSafe for Arithmetic<F>where F: 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
§

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

§

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

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

fn is_in_subset(&self) -> bool

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

fn to_subset_unchecked(&self) -> SS

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

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

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

§

fn vzip(self) -> V

§

impl<T, Right> ClosedAdd<Right> for Twhere T: Add<Right, Output = T> + AddAssign<Right>,

source§

impl<T> Scalar for Twhere T: 'static + Clone + PartialEq<T> + Debug,