    

 ## On this page

  

 

 # IRockyStatisticsAdder Struct Reference

 Last update: 16.07.2025 

`#include <<a class="el" href="rocky__statistics__data_8hpp_source.xhtml">rocky_statistics_data.hpp</a>>`

Inherits rocky20::AAdder.

## <a id="pub-methods" name="pub-methods"></a>Public Member Functions

ROCKY\_FUNCTIONS void [add\_value](#a2d87767ca1065f1a48778cf3d1e0f8ce) (double new\_value) double [get\_mean](#a57d3816e4f01de3fdd781ef229c9f771) () const double [get\_std\_deviation](#ac1c33e3ab2e1afd1590aef6e2c40eb64) () const double [get\_skewness](#a4968d2f7ab3265b9aefafe064ae16ba0) () const double [get\_kurtosis](#a6f398ed07d36a7deccea3621e9780109) () const void [reset](#ae4b238da655579b44c6293a573cd9449) () void [join](#a56563b07a2763d52804e5180f3ae0b07) (const [IRockyStatisticsAdder](structIRockyStatisticsAdder.xhtml) &amp;other) <a id="details" name="details"></a>## Detailed Description

`<a class="el" href="structIRockyStatisticsAdder.xhtml">IRockyStatisticsAdder</a>` is an auxiliary struct used to calculate the mean, standard deviation, skewness and kurtosis of a set of values. Rocky uses it in the collision statistics modules for calculating statistics of sets of collision values associated to specific entities. However, it could be used to calculate the statistics of any set of values generated during a simulation. The mean and the statistical moments up to fourth order are calculated using a one-pass algorithm, therefore, their values are updated internally every time a new value is added to the set with the `add_value` method.

For the mathematical definitions of the statistics calculated by this struct, please refer to the DEM Technical Manual.



## Member Function Documentation

<a id="a2d87767ca1065f1a48778cf3d1e0f8ce" name="a2d87767ca1065f1a48778cf3d1e0f8ce"></a>## [◆ ](#a2d87767ca1065f1a48778cf3d1e0f8ce)add\_value()

 ROCKY\_FUNCTIONS void IRockyStatisticsAdder::add\_value  ( double *new\_value*) 

This method must be used to supply each one of the values of the set forwhich `<a class="el" href="structIRockyStatisticsAdder.xhtml">IRockyStatisticsAdder</a>` must calculate statistics.Parameters new\_valueA new value that belong to the set. n\_valuesThe number of values of the set, including the one added by this method. A companion `IRockyStatisticsCounter` object can be used to keep track of that number. 



<a id="a6f398ed07d36a7deccea3621e9780109" name="a6f398ed07d36a7deccea3621e9780109"></a>## [◆ ](#a6f398ed07d36a7deccea3621e9780109)get\_kurtosis()

 double IRockyStatisticsAdder::get\_kurtosis  ( )  const

ReturnsThe kurtosis of the set of values successively supplied with the `add_value` method up to the point where this method is called. The kurtosis is defined in the DEM Technical Manual. 



<a id="a57d3816e4f01de3fdd781ef229c9f771" name="a57d3816e4f01de3fdd781ef229c9f771"></a>## [◆ ](#a57d3816e4f01de3fdd781ef229c9f771)get\_mean()

 double IRockyStatisticsAdder::get\_mean  ( )  const

ReturnsThe mean value of the set of values successively supplied with the `add_value` method up to the point where this method is called. 



<a id="a4968d2f7ab3265b9aefafe064ae16ba0" name="a4968d2f7ab3265b9aefafe064ae16ba0"></a>## [◆ ](#a4968d2f7ab3265b9aefafe064ae16ba0)get\_skewness()

 double IRockyStatisticsAdder::get\_skewness  ( )  const

ReturnsThe skewness of the set of values successively supplied with the `add_value` method up to the point where this method is called. The skewness is defined in the DEM Technical Manual. 



<a id="ac1c33e3ab2e1afd1590aef6e2c40eb64" name="ac1c33e3ab2e1afd1590aef6e2c40eb64"></a>## [◆ ](#ac1c33e3ab2e1afd1590aef6e2c40eb64)get\_std\_deviation()

 double IRockyStatisticsAdder::get\_std\_deviation  ( )  const

ReturnsThe standard deviation of the set of values successively supplied with the `add_value` method up to the point where this method is called. 



<a id="a56563b07a2763d52804e5180f3ae0b07" name="a56563b07a2763d52804e5180f3ae0b07"></a>## [◆ ](#a56563b07a2763d52804e5180f3ae0b07)join()

 void IRockyStatisticsAdder::join  ( const [IRockyStatisticsAdder](structIRockyStatisticsAdder.xhtml) &amp; *other*) 

This method calculates the mean and the statistical moments for a set of valuesformed by the union of two sets of values whose statistics were calculated by two separate instances of `<a class="el" href="structIRockyStatisticsAdder.xhtml">IRockyStatisticsAdder</a>`. After executing this method, the statistics for the compound set will be available through the methods `get_mean`, `get_std_deviation`, etc.Parameters otherThe instance of `<a class="el" href="structIRockyStatisticsAdder.xhtml">IRockyStatisticsAdder</a>` that calculated the statistics of the second set of values. 



<a id="ae4b238da655579b44c6293a573cd9449" name="ae4b238da655579b44c6293a573cd9449"></a>## [◆ ](#ae4b238da655579b44c6293a573cd9449)reset()

 void IRockyStatisticsAdder::reset  ( ) 

This method resets all internal variables in order to start the calculationof statistics for a new set of values.