Browse Source

Code style; merge MCMC namespaces into one (drop .Diagnostics)

pull/222/head
Christoph Ruegg 12 years ago
parent
commit
df4cc7ef8e
  1. 2
      src/Numerics/Distributions/Normal.cs
  2. 12
      src/Numerics/GlobalizationHelper.cs
  3. 2
      src/Numerics/Statistics/MCMC/HybridMCGeneric.cs
  4. 2
      src/Numerics/Statistics/MCMC/MCMCDiagnostics.cs
  5. 2
      src/UnitTests/ComplexTests/Complex32Test.TextHandling.cs
  6. 5
      src/UnitTests/EuclidTests/IntegerTheoryTest.cs
  7. 10
      src/UnitTests/LinearAlgebraTests/MatrixHelpers.cs
  8. 25
      src/UnitTests/LinearAlgebraTests/VectorArithmeticTheory.cs
  9. 6
      src/UnitTests/RootFindingTests/BisectionTest.cs
  10. 6
      src/UnitTests/RootFindingTests/BrentTest.cs
  11. 6
      src/UnitTests/RootFindingTests/BroydenTest.cs
  12. 24
      src/UnitTests/RootFindingTests/CubicTest.cs
  13. 3
      src/UnitTests/StatisticsTests/MCMCTests/HybridMCTest.cs
  14. 2
      src/UnitTests/StatisticsTests/MCMCTests/MCMCDiagnosticsTest.cs
  15. 3
      src/UnitTests/StatisticsTests/MCMCTests/UnivariateHybridMCTest.cs
  16. 3
      src/UnitTests/StatisticsTests/StatTestData.cs

2
src/Numerics/Distributions/Normal.cs

