Skip to content

Commit

Permalink
optimize standard deviation method
Browse files Browse the repository at this point in the history
  • Loading branch information
root676 authored and nyalldawson committed Jul 2, 2020
1 parent 371f7b2 commit 7383238
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/analysis/processing/qgsrasteranalysisutils.cpp
Expand Up @@ -343,13 +343,8 @@ double QgsRasterAnalysisUtils::medianFromCellValues( std::vector<double> cellVal

double QgsRasterAnalysisUtils::stddevFromCellValues( std::vector<double> cellValues, int stackSize )
{
double mean = meanFromCellValues( cellValues, stackSize );
double accum = 0.0;
for ( int i = 0; i < stackSize; i++ )
{
accum += std::pow( ( cellValues.at( i ) - mean ), 2.0 );
}
double stddev = std::sqrt( accum / static_cast<double>( stackSize ) );
double variance = varianceFromCellValues( cellValues, stackSize );
double stddev = std::sqrt( variance );
return stddev;
}

Expand Down

0 comments on commit 7383238

Please sign in to comment.