Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Public Member Functions | Private Attributes

SgStatisticsBase< VALUE, COUNT > Class Template Reference

Computes mean of a statistical variable. More...

#include <SgStatistics.h>

List of all members.

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

Detailed Description

template<typename VALUE, typename COUNT>
class SgStatisticsBase< VALUE, COUNT >

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.


Constructor & Destructor Documentation

template<typename VALUE , typename COUNT >
SgStatisticsBase< VALUE, COUNT >::SgStatisticsBase (  ) 

Definition at line 91 of file SgStatistics.h.

References SgStatisticsBase< VALUE, COUNT >::Clear().

template<typename VALUE, typename COUNT>
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.


Member Function Documentation

template<typename VALUE, typename COUNT >
void SgStatisticsBase< VALUE, COUNT >::Add ( VALUE  val  ) 
template<typename VALUE, typename COUNT>
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.

template<typename VALUE , typename COUNT >
void SgStatisticsBase< VALUE, COUNT >::Clear (  ) 
template<typename VALUE , typename COUNT >
COUNT SgStatisticsBase< VALUE, COUNT >::Count (  )  const
template<typename VALUE, typename COUNT>
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().

template<typename VALUE , typename COUNT >
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().

template<typename VALUE , typename COUNT >
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.

template<typename VALUE , typename COUNT >
VALUE SgStatisticsBase< VALUE, COUNT >::Mean (  )  const
template<typename VALUE, typename COUNT >
void SgStatisticsBase< VALUE, COUNT >::Remove ( VALUE  val  ) 
template<typename VALUE, typename COUNT>
void SgStatisticsBase< VALUE, COUNT >::Remove ( VALUE  val,
COUNT  n 
)
template<typename VALUE , typename COUNT >
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.

template<typename VALUE , typename COUNT >
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().


Member Data Documentation

template<typename VALUE, typename COUNT>
COUNT SgStatisticsBase< VALUE, COUNT >::m_count [private]
template<typename VALUE, typename COUNT>
VALUE SgStatisticsBase< VALUE, COUNT >::m_mean [private]

The documentation for this class was generated from the following file:


Sun Mar 13 2011 Doxygen 1.7.1