@ -347,9 +347,9 @@ namespace MathNet.Numerics.Distributions
internal static IEnumerable<double> SamplesUnchecked(System.Random rnd, double mean, double stddev) internal static IEnumerable<double> SamplesUnchecked(System.Random rnd, double mean, double stddev)
{ {
double x, y;
while (true) while (true)
{ {
double x, y;
if (!PolarTransform(rnd.NextDouble(), rnd.NextDouble(), out x, out y)) if (!PolarTransform(rnd.NextDouble(), rnd.NextDouble(), out x, out y))
{ {
continue; continue;

12
src/Numerics/GlobalizationHelper.cs

@ -28,12 +28,12 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using System;
using System.Collections.Generic;
using System.Globalization;
namespace MathNet.Numerics namespace MathNet.Numerics
{ {
using System;
using System.Collections.Generic;
using System.Globalization;
/// <summary> /// <summary>
/// Globalized String Handling Helpers /// Globalized String Handling Helpers
/// </summary> /// </summary>
@ -105,7 +105,7 @@ namespace MathNet.Numerics
{ {
var keyword = keywords[i]; var keyword = keywords[i];
int indexOfKeyword; int indexOfKeyword;
while ((indexOfKeyword = node.Value.IndexOf(keyword)) >= 0) while ((indexOfKeyword = node.Value.IndexOf(keyword, StringComparison.Ordinal)) >= 0)
{ {
if (indexOfKeyword != 0) if (indexOfKeyword != 0)
{ {
@ -269,4 +269,4 @@ namespace MathNet.Numerics
} }
#endif #endif
} }
} }

2
src/Numerics/Statistics/MCMC/HybridMCGeneric.cs

@ -35,7 +35,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
using Properties; using Properties;
/// <summary> /// <summary>
/// The Hybrid (also called Hamiltonian) Monte Carlo produces samples from distribition P using a set /// The Hybrid (also called Hamiltonian) Monte Carlo produces samples from distribution P using a set
/// of Hamiltonian equations to guide the sampling process. It uses the negative of the log density as /// of Hamiltonian equations to guide the sampling process. It uses the negative of the log density as
/// a potential energy, and a randomly generated momentum to set up a Hamiltonian system, which is then used /// a potential energy, and a randomly generated momentum to set up a Hamiltonian system, which is then used
/// to sample the distribution. This can result in a faster convergence than the random walk Metropolis sampler /// to sample the distribution. This can result in a faster convergence than the random walk Metropolis sampler

2
src/Numerics/Statistics/MCMC/MCMCDiagnostics.cs

@ -32,7 +32,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace MathNet.Numerics.Statistics.Mcmc.Diagnostics namespace MathNet.Numerics.Statistics.Mcmc
{ {
/// <summary> /// <summary>
/// Provides utilities to analysis the convergence of a set of samples from /// Provides utilities to analysis the convergence of a set of samples from

2
src/UnitTests/ComplexTests/Complex32Test.TextHandling.cs

@ -75,8 +75,6 @@ namespace MathNet.Numerics.UnitTests.ComplexTests
/// Can format complex to string with culture. /// Can format complex to string with culture.
/// </summary> /// </summary>
/// <param name="cultureName">Culture ID.</param> /// <param name="cultureName">Culture ID.</param>
/// <param name="nan">Not a number name.</param>
/// <param name="infinity">Infinity name.</param>
/// <param name="number">Complex Number.</param> /// <param name="number">Complex Number.</param>
[TestCase("en-US", "1.1")] [TestCase("en-US", "1.1")]
[TestCase("tr-TR", "1,1")] [TestCase("tr-TR", "1,1")]

5
src/UnitTests/EuclidTests/IntegerTheoryTest.cs

@ -25,6 +25,7 @@
// </copyright> // </copyright>
using System; using System;
using System.Globalization;
using NUnit.Framework; using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.EuclidTests namespace MathNet.Numerics.UnitTests.EuclidTests
@ -253,7 +254,7 @@ namespace MathNet.Numerics.UnitTests.EuclidTests
for (var i = 2; i < 31; i++) for (var i = 2; i < 31; i++)
{ {
var x = 1 << i; var x = 1 << i;
Assert.AreEqual(x, x.CeilingToPowerOfTwo(), x.ToString()); Assert.AreEqual(x, x.CeilingToPowerOfTwo(), x.ToString(CultureInfo.InvariantCulture));
Assert.AreEqual(x, (x - 1).CeilingToPowerOfTwo(), x + "-1"); Assert.AreEqual(x, (x - 1).CeilingToPowerOfTwo(), x + "-1");
Assert.AreEqual(x, ((x >> 1) + 1).CeilingToPowerOfTwo(), x + "/2+1"); Assert.AreEqual(x, ((x >> 1) + 1).CeilingToPowerOfTwo(), x + "/2+1");
Assert.AreEqual(0, (-x).CeilingToPowerOfTwo(), "-" + x); Assert.AreEqual(0, (-x).CeilingToPowerOfTwo(), "-" + x);
@ -279,7 +280,7 @@ namespace MathNet.Numerics.UnitTests.EuclidTests
for (var i = 2; i < 63; i++) for (var i = 2; i < 63; i++)
{ {
var x = ((long)1) << i; var x = ((long)1) << i;
Assert.AreEqual(x, x.CeilingToPowerOfTwo(), x.ToString()); Assert.AreEqual(x, x.CeilingToPowerOfTwo(), x.ToString(CultureInfo.InvariantCulture));
Assert.AreEqual(x, (x - 1).CeilingToPowerOfTwo(), x + "-1"); Assert.AreEqual(x, (x - 1).CeilingToPowerOfTwo(), x + "-1");
Assert.AreEqual(x, ((x >> 1) + 1).CeilingToPowerOfTwo(), x + "/2+1"); Assert.AreEqual(x, ((x >> 1) + 1).CeilingToPowerOfTwo(), x + "/2+1");
Assert.AreEqual(0, (-x).CeilingToPowerOfTwo(), "-" + x); Assert.AreEqual(0, (-x).CeilingToPowerOfTwo(), "-" + x);

10
src/UnitTests/LinearAlgebraTests/MatrixHelpers.cs

@ -27,12 +27,12 @@
using System; using System;
using MathNet.Numerics.LinearAlgebra; using MathNet.Numerics.LinearAlgebra;
namespace MathNet.Numerics.UnitTests namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
{ {
#if NOSYSNUMERICS #if NOSYSNUMERICS
using Complex = Numerics.Complex; using Complex64 = Numerics.Complex;
#else #else
using Complex = System.Numerics.Complex; using Complex64 = System.Numerics.Complex;
#endif #endif
/// <summary> /// <summary>
@ -65,7 +65,7 @@ namespace MathNet.Numerics.UnitTests
/// from the lower triangle to the upper triangle. /// from the lower triangle to the upper triangle.
/// </summary> /// </summary>
/// <param name="matrix">The matrix to make conjugate symmetric.</param> /// <param name="matrix">The matrix to make conjugate symmetric.</param>
static public void ForceConjugateSymmetric(Matrix<Complex> matrix) static public void ForceConjugateSymmetric(Matrix<Complex64> matrix)
{ {
if (matrix.RowCount != matrix.ColumnCount) if (matrix.RowCount != matrix.ColumnCount)
{ {
@ -85,7 +85,7 @@ namespace MathNet.Numerics.UnitTests
/// from the lower triangle to the upper triangle. /// from the lower triangle to the upper triangle.
/// </summary> /// </summary>
/// <param name="matrix">The matrix to make conjugate symmetric.</param> /// <param name="matrix">The matrix to make conjugate symmetric.</param>
public static void ForceConjugateSymmetric(Matrix<Complex32> matrix) public static void ForceConjugateSymmetric(Matrix<Numerics.Complex32> matrix)
{ {
if (matrix.RowCount != matrix.ColumnCount) if (matrix.RowCount != matrix.ColumnCount)
{ {

25
src/UnitTests/LinearAlgebraTests/VectorArithmeticTheory.cs

@ -28,6 +28,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using System.Globalization;
using MathNet.Numerics.LinearAlgebra; using MathNet.Numerics.LinearAlgebra;
using NUnit.Framework; using NUnit.Framework;
using System; using System;
@ -92,8 +93,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
for (var i = 0; i < Math.Min(vector.Count, 20); i++) for (var i = 0; i < Math.Min(vector.Count, 20); i++)
{ {
Assert.That(result1[i], Is.EqualTo(Minus(vector[i])), i.ToString()); Assert.That(result1[i], Is.EqualTo(Minus(vector[i])), i.ToString(CultureInfo.InvariantCulture));
Assert.That(result2[i], Is.EqualTo(Minus(vector[i])), i.ToString()); Assert.That(result2[i], Is.EqualTo(Minus(vector[i])), i.ToString(CultureInfo.InvariantCulture));
} }
} }
@ -123,9 +124,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
for (var i = 0; i < Math.Min(a.Count, 20); i++) for (var i = 0; i < Math.Min(a.Count, 20); i++)
{ {
Assert.That(result1[i], Is.EqualTo(Add(a[i], b[i])), i.ToString()); Assert.That(result1[i], Is.EqualTo(Add(a[i], b[i])), i.ToString(CultureInfo.InvariantCulture));
Assert.That(result2[i], Is.EqualTo(Add(a[i], b[i])), i.ToString()); Assert.That(result2[i], Is.EqualTo(Add(a[i], b[i])), i.ToString(CultureInfo.InvariantCulture));
Assert.That(result3[i], Is.EqualTo(Add(a[i], b[i])), i.ToString()); Assert.That(result3[i], Is.EqualTo(Add(a[i], b[i])), i.ToString(CultureInfo.InvariantCulture));
} }
} }
@ -147,8 +148,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
for (var i = 0; i < Math.Min(vector.Count, 20); i++) for (var i = 0; i < Math.Min(vector.Count, 20); i++)
{ {
Assert.That(result1[i], Is.EqualTo(Add(vector[i], scalar)), i.ToString()); Assert.That(result1[i], Is.EqualTo(Add(vector[i], scalar)), i.ToString(CultureInfo.InvariantCulture));
Assert.That(result2[i], Is.EqualTo(Add(vector[i], scalar)), i.ToString()); Assert.That(result2[i], Is.EqualTo(Add(vector[i], scalar)), i.ToString(CultureInfo.InvariantCulture));
} }
} }
@ -178,9 +179,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
for (var i = 0; i < Math.Min(a.Count, 20); i++) for (var i = 0; i < Math.Min(a.Count, 20); i++)
{ {
Assert.That(result1[i], Is.EqualTo(Subtract(a[i], b[i])), i.ToString()); Assert.That(result1[i], Is.EqualTo(Subtract(a[i], b[i])), i.ToString(CultureInfo.InvariantCulture));
Assert.That(result2[i], Is.EqualTo(Subtract(a[i], b[i])), i.ToString()); Assert.That(result2[i], Is.EqualTo(Subtract(a[i], b[i])), i.ToString(CultureInfo.InvariantCulture));
Assert.That(result3[i], Is.EqualTo(Subtract(a[i], b[i])), i.ToString()); Assert.That(result3[i], Is.EqualTo(Subtract(a[i], b[i])), i.ToString(CultureInfo.InvariantCulture));
} }
} }
@ -202,8 +203,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
for (var i = 0; i < Math.Min(vector.Count, 20); i++) for (var i = 0; i < Math.Min(vector.Count, 20); i++)
{ {
Assert.That(result1[i], Is.EqualTo(Subtract(vector[i], scalar)), i.ToString()); Assert.That(result1[i], Is.EqualTo(Subtract(vector[i], scalar)), i.ToString(CultureInfo.InvariantCulture));
Assert.That(result2[i], Is.EqualTo(Subtract(vector[i], scalar)), i.ToString()); Assert.That(result2[i], Is.EqualTo(Subtract(vector[i], scalar)), i.ToString(CultureInfo.InvariantCulture));
} }
} }
} }

6
src/UnitTests/RootFindingTests/BisectionTest.cs

@ -96,8 +96,8 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests
const double G21 = 0.30175355; const double G21 = 0.30175355;
double P2 = Math.Pow(10, 6.87776 - 1171.53 / (224.366 + T)); double P2 = Math.Pow(10, 6.87776 - 1171.53 / (224.366 + T));
double P1 = Math.Pow(10, 8.04494 - 1554.3 / (222.65 + T)); double P1 = Math.Pow(10, 8.04494 - 1554.3 / (222.65 + T));
double t1 = x1 + x2 * G12; const double t1 = x1 + x2 * G12;
double t2 = x2 + x1 * G21; const double t2 = x2 + x1 * G21;
double gamma2 = Math.Exp(-Math.Log(t2) - (x1 * (G12 * t2 - G21 * t1)) / (t1 * t2)); double gamma2 = Math.Exp(-Math.Log(t2) - (x1 * (G12 * t2 - G21 * t1)) / (t1 * t2));
double gamma1 = Math.Exp(-Math.Log(t1) + (x2 * (G12 * t2 - G21 * t1)) / (t1 * t2)); double gamma1 = Math.Exp(-Math.Log(t1) + (x2 * (G12 * t2 - G21 * t1)) / (t1 * t2));
double k1 = gamma1 * P1 / 760; double k1 = gamma1 * P1 / 760;
@ -462,7 +462,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests
const double gam = -4.3 * CH4 - 11.049 * C2H6 - 3.545 * COtwo + 0.283 * H2O - 0.001 * N2 - 0.923 * O2; const double gam = -4.3 * CH4 - 11.049 * C2H6 - 3.545 * COtwo + 0.283 * H2O - 0.001 * N2 - 0.923 * O2;
const double H0 = alp * 298 + bet * 0.001 * 298 * 298 / 2 + gam * 1e-6 * 298 * 298 * 298 / 3; const double H0 = alp * 298 + bet * 0.001 * 298 * 298 / 2 + gam * 1e-6 * 298 * 298 * 298 / 3;
double Hf = alp * T + bet * 0.001 * T * T / 2 + gam * 1e-6 * T * T * T / 3; double Hf = alp * T + bet * 0.001 * T * T / 2 + gam * 1e-6 * T * T * T / 3;
double xx = 1; const double xx = 1;
return 212798 * y * xx + 372820 * z * xx + H0 - Hf; return 212798 * y * xx + 372820 * z * xx + H0 - Hf;
}; };

6
src/UnitTests/RootFindingTests/BrentTest.cs

@ -109,8 +109,8 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests
const double G21 = 0.30175355; const double G21 = 0.30175355;
double P2 = Math.Pow(10, 6.87776 - 1171.53 / (224.366 + T)); double P2 = Math.Pow(10, 6.87776 - 1171.53 / (224.366 + T));
double P1 = Math.Pow(10, 8.04494 - 1554.3 / (222.65 + T)); double P1 = Math.Pow(10, 8.04494 - 1554.3 / (222.65 + T));
double t1 = x1 + x2 * G12; const double t1 = x1 + x2 * G12;
double t2 = x2 + x1 * G21; const double t2 = x2 + x1 * G21;
double gamma2 = Math.Exp(-Math.Log(t2) - (x1 * (G12 * t2 - G21 * t1)) / (t1 * t2)); double gamma2 = Math.Exp(-Math.Log(t2) - (x1 * (G12 * t2 - G21 * t1)) / (t1 * t2));
double gamma1 = Math.Exp(-Math.Log(t1) + (x2 * (G12 * t2 - G21 * t1)) / (t1 * t2)); double gamma1 = Math.Exp(-Math.Log(t1) + (x2 * (G12 * t2 - G21 * t1)) / (t1 * t2));
double k1 = gamma1 * P1 / 760; double k1 = gamma1 * P1 / 760;
@ -472,7 +472,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests
const double gam = -4.3 * CH4 - 11.049 * C2H6 - 3.545 * COtwo + 0.283 * H2O - 0.001 * N2 - 0.923 * O2; const double gam = -4.3 * CH4 - 11.049 * C2H6 - 3.545 * COtwo + 0.283 * H2O - 0.001 * N2 - 0.923 * O2;
const double H0 = alp * 298 + bet * 0.001 * 298 * 298 / 2 + gam * 1e-6 * 298 * 298 * 298 / 3; const double H0 = alp * 298 + bet * 0.001 * 298 * 298 / 2 + gam * 1e-6 * 298 * 298 * 298 / 3;
double Hf = alp * T + bet * 0.001 * T * T / 2 + gam * 1e-6 * T * T * T / 3; double Hf = alp * T + bet * 0.001 * T * T / 2 + gam * 1e-6 * T * T * T / 3;
double xx = 1; const double xx = 1;
return 212798 * y * xx + 372820 * z * xx + H0 - Hf; return 212798 * y * xx + 372820 * z * xx + H0 - Hf;
}; };

6
src/UnitTests/RootFindingTests/BroydenTest.cs

@ -97,8 +97,8 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests
const double G21 = 0.30175355; const double G21 = 0.30175355;
double P2 = Math.Pow(10, 6.87776 - 1171.53 / (224.366 + T)); double P2 = Math.Pow(10, 6.87776 - 1171.53 / (224.366 + T));
double P1 = Math.Pow(10, 8.04494 - 1554.3 / (222.65 + T)); double P1 = Math.Pow(10, 8.04494 - 1554.3 / (222.65 + T));
double t1 = x1 + x2 * G12; const double t1 = x1 + x2 * G12;
double t2 = x2 + x1 * G21; const double t2 = x2 + x1 * G21;
double gamma2 = Math.Exp(-Math.Log(t2) - (x1 * (G12 * t2 - G21 * t1)) / (t1 * t2)); double gamma2 = Math.Exp(-Math.Log(t2) - (x1 * (G12 * t2 - G21 * t1)) / (t1 * t2));
double gamma1 = Math.Exp(-Math.Log(t1) + (x2 * (G12 * t2 - G21 * t1)) / (t1 * t2)); double gamma1 = Math.Exp(-Math.Log(t1) + (x2 * (G12 * t2 - G21 * t1)) / (t1 * t2));
double k1 = gamma1 * P1 / 760; double k1 = gamma1 * P1 / 760;
@ -463,7 +463,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests
const double gam = -4.3 * CH4 - 11.049 * C2H6 - 3.545 * COtwo + 0.283 * H2O - 0.001 * N2 - 0.923 * O2; const double gam = -4.3 * CH4 - 11.049 * C2H6 - 3.545 * COtwo + 0.283 * H2O - 0.001 * N2 - 0.923 * O2;
const double H0 = alp * 298 + bet * 0.001 * 298 * 298 / 2 + gam * 1e-6 * 298 * 298 * 298 / 3; const double H0 = alp * 298 + bet * 0.001 * 298 * 298 / 2 + gam * 1e-6 * 298 * 298 * 298 / 3;
double Hf = alp * T + bet * 0.001 * T * T / 2 + gam * 1e-6 * T * T * T / 3; double Hf = alp * T + bet * 0.001 * T * T / 2 + gam * 1e-6 * T * T * T / 3;
double xx = 1; const double xx = 1;
return 212798 * y * xx + 372820 * z * xx + H0 - Hf; return 212798 * y * xx + 372820 * z * xx + H0 - Hf;
}; };

24
src/UnitTests/RootFindingTests/CubicTest.cs

@ -9,9 +9,9 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests
[Test] [Test]
public void RealRoots_SingleReal() public void RealRoots_SingleReal()
{ {
var a0 = 1d; const double a0 = 1d;
var a1 = 5d; const double a1 = 5d;
var a2 = 2d; const double a2 = 2d;
var roots = Cubic.RealRoots(a0, a1, a2); var roots = Cubic.RealRoots(a0, a1, a2);
var root = roots.Item1; var root = roots.Item1;
var funcValue = root * (root * (root + a2) + a1) + a0; var funcValue = root * (root * (root + a2) + a1) + a0;
@ -23,9 +23,9 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests
[Test] [Test]
public void RealRoots_DoubleReal1() public void RealRoots_DoubleReal1()
{ {
var a0 = -2d; const double a0 = -2d;
var a1 = 5d; const double a1 = 5d;
var a2 = -4d; const double a2 = -4d;
var roots = Cubic.RealRoots(a0, a1, a2); var roots = Cubic.RealRoots(a0, a1, a2);
Assert.That(roots.Item1, Is.EqualTo(2).Within(1e-14)); Assert.That(roots.Item1, Is.EqualTo(2).Within(1e-14));
Assert.That(roots.Item2, Is.EqualTo(1).Within(1e-14)); Assert.That(roots.Item2, Is.EqualTo(1).Within(1e-14));
@ -35,9 +35,9 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests
[Test] [Test]
public void RealRoots_DoubleReal2() public void RealRoots_DoubleReal2()
{ {
var a0 = -4d; const double a0 = -4d;
var a1 = 8d; const double a1 = 8d;
var a2 = -5d; const double a2 = -5d;
var roots = Cubic.RealRoots(a0, a1, a2); var roots = Cubic.RealRoots(a0, a1, a2);
Assert.That(roots.Item1, Is.EqualTo(1).Within(1e-14)); Assert.That(roots.Item1, Is.EqualTo(1).Within(1e-14));
Assert.That(roots.Item2, Is.EqualTo(2).Within(1e-14)); Assert.That(roots.Item2, Is.EqualTo(2).Within(1e-14));
@ -47,9 +47,9 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests
[Test] [Test]
public void RealRoots_TripleReal() public void RealRoots_TripleReal()
{ {
var a0 = 6d; const double a0 = 6d;
var a1 = -5d; const double a1 = -5d;
var a2 = -2d; const double a2 = -2d;
var roots = Cubic.RealRoots(a0, a1, a2); var roots = Cubic.RealRoots(a0, a1, a2);
Assert.That(roots.Item1, Is.EqualTo(3).Within(1e-14)); Assert.That(roots.Item1, Is.EqualTo(3).Within(1e-14));
Assert.That(roots.Item2, Is.EqualTo(-2).Within(1e-14)); Assert.That(roots.Item2, Is.EqualTo(-2).Within(1e-14));

3
src/UnitTests/StatisticsTests/MCMCTests/HybridMCTest.cs

@ -29,6 +29,7 @@
// </copyright> // </copyright>
using System; using System;
using System.Globalization;
using MathNet.Numerics.Distributions; using MathNet.Numerics.Distributions;
using MathNet.Numerics.Statistics; using MathNet.Numerics.Statistics;
using MathNet.Numerics.Statistics.Mcmc; using MathNet.Numerics.Statistics.Mcmc;
@ -151,7 +152,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
string index = i.ToString(); string index = i.ToString(CultureInfo.InvariantCulture);
Assert.AreEqual(mean[i], sampleMean[i], 10*convergence[i], index + "Mean"); Assert.AreEqual(mean[i], sampleMean[i], 10*convergence[i], index + "Mean");
Assert.AreEqual(sampleSdv[i]*sampleSdv[i], sdv[i]*sdv[i], 10*convergence[i], index + "Standard Deviation"); Assert.AreEqual(sampleSdv[i]*sampleSdv[i], sdv[i]*sdv[i], 10*convergence[i], index + "Standard Deviation");
} }

2
src/UnitTests/StatisticsTests/MCMCTests/MCMCDiagnosticsTest.cs

@ -31,7 +31,7 @@
using System; using System;
using MathNet.Numerics.Distributions; using MathNet.Numerics.Distributions;
using MathNet.Numerics.Statistics; using MathNet.Numerics.Statistics;
using MathNet.Numerics.Statistics.Mcmc.Diagnostics; using MathNet.Numerics.Statistics.Mcmc;
using NUnit.Framework; using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests

3
src/UnitTests/StatisticsTests/MCMCTests/UnivariateHybridMCTest.cs

@ -32,7 +32,6 @@ using System;
using MathNet.Numerics.Distributions; using MathNet.Numerics.Distributions;
using MathNet.Numerics.Statistics; using MathNet.Numerics.Statistics;
using MathNet.Numerics.Statistics.Mcmc; using MathNet.Numerics.Statistics.Mcmc;
using MathNet.Numerics.Statistics.Mcmc.Diagnostics;
using NUnit.Framework; using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests
@ -142,7 +141,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests
//Approximating chi-square with normal distribution. (Degree of freedom is large) //Approximating chi-square with normal distribution. (Degree of freedom is large)
double deviationConvergence = 3*Constants.Sqrt2/Math.Sqrt(effective); double deviationConvergence = 3*Constants.Sqrt2/Math.Sqrt(effective);
Assert.AreEqual(deviationRation, 1, deviationConvergence, "Standard Deivation"); Assert.AreEqual(deviationRation, 1, deviationConvergence, "Standard Deviation");
} }
} }
} }

3
src/UnitTests/StatisticsTests/StatTestData.cs

@ -28,6 +28,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using System;
using System.Globalization; using System.Globalization;
namespace MathNet.Numerics.UnitTests.StatisticsTests namespace MathNet.Numerics.UnitTests.StatisticsTests
@ -116,7 +117,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests
/// <returns>Parameter value.</returns> /// <returns>Parameter value.</returns>
static double GetValue(string str) static double GetValue(string str)
{ {
var start = str.IndexOf(":"); var start = str.IndexOf(":", StringComparison.Ordinal);
var value = str.Substring(start + 1).Trim(); var value = str.Substring(start + 1).Trim();
if (value.Equals("NaN")) if (value.Equals("NaN"))
{ {

Loading…
Cancel
Save