SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
stats.h File Reference

Math/Statistics functions. More...

#include <algorithm>
#include <map>
#include <vector>

Go to the source code of this file.

Functions

template<class InputIt, class T = typename std::iterator_traits<InputIt>::value_type>
satdump::most_common (InputIt begin, InputIt end, T def)
 Return the most common element within the provided sequence.
template<class InputIt, class T = typename std::iterator_traits<InputIt>::value_type>
satdump::average_common (InputIt begin, InputIt end)
 Returns the average of the provided elements.
template<typename T>
satdump::percentile (T *array, int size, float percentile)
 Returns a percentile of the provided array.
template<typename T>
double satdump::avg_overflowless (std::vector< T > const &v)
 Returns the average of the provided elements. Version that won't overflow with very large numbers and amount of elements.
double satdump::get_median (std::vector< double > values)
 Returns the median of the provided elements.

Detailed Description

Math/Statistics functions.

Function Documentation

◆ average_common()

template<class InputIt, class T = typename std::iterator_traits<InputIt>::value_type>
T satdump::average_common ( InputIt begin,
InputIt end )

Returns the average of the provided elements.

Parameters
beginFirst iterator
endlast iterator
Returns
average of elements

◆ avg_overflowless()

template<typename T>
double satdump::avg_overflowless ( std::vector< T > const & v)

Returns the average of the provided elements. Version that won't overflow with very large numbers and amount of elements.

Parameters
vVector to average
Returns
average of elements

◆ get_median()

double satdump::get_median ( std::vector< double > values)

Returns the median of the provided elements.

Parameters
valuesinput vector
Returns
median of the elements

◆ most_common()

template<class InputIt, class T = typename std::iterator_traits<InputIt>::value_type>
T satdump::most_common ( InputIt begin,
InputIt end,
T def )

Return the most common element within the provided sequence.

Parameters
beginFirst iterator
endlast iterator
defdefault if we don't have enough elements
Returns
most common element OR default

◆ percentile()

template<typename T>
T satdump::percentile ( T * array,
int size,
float percentile )

Returns a percentile of the provided array.

Parameters
arrayto work with
sizeof the array, in elements
percentileto return
Returns
the percentile