Skip to content
Snippets Groups Projects
Commit d1b24f46 authored by Andre Offringa's avatar Andre Offringa
Browse files

Task #1892: error values on slope

parent c4073d86
Branches
Tags
No related merge requests found
......@@ -263,6 +263,34 @@ class LogHistogram : public Serializable
return (double) (sumOffset/(long double) n);
}
double NormalizedSlopeStdDev(double startAmplitude, double endAmplitude, double slope, double offset) const
{
long double sqErrorSum = 0.0, xsqErrorSum = 0.0, xSum = 0.0;
unsigned long n = 0;
// determine the 'average' x
for(const_iterator i=begin();i!=end();++i)
{
if(i.value() >= startAmplitude && i.value() < endAmplitude)
{
xSum += log10(i.value());
++n;
}
}
const long double avgX = xSum / n;
for(const_iterator i=begin();i!=end();++i)
{
if(i.value() >= startAmplitude && i.value() < endAmplitude)
{
long double y = log10(i.normalizedCount());
long double x = log10(i.value());
long double ySlope = x*slope + offset;
sqErrorSum += (y-ySlope)*(y-ySlope);
xsqErrorSum += (x - avgX)*(x - avgX);
}
}
return (double) sqrtl(sqErrorSum/(xsqErrorSum * (long double) (n-2)));
}
double PowerLawUpperLimit(double constrainingAmplitude, double exponent, double factor) const
{
const double count = NormalizedCountAbove(constrainingAmplitude);
......
......@@ -453,11 +453,13 @@ void HistogramPage::addSlopeText(std::stringstream &str, const LogHistogram &his
}
double rfiRatio = atof(_slopeRFIRatio.get_text().c_str());
double slope = histogram.NormalizedSlope(minRange, maxRange);
double offset = histogram.NormalizedSlopeOffset(minRange, maxRange, slope);
double upperLimit = histogram.PowerLawUpperLimit(minRange, slope, pow10(offset));
double lowerLimit = histogram.PowerLawLowerLimit(minRange, slope, pow10(offset), rfiRatio);
str << '\n' << slope << '[' << log10(lowerLimit) << ';' << log10(upperLimit) << ']';
const double
slope = histogram.NormalizedSlope(minRange, maxRange),
offset = histogram.NormalizedSlopeOffset(minRange, maxRange, slope),
error = histogram.NormalizedSlopeStdDev(minRange, maxRange, slope, offset),
upperLimit = histogram.PowerLawUpperLimit(minRange, slope, pow10(offset)),
lowerLimit = histogram.PowerLawLowerLimit(minRange, slope, pow10(offset), rfiRatio);
str << '\n' << slope << "±" << error << '[' << log10(lowerLimit) << ';' << log10(upperLimit) << ']';
}
void HistogramPage::updateDataWindow()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment