mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
63 lines
2.2 KiB
Plaintext
63 lines
2.2 KiB
Plaintext
Variance
|
|
20.9.0
|
|
|
|
template <bool Variance_Type, typename TInput, typename TCalc = TInput>
|
|
class variance : public etl::unary_function<TInput, void>
|
|
|
|
Variance_Type Population or Sample.
|
|
TInput The input data type.
|
|
TCalc The type to use for internal calculations. By default, equal to TInput.
|
|
____________________________________________________________________________________________________
|
|
variance_type
|
|
etl::variance_type::Sample
|
|
etl::variance_type::Population
|
|
____________________________________________________________________________________________________
|
|
variance
|
|
variance()
|
|
Default constructor.
|
|
|
|
template <typename TIterator>
|
|
variance(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_variance() const
|
|
Returns the calculated variance for the data.
|
|
____________________________________________________________________________________________________
|
|
operator double() const
|
|
Returns the calculated variance for the data.
|
|
____________________________________________________________________________________________________
|
|
size_t count() const
|
|
Get the total number added entries.
|
|
____________________________________________________________________________________________________
|
|
void clear()
|
|
Clear the variance.
|
|
____________________________________________________________________________________________________
|
|
Example
|
|
|
|
std::array<char, 10> input
|
|
{
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
|
};
|
|
|
|
etl::variance<etl::variance_type::Population, char, int32_t> variance(input.begin(),
|
|
input.end());
|
|
|
|
double variance_result;
|
|
|
|
variance_result = variance; // variance_result == 8.25
|
|
|