Commit bea7ae7c authored by Alessio Netti's avatar Alessio Netti
Browse files

Analytics: improving normalization in CS plugin

parent 97e618bd
......@@ -429,13 +429,13 @@ void CSOperator::computeSignature(U_Ptr unit, uint64_t nowTs) {
// Normalizes sensor data
void CSOperator::normalize(std::vector<reading_t> &v, size_t idx) {
int64_t denom = _max[idx]!=_min[idx] ? (_max[idx] - _min[idx]) : 1;
double denom = _max[idx]!=_min[idx] ? (double)_scalingFactor / (double)(_max[idx] - _min[idx]) : (double)_scalingFactor;
for(size_t idx2=0; idx2<v.size(); idx2++) {
if(v[idx2].value > _max[idx])
v[idx2].value = _max[idx];
else if(v[idx2].value < _min[idx])
v[idx2].value = _min[idx];
v[idx2].value = (v[idx2].value - _min[idx]) * _scalingFactor / denom;
v[idx2].value = (int64_t)((double)(v[idx2].value - _min[idx]) * denom);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment