variance.h
Go to the documentation of this file.
/* variance.h
*/
#ifndef _VARIANCE_H
#define _VARIANCE_H
#include "osl/stat/average.h"
namespace osl
{
namespace stat
{
class Variance : private Average
{
double m_variance;
typedef Average base_t;
public:
// CREATORS
Variance() : m_variance(0)
{
}
// MANIPULATORS
void add(const double& x)
{
const double diff = base_t::add(x);
const double adjuster
= static_cast<double>(numElements()-1)/numElements();
m_variance += diff*diff*adjuster;
}
// ACCESSORS
double variance() const { return m_variance/numElements(); }
using base_t::average;
using base_t::numElements;
};
} // namespace stat
using stat::Average;
} // namespace osl
#endif /* _VARIANCE_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
average.h
osl::stat::Average::add
double add(const double &x)
Add an element x.
Definition average.h:27
osl::stat::Average::Average
Average()
Definition average.h:19
osl::stat::Average::average
double average() const
Definition average.h:48
osl::stat::Average::numElements
int numElements() const
Definition average.h:49
osl::stat::Variance::base_t
Average base_t
Definition variance.h:17
osl::stat::Variance::add
void add(const double &x)
Definition variance.h:24
osl::stat::Variance::Variance
Variance()
Definition variance.h:20
osl::stat::Variance::variance
double variance() const
Definition variance.h:33
osl::stat::Variance::m_variance
double m_variance
Definition variance.h:16
osl::stat::Variance::numElements
int numElements() const
Definition average.h:49
osl::stat
Definition rating/featureSet.h:18
osl
Definition additionalEffect.h:6