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>
impl<F: Float> Arithmetic<F>
sourcepub fn new() -> Self
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.);sourcepub fn sample_variance(&self) -> F
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) \)
sourcepub fn sample_std_dev(&self) -> F
pub fn sample_std_dev(&self) -> F
Standard deviation of the sample
Complexity: \( O(1) \)
Trait Implementations§
source§impl<F: Float> Add<Arithmetic<F>> for Arithmetic<F>
impl<F: Float> Add<Arithmetic<F>> for Arithmetic<F>
source§impl<F: Clone + Float> Clone for Arithmetic<F>
impl<F: Clone + Float> Clone for Arithmetic<F>
source§fn clone(&self) -> Arithmetic<F>
fn clone(&self) -> Arithmetic<F>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl<F: Float> Default for Arithmetic<F>
impl<F: Float> Default for Arithmetic<F>
source§impl<F: Float> StatisticsOps<F> for Arithmetic<F>
impl<F: Float> StatisticsOps<F> for Arithmetic<F>
source§fn sample_mean(&self) -> F
fn sample_mean(&self) -> F
Mean of the sample Read more
source§fn sample_sem(&self) -> F
fn sample_sem(&self) -> F
Standard error of the sample mean Read more
source§fn ci_mean(&self, confidence: Confidence) -> CIResult<Interval<F>>
fn ci_mean(&self, confidence: Confidence) -> CIResult<Interval<F>>
Confidence interval of the sample mean Read more
source§fn sample_count(&self) -> usize
fn sample_count(&self) -> usize
Number of samples Read more
impl<F: Copy + Float> Copy 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<F, T> MeanCI<F> for Twhere
F: Float,
T: StatisticsOps<F>,
impl<F, T> MeanCI<F> for Twhere F: Float, T: StatisticsOps<F>,
source§fn ci<I>(confidence: Confidence, data: I) -> Result<Interval<F>, CIError>where
I: IntoIterator<Item = F>,
fn ci<I>(confidence: Confidence, data: I) -> Result<Interval<F>, CIError>where I: IntoIterator<Item = F>,
Compute the confidence interval on the mean of a sample Read more
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
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
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.