Options
All
  • Public
  • Public/Protected
  • All
Menu

Statistics tool

This class accumulates a set of data and returns their statistics (e.g: mean, variance, skewness, kurtosis, error estimation, percentile, etc.) based on the empirical distribution (no gaussian assumption)

It doesn't suffer the numerical instability problem of IncrementalStatistics. The downside is that it stores all samples, thus increasing the memory requirements.

Hierarchy

  • GeneralStatistics

Index

Type aliases

Static value_type

value_type: Real

Constructors

constructor

Properties

Private _samples

_samples: Array<[Real, Real]>

Private _sorted

_sorted: boolean

Methods

add

  • adds a datum to the set, possibly with a weight

    Parameters

    • value: Real
    • Default value weight: Real = 1

    Returns void

addSequence

  • addSequence(value: Real[], weight?: Real[]): void
  • adds a sequence of data to the set, with default weight

    Parameters

    • value: Real[]
    • Default value weight: Real[] = []

    Returns void

data

  • collected data

    Returns Array<[Real, Real]>

errorEstimate

  • errorEstimate(): Real
  • returns the error estimate on the mean value, defined as $ \epsilon = \sigma/\sqrt{N}. $

    Returns Real

expectationValue1

  • Expectation value of a function $ f $ over R

    Parameters

    Returns Real

expectationValue2

  • Expectation value of a function $ f $ on a given range $ \mathcal{R} $, i.e., $$ \mathrm{E}\left[f ;|; \mathcal{R}\right] = \frac{\sum_{x_i \in \mathcal{R}} f(x_i) w_i}{ \sum_{x_i \in \mathcal{R}} w_i}. $$ The range is passed as a boolean function returning true if the argument belongs to the range or false otherwise.

    The function returns a pair made of the result and the number of observations in the given range.

    Parameters

    Returns [Real, Size]

kurtosis

  • returns the excess kurtosis, defined as $$ \frac{N^2(N+1)}{(N-1)(N-2)(N-3)} \frac{\left\langle \left(x-\langle x \rangle \right)^4 \right\rangle}{\sigma^4} - \frac{3(N-1)^2}{(N-2)(N-3)}. $$ The above evaluates to 0 for a Gaussian distribution.

    Returns Real

max

  • returns the maximum sample value

    Returns Real

mean

  • returns the mean, defined as $$ \langle x \rangle = \frac{\sum w_i x_i}{\sum w_i}. $$

    Returns Real

min

  • returns the minimum sample value

    Returns Real

percentile

  • $ y $-th percentile, defined as the value $ \bar{x} $ such that $$ y = \frac{\sum_{x_i < \bar{x}} w_i}{ \sum_i w_i} $$

    $ y $ must be in the range $ (0-1]. $

    Parameters

    Returns Real

reserve

  • reserve(n: Size): void
  • informs the internal storage of a planned increase in size

    Parameters

    Returns void

reset

  • reset(): void
  • resets the data to a null set

    Returns void

samples1

  • number of samples collected

    Returns Size

samples2

  • Parameters

    Returns Size

skewness

  • returns the skewness, defined as $$ \frac{N^2}{(N-1)(N-2)} \frac{\left\langle \left( x-\langle x \rangle \right)^3 \right\rangle}{\sigma^3}. $$ The above evaluates to 0 for a Gaussian distribution.

    Returns Real

sort

  • sort(): void
  • sort the data set in increasing order

    Returns void

standardDeviation

  • standardDeviation(): Real
  • returns the standard deviation $ \sigma $, defined as the square root of the variance.

    Returns Real

topPercentile

  • $ y $-th top percentile, defined as the value $ \bar{x} $ such that $$ y = \frac{\sum_{x_i > \bar{x}} w_i}{ \sum_i w_i} $$

    $ y $ must be in the range $ (0-1]. $

    Parameters

    Returns Real

variance

  • returns the variance, defined as $$ \sigma^2 = \frac{N}{N-1} \left\langle \left( x-\langle x \rangle \right)^2 \right\rangle. $$

    Returns Real

weightSum1

  • weightSum1(): Real
  • sum of data weights

    Returns Real

weightSum2

  • Parameters

    Returns Real