A C++ template library for embedded applications
MIT licensed
Designed and
maintained by
John Wellbelove
Support the development
of the ETL

Standard Deviation

20.9.0

template <bool Standard_Deviation_Type, typename TInput, typename TCalc = TInput>
class standard_deviation  : public etl::unary_function<TInput, void>

Standard_Deviation_Type Population or Sample.
TInput                  The input data type.
TCalc                   The type to use for internal calculations. By default, equal to TInput.
____________________________________________________________________________________________________
standard_deviation_type
etl::standard_deviation_type::Sample    
etl::standard_deviation_type::Population
____________________________________________________________________________________________________
standard_deviation
standard_deviation()
Default constructor.

template <typename TIterator>
standard_deviation(TIterator first, TIterator last)
Construct from an iterator range.
____________________________________________________________________________________________________
void add(TInput value1)
Add a value.

template <typename TIterator>
void add(TIterator first, TIterator last)
Add a range of values.
____________________________________________________________________________________________________
void operator()(TInput value)
Add a values.

template <typename TIterator>
void operator()(TIterator first, TIterator last)
Add a range of values.
____________________________________________________________________________________________________
double get_standard_deviation() const
Returns the calculated standard deviation for the data.
____________________________________________________________________________________________________
double get_variance() const
Returns the calculated variance for the data.
____________________________________________________________________________________________________
operator double() const
Returns the calculated standard deviation for the data.
____________________________________________________________________________________________________
size_t count() const
Get the total number added entries.
____________________________________________________________________________________________________
void clear()
Clear the standard deviation.
____________________________________________________________________________________________________
Example

std::array<char, 10> input
{
  0, 1, 2, 3, 4, 5, 6, 7, 8, 9
};

etl::standard_deviation<etl::standard_deviation_type::Population, char, int32_t>
    standard_deviation(input.begin(), input.end());

double standard_deviation_result;
double variance_result;

standard_deviation_result = standard_deviation; // standard_deviation_result  == 2.87
variance_result = standard_deviation.get_variance(); // variance_result  == 8.25
standard_deviation.h