/usr/include/osl/stat/average.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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | /* average.h
*/
#ifndef _AVERAGE_H
#define _AVERAGE_H
namespace osl
{
namespace stat
{
/**
* incrementaly maintain average of data sequence
*/
class Average
{
double mean;
int elements;
public:
// CREATORS
Average() : mean(0), elements(0)
{
}
// MANIPULATORS
/**
* Add an element x
* @return difference between x and (old) mean
*/
double add(const double& x)
{
++elements;
const double diff = x - mean;
mean += diff/elements;
return diff;
}
void merge(const Average& r)
{
if (r.elements == 0)
return;
const double sum = mean*elements + r.mean*r.elements;
elements += r.elements;
mean = sum / elements;
}
void clear(double a=0.0, int e=0)
{
mean = a;
elements = e;
}
// ACCESSORS
double getAverage() const { return mean; }
double average() const { return mean; }
int numElements() const { return elements; }
};
} // namespace stat
} // namespace osl
#endif /* _AVERAGE_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|