Browse Source

Goodness of Fit: drop Sample-prefix of SampleStandardError

pull/469/head
Christoph Ruegg 10 years ago
parent
commit
2e30ef2b61
  1. 6
      src/Numerics/GoodnessOfFit.cs
  2. 8
      src/UnitTests/GoodnessOfFit/StandardErrorTest.cs

6
src/Numerics/GoodnessOfFit.cs

@ -68,7 +68,7 @@ namespace MathNet.Numerics
/// <returns>The Standard Error of the regression</returns>
public static double PopulationStandardError(IEnumerable<double> modelledValues, IEnumerable<double> observedValues)
{
return SampleStandardError(modelledValues, observedValues, 0);
return StandardError(modelledValues, observedValues, 0);
}
/// <summary>
@ -80,7 +80,7 @@ namespace MathNet.Numerics
/// <param name="degreesOfFreedom">The degrees of freedom by which the
/// number of samples is reduced for performing the Standard Error calculation</param>
/// <returns>The Standard Error of the regression</returns>
public static double SampleStandardError(IEnumerable<double> modelledValues, IEnumerable<double> observedValues, int degreesOfFreedom)
public static double StandardError(IEnumerable<double> modelledValues, IEnumerable<double> observedValues, int degreesOfFreedom)
{
using (IEnumerator<double> ieM = modelledValues.GetEnumerator())
using (IEnumerator<double> ieO = observedValues.GetEnumerator())
@ -108,4 +108,4 @@ namespace MathNet.Numerics
}
}
}
}
}

8
src/UnitTests/GoodnessOfFit/StandardErrorTest.cs

@ -52,7 +52,7 @@ namespace MathNet.Numerics.UnitTests.GoodnessOfFit
}
[Test]
public void ComputesSampleStandardErrorOfTheRegression()
public void ComputesStandardErrorOfTheRegression()
{
// Definition as described at: http://onlinestatbook.com/lms/regression/accuracy.html
var xes = new[] { 1.0, 2, 3, 4, 5 };
@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.GoodnessOfFit
var a = fit.Item1;
var b = fit.Item2;
var predictedYs = xes.Select(x => a + b * x);
var standardError = Numerics.GoodnessOfFit.SampleStandardError(predictedYs, ys, degreesOfFreedom: 2);
var standardError = Numerics.GoodnessOfFit.StandardError(predictedYs, ys, degreesOfFreedom: 2);
Assert.AreEqual(0.964, standardError, 1e-3);
}
@ -76,11 +76,11 @@ namespace MathNet.Numerics.UnitTests.GoodnessOfFit
}
[Test]
public void SampleStandardErrorShouldThrowIfSampleSizeIsSmallerThanGivenDegreesOfFreedom()
public void StandardErrorShouldThrowIfSampleSizeIsSmallerThanGivenDegreesOfFreedom()
{
var modelled = new[] { 1.0 };
var observed = new[] { 1.0 };
Assert.Throws<ArgumentOutOfRangeException>(() => Numerics.GoodnessOfFit.SampleStandardError(modelled, observed, 2));
Assert.Throws<ArgumentOutOfRangeException>(() => Numerics.GoodnessOfFit.StandardError(modelled, observed, 2));
}
}
}

Loading…
Cancel
Save