ALMaSS Rodenticide ODdox  1.1
The rodenticide model description following ODdox protocol
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...
 
double get_SD ()
 Returns the sample standard deviation. More...
 
double get_SE ()
 Returns the sample standard error. More...
 
void ClearData ()
 Clears the data. More...
 

Protected Attributes

double m_K
 
double m_n
 
double m_Sum
 
double m_SumX
 
double m_SumX2
 

Constructor & Destructor Documentation

◆ SimpleStatistics()

SimpleStatistics::SimpleStatistics ( )
inline

SimpleStatistics constructor.

338  {
339  ClearData();
340  }

References ClearData().

Member Function Documentation

◆ add_variable()

void SimpleStatistics::add_variable ( double  x)
inline

Add a value.

342  {
343  // This uses the computed shifted data equation.
344  if (m_n == 0) m_K = x;
345  m_n++;
346  m_Sum += x;
347  m_SumX += x - m_K;
348  m_SumX2 += (x - m_K) * (x - m_K);
349  }

References m_K, m_n, m_Sum, m_SumX, and m_SumX2.

◆ ClearData()

void SimpleStatistics::ClearData ( )
inline

Clears the data.

404  {
405  m_K = 0;
406  m_n = 0;
407  m_Sum = 0;
408  m_SumX = 0;
409  m_SumX2 = 0;
410  }

References m_K, m_n, m_Sum, m_SumX, and m_SumX2.

Referenced by SimpleStatistics().

◆ get_meanvalue()

double SimpleStatistics::get_meanvalue ( )
inline

Returns the mean.

366  {
367  if (m_n == 0) return -1;
368  return m_K + m_SumX / m_n;
369  }

References m_K, m_n, and m_SumX.

◆ get_N()

double SimpleStatistics::get_N ( )
inline

Returns the number of values.

358  {
359  return m_n;
360  }

References m_n.

Referenced by get_SE().

◆ get_SD()

double SimpleStatistics::get_SD ( )
inline

Returns the sample standard deviation.

387  {
388  if (m_n < 2)
389  {
390  return -1; // Ilegal n value, but don't want to exit
391  }
392  return (sqrt(get_varianceS()));
393  }

References get_varianceS(), and m_n.

◆ get_SE()

double SimpleStatistics::get_SE ( )
inline

Returns the sample standard error.

395  {
396  if (m_n < 2)
397  {
398  return -1; // Ilegal n value, but don't want to exit
399  }
400  return (sqrt(get_varianceS()/get_N()));
401  }

References get_N(), get_varianceS(), and m_n.

◆ get_Total()

double SimpleStatistics::get_Total ( )
inline

Returns the mean.

362  {
363  return m_Sum;
364  }

References m_Sum.

◆ get_varianceP()

double SimpleStatistics::get_varianceP ( )
inline

Returns the population variance.

371  {
372  if (m_n < 2)
373  {
374  return -1; // Ilegal n value, but don't want to exit
375  }
376  return (m_SumX2 - (m_SumX*m_SumX) / m_n) / (m_n);
377  }

References m_n, m_SumX, and m_SumX2.

◆ get_varianceS()

double SimpleStatistics::get_varianceS ( )
inline

Returns the sample variance.

379  {
380  if (m_n < 2)
381  {
382  return -1; // Ilegal n value, but don't want to exit
383  }
384  return (m_SumX2 - (m_SumX*m_SumX) / m_n) / (m_n - 1);
385  }

References m_n, m_SumX, and m_SumX2.

Referenced by get_SD(), and get_SE().

◆ remove_variable()

void SimpleStatistics::remove_variable ( double  x)
inline

Remove a value.

351  {
352  m_n--;
353  m_Sum -= x;
354  m_SumX -= (x - m_K);
355  m_SumX2 -= (x - m_K) * (x - m_K);
356  }

References m_K, m_n, m_Sum, m_SumX, and m_SumX2.

Member Data Documentation

◆ m_K

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

Referenced by add_variable(), ClearData(), get_meanvalue(), and remove_variable().

◆ m_n

double SimpleStatistics::m_n
protected

◆ m_Sum

double SimpleStatistics::m_Sum
protected

◆ m_SumX

double SimpleStatistics::m_SumX
protected

◆ m_SumX2

double SimpleStatistics::m_SumX2
protected

The documentation for this class was generated from the following file:
SimpleStatistics::get_N
double get_N()
Returns the number of values.
Definition: PopulationManager.h:358
SimpleStatistics::m_Sum
double m_Sum
Definition: PopulationManager.h:332
SimpleStatistics::m_K
double m_K
Definition: PopulationManager.h:330
SimpleStatistics::m_SumX2
double m_SumX2
Definition: PopulationManager.h:334
SimpleStatistics::get_varianceS
double get_varianceS()
Returns the sample variance.
Definition: PopulationManager.h:379
SimpleStatistics::m_n
double m_n
Definition: PopulationManager.h:331
SimpleStatistics::m_SumX
double m_SumX
Definition: PopulationManager.h:333
SimpleStatistics::ClearData
void ClearData()
Clears the data.
Definition: PopulationManager.h:403