Momentum Scripting v1
Loading...
Searching...
No Matches
v1::MedianStatistic Class Reference

#include <Statistic.h>

Public Member Functions

 MedianStatistic (size_t maxHistorySize)
 
void clear ()
 
virtual double get () const override
 
size_t getCurrentHistorySize () const
 
size_t getMaxHistorySize () const
 
virtual double update (double observation) override
 

Detailed Description

Median statistic that keeps a history of a number of observations and reports the median, i.e., middle element in sorted order, of that.

Constructor & Destructor Documentation

◆ MedianStatistic()

v1::MedianStatistic::MedianStatistic ( size_t  maxHistorySize)
Parameters
maxHistorySize- The number of observations to keep in the history.

Member Function Documentation

◆ clear()

void v1::MedianStatistic::clear ( )

Reset all history.

◆ get()

virtual double v1::MedianStatistic::get ( ) const
overridevirtual
Returns
The median of the history.
Todo:
What should be removed here?

Implements v1::Statistic.

◆ getCurrentHistorySize()

size_t v1::MedianStatistic::getCurrentHistorySize ( ) const

◆ getMaxHistorySize()

size_t v1::MedianStatistic::getMaxHistorySize ( ) const

◆ update()

virtual double v1::MedianStatistic::update ( double  observation)
overridevirtual

Add a new observation to the history, removing the oldest if the maximum history size has been reached.

Parameters
observation- the observation to add

Implements v1::Statistic.