Simox  2.3.74.0
simox::math::SoftMinMax Class Reference

The SoftMinMax class can be used to find soft min and max of a set of floats. More...

Public Member Functions

 SoftMinMax ()
 No initialization constructor. More...
 
 SoftMinMax (float percentile, std::size_t numValues)
 Constructs a SoftMinMax for given percentile and number of values. More...
 
void reset (float percentile, std::size_t numValues)
 
void add (float value)
 
float getSoftMin () const
 
float getSoftMax () const
 

Detailed Description

The SoftMinMax class can be used to find soft min and max of a set of floats.

Soft means that some values are allowed to be >= soft min / <= soft max (including the soft min/max), respectively. A percentile argument in [0..0.5] specifies the percentage of values which are allowed to excess the soft min/max.

Constructor & Destructor Documentation

◆ SoftMinMax() [1/2]

simox::math::SoftMinMax::SoftMinMax ( )

No initialization constructor.

◆ SoftMinMax() [2/2]

simox::math::SoftMinMax::SoftMinMax ( float  percentile,
std::size_t  numValues 
)

Constructs a SoftMinMax for given percentile and number of values.

Parameters
percentileThe percentage of values that may excess the soft min/max. Must be in [0..0.5].
numValuesthe total number of values that will be added. Must be > 0.
Exceptions
<tt>std::invalid_argument</tt>If one of the parameters value does not meet the requirements

Member Function Documentation

◆ add()

void simox::math::SoftMinMax::add ( float  value)

Add a value to the considered collection.

Note
Only values excessing the current soft min/max are stored.

◆ getSoftMax()

float simox::math::SoftMinMax::getSoftMax ( ) const

Get the current soft max.

Exceptions
<tt>std::out_of_range</tt>If no element was added.

◆ getSoftMin()

float simox::math::SoftMinMax::getSoftMin ( ) const

Get the current soft min.

Exceptions
<tt>std::out_of_range</tt>If no element was added.

◆ reset()

void simox::math::SoftMinMax::reset ( float  percentile,
std::size_t  numValues 
)

Reinitializes the SoftMinMax with the given arguments.

See also
SoftMinMax()
Exceptions
<tt>std::invalid_argument</tt>If one of the parameters value does not meet the requirements.