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

Analytics: improvements to normalization in signatures plugin

parent 8f1108f1
......@@ -421,8 +421,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;
for(size_t idx2=0; idx2<v.size(); idx2++)
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;
}
}
// Computes average sensor values
......
Supports Markdown
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