void updateWeightedSDEstimate(PeakType p, const double& mean_t1, double& sd_t, double& last_weights_sum) { double denom = last_weights_sum * sd_t * sd_t + p.getIntensity() * (p.getMZ() - mean_t1) * (p.getMZ() - mean_t1); double weights_sum = last_weights_sum + p.getIntensity(); double tmp_sd = std::sqrt(denom / weights_sum); if (tmp_sd > std::numeric_limits<double>::epsilon()) { sd_t = tmp_sd; } last_weights_sum = weights_sum; }
void updateWeightedSDEstimateRobust(PeakType p, const double& mean_t1, double& sd_t, double& last_weights_sum) { double denom1 = std::log(last_weights_sum) + 2 * std::log(sd_t); double denom2 = std::log(p.getIntensity()) + 2 * std::log(std::abs(p.getMZ() - mean_t1)); double denom = std::sqrt(std::exp(denom1) + std::exp(denom2)); double weights_sum = last_weights_sum + p.getIntensity(); double tmp_sd = denom / std::sqrt(weights_sum); if (tmp_sd > std::numeric_limits<double>::epsilon()) { sd_t = tmp_sd; } last_weights_sum = weights_sum; }