Source release v3.5.0
This commit is contained in:
33
metrics/src/distribution.cpp
Normal file
33
metrics/src/distribution.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This file contains the definitions for the Distribution class members.
|
||||
|
||||
#include "distribution.h"
|
||||
|
||||
#include <float.h>
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
Distribution::Distribution() :
|
||||
count_(0LL),
|
||||
min_(DBL_MAX),
|
||||
max_(-DBL_MAX),
|
||||
mean_(0.0),
|
||||
sum_squared_deviation_(0.0) {
|
||||
}
|
||||
|
||||
void Distribution::Record(double value) {
|
||||
// Using method of provisional means.
|
||||
double deviation = value - mean_;
|
||||
mean_ = mean_ + (deviation / ++count_);
|
||||
sum_squared_deviation_ =
|
||||
sum_squared_deviation_ + (deviation * (value - mean_));
|
||||
|
||||
min_ = min_ < value ? min_ : value;
|
||||
max_ = max_ > value ? max_ : value;
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
Reference in New Issue
Block a user