pub struct Geometric<F: Float> { /* private fields */ }Expand description
Represents the state of the computation of the geometric mean.
This is a simple implementation that accumulates information about the samples, such as sum and sum of squares.
It is implemented as a wrapper around Arithmetic to compute the arithmetic mean of the logarithms of the samples.
It is best used through the StatisticsOps trait.
Implementations§
source§impl<F: Float> Geometric<F>
impl<F: Float> Geometric<F>
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new empty state
Example
let mut stats = mean::Geometric::new();
stats.append(10.)?;
assert_eq!(stats.sample_count(), 1);
assert_abs_diff_eq!(stats.sample_mean(), 10., epsilon = 1e-10);sourcepub fn append(&mut self, x: F) -> CIResult<()>
pub fn append(&mut self, x: F) -> CIResult<()>
Append a new sample to the data
Complexity: \( O(1) \)
sourcepub fn sample_mean(&self) -> F
pub fn sample_mean(&self) -> F
Geometric mean of the sample
sourcepub fn sample_sem(&self) -> F
pub fn sample_sem(&self) -> F
Standard error of the geometric mean
Computed as: \( G \frac{s_{\log x_i}}{\sqrt{n-1}} \) where \( G \) is the geometric mean of the sample; \( s_{\log x_i} \) is the estimate of the standard deviation of the logarithms of the samples; and \( n-1 \) is the degree of freedom of the sample data.
Reference
- Nilan Noris. “The standard errors of the geometric and harmonic means and their application to index numbers.” Ann. Math. Statist. 11(4): 445-448 (December, 1940). DOI: 10.1214/aoms/1177731830 JSTOR
sourcepub fn sample_count(&self) -> usize
pub fn sample_count(&self) -> usize
Number of samples
Complexity: \( O(1) \)
sourcepub fn ci_mean(&self, confidence: Confidence) -> CIResult<Interval<F>>
pub fn ci_mean(&self, confidence: Confidence) -> CIResult<Interval<F>>
Confidence interval for the geometric mean
sourcepub fn ci<I>(confidence: Confidence, data: I) -> CIResult<Interval<F>>where
I: IntoIterator<Item = F>,
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 intervaldata- The data to compute the confidence interval on
Output
Ok(interval)- The confidence interval on the mean of the sample
Errors
CIError::TooFewSamples- If the input data has too few samples to compute the confidence intervalCIError::NonPositiveValue- If the input data contains non-positive values when computing harmonic/geometric means.CIError::InvalidInputData- If the input data contains invalid values (e.g. NaN)CIError::FloatConversionError- If some data cannot be converted to a float
Trait Implementations§
source§impl<F: Float> AddAssign<Geometric<F>> for Geometric<F>
impl<F: Float> AddAssign<Geometric<F>> for Geometric<F>
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moresource§impl<F: Float> MeanCI<F> for Geometric<F>
impl<F: Float> MeanCI<F> for Geometric<F>
source§fn ci<I>(confidence: Confidence, data: I) -> CIResult<Interval<F>>where
I: IntoIterator<Item = F>,
fn ci<I>(confidence: Confidence, data: I) -> CIResult<Interval<F>>where I: IntoIterator<Item = F>,
source§impl<F: PartialEq + Float> PartialEq<Geometric<F>> for Geometric<F>
impl<F: PartialEq + Float> PartialEq<Geometric<F>> for Geometric<F>
source§impl<F: Float> StatisticsOps<F> for Geometric<F>
impl<F: Float> StatisticsOps<F> for Geometric<F>
source§fn sample_mean(&self) -> F
fn sample_mean(&self) -> F
source§fn sample_sem(&self) -> F
fn sample_sem(&self) -> F
source§fn ci_mean(&self, confidence: Confidence) -> CIResult<Interval<F>>
fn ci_mean(&self, confidence: Confidence) -> CIResult<Interval<F>>
source§fn sample_count(&self) -> usize
fn sample_count(&self) -> usize
source§fn ci<I>(confidence: Confidence, data: I) -> CIResult<Interval<F>>where
I: IntoIterator<Item = F>,
fn ci<I>(confidence: Confidence, data: I) -> CIResult<Interval<F>>where I: IntoIterator<Item = F>,
impl<F: Copy + Float> Copy for Geometric<F>
impl<F: Float> StructuralPartialEq for Geometric<F>
Auto Trait Implementations§
impl<F> RefUnwindSafe for Geometric<F>where F: RefUnwindSafe,
impl<F> Send for Geometric<F>where F: Send,
impl<F> Sync for Geometric<F>where F: Sync,
impl<F> Unpin for Geometric<F>where F: Unpin,
impl<F> UnwindSafe for Geometric<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
§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>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.