/usr/include/osl/stat/variance.h is in libosl-dev 0.6.0-3.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | /* variance.h
*/
#ifndef _VARIANCE_H
#define _VARIANCE_H
#include "osl/stat/average.h"
namespace osl
{
namespace stat
{
/**
* incrementaly maintain average and variance of data sequence
*/
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::getAverage;
using base_t::average;
using base_t::numElements;
};
} // namespace stat
} // namespace osl
#endif /* _VARIANCE_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|