Computes mean of a statistical variable. More...
#include <SgStatistics.h>
Public Member Functions | |
| SgStatisticsBase () | |
| SgStatisticsBase (VALUE val, COUNT count) | |
| Create statistics initialized with values. | |
| void | Add (VALUE val) |
| void | Remove (VALUE val) |
| void | Add (VALUE val, COUNT n) |
| Add a value n times. | |
| void | Remove (VALUE val, COUNT n) |
| Remove a value n times. | |
| void | Clear () |
| COUNT | Count () const |
| void | Initialize (VALUE val, COUNT count) |
| Initialize with values. | |
| bool | IsDefined () const |
| Check if the mean value is defined. | |
| VALUE | Mean () const |
| void | Write (std::ostream &out) const |
| Write in human readable format. | |
| void | SaveAsText (std::ostream &out) const |
| Save in a compact platform-independent text format. | |
| void | LoadFromText (std::istream &in) |
| Load from text format. | |
Private Attributes | |
| COUNT | m_count |
| VALUE | m_mean |
Computes mean of a statistical variable.
The template parameters are the floating point type and the counter type, depending on the precision-memory tradeoff.
Definition at line 34 of file SgStatistics.h.
| SgStatisticsBase< VALUE, COUNT >::SgStatisticsBase | ( | ) |
Definition at line 91 of file SgStatistics.h.
References SgStatisticsBase< VALUE, COUNT >::Clear().
| SgStatisticsBase< VALUE, COUNT >::SgStatisticsBase | ( | VALUE | val, | |
| COUNT | count | |||
| ) |
Create statistics initialized with values.
Note that value must be initialized to 0 if count is 0. Equivalent to creating a statistics and calling count times Add(val)
Definition at line 97 of file SgStatistics.h.
| void SgStatisticsBase< VALUE, COUNT >::Add | ( | VALUE | val | ) |
Definition at line 104 of file SgStatistics.h.
References SgStatisticsBase< VALUE, COUNT >::m_count, SgStatisticsBase< VALUE, COUNT >::m_mean, and SG_ASSERT.
Referenced by SgUctSearch::GetValueEstimate(), SgUctSearch::GetValueEstimateRave(), and SgUctSearch::UpdateStatistics().
| void SgStatisticsBase< VALUE, COUNT >::Add | ( | VALUE | val, | |
| COUNT | n | |||
| ) |
Add a value n times.
Definition at line 154 of file SgStatistics.h.
References SgStatisticsBase< VALUE, COUNT >::m_count, SgStatisticsBase< VALUE, COUNT >::m_mean, and SG_ASSERT.
| void SgStatisticsBase< VALUE, COUNT >::Clear | ( | ) |
Definition at line 169 of file SgStatistics.h.
References SgStatisticsBase< VALUE, COUNT >::m_count, and SgStatisticsBase< VALUE, COUNT >::m_mean.
Referenced by SgUctSearchStat::Clear(), SgStatisticsBase< VALUE, COUNT >::Remove(), and SgStatisticsBase< VALUE, COUNT >::SgStatisticsBase().
| COUNT SgStatisticsBase< VALUE, COUNT >::Count | ( | ) | const |
Definition at line 176 of file SgStatistics.h.
References SgStatisticsBase< VALUE, COUNT >::m_count.
Referenced by SgUctSearch::GetValueEstimate(), and SgUctSearch::GetValueEstimateRave().
| void SgStatisticsBase< VALUE, COUNT >::Initialize | ( | VALUE | val, | |
| COUNT | count | |||
| ) |
Initialize with values.
Equivalent to calling Clear() and calling count times Add(val)
Definition at line 182 of file SgStatistics.h.
References SgStatisticsBase< VALUE, COUNT >::m_count, SgStatisticsBase< VALUE, COUNT >::m_mean, and SG_ASSERT.
Referenced by SgUctSearch::GetValueEstimate(), and SgUctSearch::GetValueEstimateRave().
| bool SgStatisticsBase< VALUE, COUNT >::IsDefined | ( | ) | const |
Check if the mean value is defined.
The mean value is defined, if the count if greater than zero. The result of this function is equivalent to Count() > 0, for integer count types and Count() > epsilon() for floating point count types.
Definition at line 190 of file SgStatistics.h.
References SgStatisticsBase< VALUE, COUNT >::m_count.
Referenced by SgUctSearch::GetValueEstimate(), SgUctSearch::GetValueEstimateRave(), SgStatisticsBase< VALUE, COUNT >::Mean(), and SgStatisticsBase< VALUE, COUNT >::Write().
| void SgStatisticsBase< VALUE, COUNT >::LoadFromText | ( | std::istream & | in | ) |
Load from text format.
See SaveAsText()
Definition at line 199 of file SgStatistics.h.
References SgStatisticsBase< VALUE, COUNT >::m_count, and SgStatisticsBase< VALUE, COUNT >::m_mean.
| VALUE SgStatisticsBase< VALUE, COUNT >::Mean | ( | ) | const |
Definition at line 205 of file SgStatistics.h.
References SgStatisticsBase< VALUE, COUNT >::IsDefined(), SgStatisticsBase< VALUE, COUNT >::m_mean, and SG_ASSERT.
Referenced by SgUctSearch::GetValueEstimate(), SgUctSearch::GetValueEstimateRave(), SgUctSearchStat::Write(), and SgStatisticsBase< VALUE, COUNT >::Write().
| void SgStatisticsBase< VALUE, COUNT >::Remove | ( | VALUE | val | ) |
Definition at line 119 of file SgStatistics.h.
References SgStatisticsBase< VALUE, COUNT >::Clear(), SgStatisticsBase< VALUE, COUNT >::m_count, and SgStatisticsBase< VALUE, COUNT >::m_mean.
| void SgStatisticsBase< VALUE, COUNT >::Remove | ( | VALUE | val, | |
| COUNT | n | |||
| ) |
Remove a value n times.
Definition at line 136 of file SgStatistics.h.
References SgStatisticsBase< VALUE, COUNT >::Clear(), SgStatisticsBase< VALUE, COUNT >::m_count, SgStatisticsBase< VALUE, COUNT >::m_mean, and SG_ASSERT.
| void SgStatisticsBase< VALUE, COUNT >::SaveAsText | ( | std::ostream & | out | ) | const |
Save in a compact platform-independent text format.
The data is written in a single line, without trailing newline.
Definition at line 221 of file SgStatistics.h.
References SgStatisticsBase< VALUE, COUNT >::m_count, and SgStatisticsBase< VALUE, COUNT >::m_mean.
| void SgStatisticsBase< VALUE, COUNT >::Write | ( | std::ostream & | out | ) | const |
Write in human readable format.
Definition at line 212 of file SgStatistics.h.
References SgStatisticsBase< VALUE, COUNT >::IsDefined(), and SgStatisticsBase< VALUE, COUNT >::Mean().
COUNT SgStatisticsBase< VALUE, COUNT >::m_count [private] |
Definition at line 85 of file SgStatistics.h.
Referenced by SgStatisticsBase< VALUE, COUNT >::Add(), SgStatisticsBase< VALUE, COUNT >::Clear(), SgStatisticsBase< VALUE, COUNT >::Count(), SgStatisticsBase< VALUE, COUNT >::Initialize(), SgStatisticsBase< VALUE, COUNT >::IsDefined(), SgStatisticsBase< VALUE, COUNT >::LoadFromText(), SgStatisticsBase< VALUE, COUNT >::Remove(), and SgStatisticsBase< VALUE, COUNT >::SaveAsText().
VALUE SgStatisticsBase< VALUE, COUNT >::m_mean [private] |
Definition at line 87 of file SgStatistics.h.
Referenced by SgStatisticsBase< VALUE, COUNT >::Add(), SgStatisticsBase< VALUE, COUNT >::Clear(), SgStatisticsBase< VALUE, COUNT >::Initialize(), SgStatisticsBase< VALUE, COUNT >::LoadFromText(), SgStatisticsBase< VALUE, COUNT >::Mean(), SgStatisticsBase< VALUE, COUNT >::Remove(), and SgStatisticsBase< VALUE, COUNT >::SaveAsText().