Skip to content

Commit

Permalink
refactor(DataTomeAnalysis): ⚡ improve calculation of method var
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreHiroyuki committed Jun 11, 2024
1 parent 4bc110c commit 653e854
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/DataTomeAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ class DataTomeAnalysis : public DataTomeMvAvg<TypeOfArray, TypeOfSum> {

TypeOfArray var = 0;
for (size_t i = 0; i < this->point_count(); i++) {
var += ((*this)[i] - average) * ((*this)[i] - average);
TypeOfArray data_point = (*this)[i] - average;
var += (data_point - average) * (data_point - average);
}

return var;
Expand Down Expand Up @@ -264,7 +265,8 @@ class DataTomeAnalysis : public DataTomeMvAvg<TypeOfArray, TypeOfSum> {

TypeOfArray var = 0;
for (size_t i = 0; i < this->partial_point_count(partial_id); i++) {
var += ((*this)[i] - average) * ((*this)[i] - average);
TypeOfArray data_point = (*this)[i] - average;
var += (data_point - average) * (data_point - average);
}

return var;
Expand Down

0 comments on commit 653e854

Please sign in to comment.