public void StabilityMeanVariance() { // Test around 10^9, potential stability issues var gaussian = new Distributions.Normal(1e+9, 2) { RandomSource = new Numerics.Random.MersenneTwister(100) }; AssertHelpers.AlmostEqual(1e+9, gaussian.Samples().Take(10000).Mean(), 11); AssertHelpers.AlmostEqual(4d, gaussian.Samples().Take(10000).Variance(), 1); AssertHelpers.AlmostEqual(2d, gaussian.Samples().Take(10000).StandardDeviation(), 2); }
public static Vector GenerateRandomDenseVector(int order) { // Fill a matrix with standard random numbers. var normal = new Distributions.Normal(); normal.RandomSource = new Random.MersenneTwister(1); var v = new DenseVector(order); for (int i = 0; i < order; i++) { v[i] = normal.Sample(); } // Generate a matrix which is positive definite. return v; }
public static Vector <float> GenerateRandomUserDefinedVector(int order) { // Fill a matrix with standard random numbers. var normal = new Distributions.Normal(); normal.RandomSource = new Numerics.Random.MersenneTwister(1); var v = new UserDefinedVector(order); for (int i = 0; i < order; i++) { v[i] = (float)normal.Sample(); } // Generate a matrix which is positive definite. return(v); }
public static Matrix GenerateRandomPositiveDefiniteDenseMatrix(int order) { // Fill a matrix with standard random numbers. var normal = new Distributions.Normal(); normal.RandomSource = new Random.MersenneTwister(1); var A = new DenseMatrix(order); for (int i = 0; i < order; i++) { for (int j = 0; j < order; j++) { A[i, j] = normal.Sample(); } } // Generate a matrix which is positive definite. return A.Transpose() * A; }
public static Matrix GenerateRandomDenseMatrix(int row, int col) { // Fill a matrix with standard random numbers. var normal = new Distributions.Normal(); normal.RandomSource = new Random.MersenneTwister(1); var A = new DenseMatrix(row, col); for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { A[i, j] = normal.Sample(); } } // Generate a matrix which is positive definite. return A; }
public void StabilityMeanVariance() { // Test around 10^9, potential stability issues var gaussian = new Distributions.Normal(1e+9, 2, new MersenneTwister(100)); AssertHelpers.AlmostEqual(1e+9, Statistics.Mean(gaussian.Samples().Take(10000)), 11); AssertHelpers.AlmostEqual(4d, Statistics.Variance(gaussian.Samples().Take(10000)), 1); AssertHelpers.AlmostEqual(2d, Statistics.StandardDeviation(gaussian.Samples().Take(10000)), 2); AssertHelpers.AlmostEqual(1e+9, ArrayStatistics.Mean(gaussian.Samples().Take(10000).ToArray()), 11); AssertHelpers.AlmostEqual(4d, ArrayStatistics.Variance(gaussian.Samples().Take(10000).ToArray()), 1); AssertHelpers.AlmostEqual(2d, ArrayStatistics.StandardDeviation(gaussian.Samples().Take(10000).ToArray()), 2); AssertHelpers.AlmostEqual(1e+9, StreamingStatistics.Mean(gaussian.Samples().Take(10000)), 11); AssertHelpers.AlmostEqual(4d, StreamingStatistics.Variance(gaussian.Samples().Take(10000)), 1); AssertHelpers.AlmostEqual(2d, StreamingStatistics.StandardDeviation(gaussian.Samples().Take(10000)), 2); }
public static Vector <Complex> GenerateRandomDenseVector(int order) { // Fill a matrix with standard random numbers. var normal = new Distributions.Normal { RandomSource = new Numerics.Random.MersenneTwister(1) }; var v = new DenseVector(order); for (var i = 0; i < order; i++) { v[i] = new Complex(normal.Sample(), normal.Sample()); } // Generate a matrix which is positive definite. return(v); }
public static Matrix<Complex> GenerateRandomDenseMatrix(int row, int col) { // Fill a matrix with standard random numbers. var normal = new Distributions.Normal { RandomSource = new Random.MersenneTwister(1) }; var matrixA = new DenseMatrix(row, col); for (var i = 0; i < row; i++) { for (var j = 0; j < col; j++) { matrixA[i, j] = new Complex(normal.Sample(), normal.Sample()); } } // Generate a matrix which is positive definite. return matrixA; }
public static Matrix <float> GenerateRandomDenseMatrix(int row, int col) { // Fill a matrix with standard random numbers. var normal = new Distributions.Normal(); normal.RandomSource = new Numerics.Random.MersenneTwister(1); var matrixA = new DenseMatrix(row, col); for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { matrixA[i, j] = (float)normal.Sample(); } } // Generate a matrix which is positive definite. return(matrixA); }
public static Matrix <float> GenerateRandomPositiveDefiniteUserDefinedMatrix(int order) { // Fill a matrix with standard random numbers. var normal = new Distributions.Normal(); normal.RandomSource = new Numerics.Random.MersenneTwister(1); var matrixA = new UserDefinedMatrix(order); for (int i = 0; i < order; i++) { for (int j = 0; j < order; j++) { matrixA[i, j] = (float)normal.Sample(); } } // Generate a matrix which is positive definite. return(matrixA.Transpose() * matrixA); }
public static Matrix <Complex> GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(int order) { // Fill a matrix with standard random numbers. var normal = new Distributions.Normal { RandomSource = new Numerics.Random.MersenneTwister(1) }; var matrixA = new UserDefinedMatrix(order); for (var i = 0; i < order; i++) { for (var j = 0; j < order; j++) { matrixA[i, j] = new Complex(normal.Sample(), normal.Sample()); } } // Generate a Hermitian matrix which is positive definite. return(matrixA.ConjugateTranspose() * matrixA); }
public static Matrix <Complex> GenerateRandomUserDefinedMatrix(int row, int col) { // Fill a matrix with standard random numbers. var normal = new Distributions.Normal { RandomSource = new Numerics.Random.MersenneTwister(1) }; var matrixA = new UserDefinedMatrix(row, col); for (var i = 0; i < row; i++) { for (var j = 0; j < col; j++) { matrixA[i, j] = new Complex(normal.Sample(), normal.Sample()); } } // Generate a matrix which is positive definite. return(matrixA); }
public static Matrix<Complex> GenerateRandomPositiveDefiniteHermitianDenseMatrix(int order) { // Fill a matrix with standard random numbers. var normal = new Distributions.Normal { RandomSource = new Random.MersenneTwister(1) }; var matrixA = new DenseMatrix(order); for (var i = 0; i < order; i++) { for (var j = 0; j < order; j++) { matrixA[i, j] = new Complex(normal.Sample(), normal.Sample()); } } // Generate a Hermitian matrix which is positive definite. return matrixA.ConjugateTranspose() * matrixA; }
public static Vector<Complex> GenerateRandomUserDefinedVector(int order) { // Fill a matrix with standard random numbers. var normal = new Distributions.Normal { RandomSource = new Random.MersenneTwister(1) }; var v = new UserDefinedVector(order); for (var i = 0; i < order; i++) { v[i] = new Complex(normal.Sample(), normal.Sample()); } // Generate a matrix which is positive definite. return v; }