ALMaSS Rabbit ODdox  1.00
The rabbit model description following ODdox protocol
Public Member Functions | Protected Attributes | List of all members
SimpleStatistics Class Reference

#include <populationmanager.h>

Public Member Functions

 SimpleStatistics ()
 SimpleStatistics constructor. More...
 
void add_variable (double x)
 Add a value. More...
 
void remove_variable (double x)
 Remove a value. More...
 
double get_N ()
 Returns the number of values. More...
 
double get_Total ()
 Returns the mean. More...
 
double get_meanvalue ()
 Returns the mean. More...
 
double get_varianceP ()
 Returns the population variance. More...
 
double get_varianceS ()
 Returns the sample variance. More...
 
void ClearData ()
 Clears the data. More...
 

Protected Attributes

double m_K
 
double m_n
 
double m_Sum
 
double m_SumX
 
double m_SumX2
 

Detailed Description

Definition at line 319 of file populationmanager.h.

Constructor & Destructor Documentation

SimpleStatistics::SimpleStatistics ( )
inline

SimpleStatistics constructor.

Definition at line 333 of file populationmanager.h.

334  {
335  ClearData();
336  }
void ClearData()
Clears the data.

Member Function Documentation

void SimpleStatistics::add_variable ( double  x)
inline

Add a value.

Definition at line 338 of file populationmanager.h.

338  {
339  // This uses the computed shifted data equation.
340  if (m_n == 0) m_K = x;
341  m_n++;
342  m_Sum += x;
343  m_SumX += x - m_K;
344  m_SumX2 += (x - m_K) * (x - m_K);
345  }
void SimpleStatistics::ClearData ( )
inline

Clears the data.

Definition at line 382 of file populationmanager.h.

383  {
384  m_K = 0;
385  m_n = 0;
386  m_Sum = 0;
387  m_SumX = 0;
388  m_SumX2 = 0;
389  }
double SimpleStatistics::get_meanvalue ( )
inline

Returns the mean.

Definition at line 362 of file populationmanager.h.

362  {
363  return m_K + m_SumX / m_n;
364  }
double SimpleStatistics::get_N ( )
inline

Returns the number of values.

Definition at line 354 of file populationmanager.h.

354  {
355  return m_n;
356  }
double SimpleStatistics::get_Total ( )
inline

Returns the mean.

Definition at line 358 of file populationmanager.h.

358  {
359  return m_Sum;
360  }
double SimpleStatistics::get_varianceP ( )
inline

Returns the population variance.

Definition at line 366 of file populationmanager.h.

366  {
367  if (m_n < 2)
368  {
369  return -1; // Ilegal n value, but don't want to exit
370  }
371  return (m_SumX2 - (m_SumX*m_SumX) / m_n) / (m_n);
372  }
double SimpleStatistics::get_varianceS ( )
inline

Returns the sample variance.

Definition at line 374 of file populationmanager.h.

374  {
375  if (m_n < 2)
376  {
377  return -1; // Ilegal n value, but don't want to exit
378  }
379  return (m_SumX2 - (m_SumX*m_SumX) / m_n) / (m_n - 1);
380  }
void SimpleStatistics::remove_variable ( double  x)
inline

Remove a value.

Definition at line 347 of file populationmanager.h.

347  {
348  m_n--;
349  m_Sum -= x;
350  m_SumX -= (x - m_K);
351  m_SumX2 -= (x - m_K) * (x - m_K);
352  }

Member Data Documentation

double SimpleStatistics::m_K
protected

This class is designed to provide the facility to create simple stats from data that comes in incrementally. It can provide the mean, variance of the data set at any point in time

Definition at line 326 of file populationmanager.h.

double SimpleStatistics::m_n
protected

Definition at line 327 of file populationmanager.h.

double SimpleStatistics::m_Sum
protected

Definition at line 328 of file populationmanager.h.

double SimpleStatistics::m_SumX
protected

Definition at line 329 of file populationmanager.h.

double SimpleStatistics::m_SumX2
protected

Definition at line 330 of file populationmanager.h.


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