public void ValidateToString() { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; var d = new InverseWishart(1d, Matrix <double> .Build.RandomPositiveDefinite(2, 1)); Assert.AreEqual("InverseWishart(ν = 1, Rows = 2, Columns = 2)", d.ToString()); }
public void HasRandomSourceEvenAfterSetToNull() { var d = new InverseWishart(1.0, Matrix <double> .Build.RandomPositiveDefinite(2, 1)); Assert.DoesNotThrow(() => d.RandomSource = null); Assert.IsNotNull(d.RandomSource); }
public void HasRandomSourceEvenAfterSetToNull() { var d = new InverseWishart(1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)); Assert.DoesNotThrow(() => d.RandomSource = null); Assert.IsNotNull(d.RandomSource); }
public void FailSCreateInverseWishart(double nu, int order) { var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); matrix[0, 0] = 0.0; var d = new InverseWishart(nu, matrix); }
public void ValidateDensity(double nu, double density) { var matrix = Matrix <double> .Build.Dense(1, 1, 1.0); var x = Matrix <double> .Build.Dense(1, 1, 5.0); var d = new InverseWishart(nu, matrix); AssertHelpers.AlmostEqualRelative(density, d.Density(x), 16); }
public void ValidateMode(double nu, int order) { var d = new InverseWishart(nu, Matrix <double> .Build.RandomPositiveDefinite(order, 1)); var mode = d.Mode; for (var i = 0; i < d.Scale.RowCount; i++) { for (var j = 0; j < d.Scale.ColumnCount; j++) { Assert.AreEqual(d.Scale[i, j] * (1.0 / (nu + d.Scale.RowCount + 1.0)), mode[i, j]); } } }
public void CanGetS() { int order = 2; var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); var d = new InverseWishart(1.0, matrix); for (int i = 0; i < order; i++) { for (int j = 0; j < order; j++) { Assert.AreEqual <double>(matrix[i, j], d.S[i, j]); } } }
public void CanCreateInverseWishart(double nu, int order) { var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); var d = new InverseWishart(nu, matrix); Assert.AreEqual(nu, d.DegreesOfFreedom); for (var i = 0; i < d.Scale.RowCount; i++) { for (var j = 0; j < d.Scale.ColumnCount; j++) { Assert.AreEqual(matrix[i, j], d.Scale[i, j]); } } }
public void ValidateMode([Values(0.1, 1.0, 5.0)] double nu, [Values(2, 5)] int order) { var d = new InverseWishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order)); var mode = d.Mode; for (var i = 0; i < d.S.RowCount; i++) { for (var j = 0; j < d.S.ColumnCount; j++) { Assert.AreEqual(d.S[i, j] * (1.0 / (nu + d.S.RowCount + 1.0)), mode[i, j]); } } }
public void CanGetS() { const int Order = 2; var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(Order); var d = new InverseWishart(1.0, matrix); for (var i = 0; i < Order; i++) { for (var j = 0; j < Order; j++) { Assert.AreEqual(matrix[i, j], d.S[i, j]); } } }
public void CanCreateInverseWishart([Values(0.1, 1.0, 5.0)] double nu, [Values(2, 5)] int order) { var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); var d = new InverseWishart(nu, matrix); Assert.AreEqual(nu, d.Nu); for (var i = 0; i < d.S.RowCount; i++) { for (var j = 0; j < d.S.ColumnCount; j++) { Assert.AreEqual(matrix[i, j], d.S[i, j]); } } }
public void ValidateMean(double nu, int order) { var d = new InverseWishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order)); var mean = d.Mean; for (var i = 0; i < d.Scale.RowCount; i++) { for (var j = 0; j < d.Scale.ColumnCount; j++) { Assert.AreEqual(d.Scale[i, j] * (1.0 / (nu - d.Scale.RowCount - 1.0)), mean[i, j]); } } }
public void ValidateDensity([Values(1.0, 2.0, 5.0)] double nu, [Values(0.03228684517430723, 0.018096748360719193, 0.00043049126899076171)] double density) { const int Order = 1; var matrix = new DenseMatrix(Order); matrix[0, 0] = 1; var x = new DenseMatrix(Order); x[0, 0] = 5; var d = new InverseWishart(nu, matrix); AssertHelpers.AlmostEqual(density, d.Density(x), 16); }
public void CanGetS() { const int Order = 2; var matrix = Matrix <double> .Build.RandomPositiveDefinite(Order, 1); var d = new InverseWishart(1.0, matrix); for (var i = 0; i < Order; i++) { for (var j = 0; j < Order; j++) { Assert.AreEqual(matrix[i, j], d.Scale[i, j]); } } }
public void CanCreateInverseWishart(double nu, int order) { var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); var d = new InverseWishart(nu, matrix); Assert.AreEqual<double>(nu, d.Nu); for (int i = 0; i < d.S.RowCount; i++) { for (int j = 0; j < d.S.ColumnCount; j++) { Assert.AreEqual(matrix[i, j], d.S[i, j]); } } }
public void ValidateDensity(double nu, double density) { const int Order = 1; var matrix = new DenseMatrix(Order); matrix[0, 0] = 1; var x = new DenseMatrix(Order); x[0, 0] = 5; var d = new InverseWishart(nu, matrix); AssertHelpers.AlmostEqualRelative(density, d.Density(x), 16); }
public void CanCreateInverseWishart(double nu, int order) { var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); var d = new InverseWishart(nu, matrix); Assert.AreEqual <double>(nu, d.Nu); for (int i = 0; i < d.S.RowCount; i++) { for (int j = 0; j < d.S.ColumnCount; j++) { Assert.AreEqual(matrix[i, j], d.S[i, j]); } } }
public void ValidateDensity(double nu, double density) { int order = 1; var matrix = new DenseMatrix(order); matrix[0, 0] = 1; var X = new DenseMatrix(order); X[0, 0] = 5; var d = new InverseWishart(nu, matrix); AssertHelpers.AlmostEqual(density, d.Density(X), 16); }
public void ValidateVariance([Values(0.1, 1.0, 5.0)] double nu, [Values(2, 5)] int order) { var d = new InverseWishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order)); var variance = d.Variance; for (var i = 0; i < d.S.RowCount; i++) { for (var j = 0; j < d.S.ColumnCount; j++) { var num1 = ((nu - d.S.RowCount + 1) * d.S[i, j] * d.S[i, j]) + ((nu - d.S.RowCount - 1) * d.S[i, i] * d.S[j, j]); var num2 = (nu - d.S.RowCount) * (nu - d.S.RowCount - 1) * (nu - d.S.RowCount - 1) * (nu - d.S.RowCount - 3); Assert.AreEqual(num1 / num2, variance[i, j]); } } }
public void ValidateVariance(double nu, int order) { var d = new InverseWishart(nu, Matrix <double> .Build.RandomPositiveDefinite(order, 1)); var variance = d.Variance; for (var i = 0; i < d.Scale.RowCount; i++) { for (var j = 0; j < d.Scale.ColumnCount; j++) { var num1 = ((nu - d.Scale.RowCount + 1) * d.Scale[i, j] * d.Scale[i, j]) + ((nu - d.Scale.RowCount - 1) * d.Scale[i, i] * d.Scale[j, j]); var num2 = (nu - d.Scale.RowCount) * (nu - d.Scale.RowCount - 1) * (nu - d.Scale.RowCount - 1) * (nu - d.Scale.RowCount - 3); Assert.AreEqual(num1 / num2, variance[i, j]); } } }
public void CanGetNu([Values(1.0, 2.0, 5.0)] double nu) { var d = new InverseWishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)); Assert.AreEqual(nu, d.Nu); }
public void FailSetRandomSourceWithNullReference() { var d = new InverseWishart(1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)); d.RandomSource = null; }
public void CanGetNu(double nu) { var d = new InverseWishart(nu, Matrix <double> .Build.RandomPositiveDefinite(2, 1)); Assert.AreEqual(nu, d.DegreesOfFreedom); }
public void CanGetS() { int order = 2; var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); var d = new InverseWishart(1.0, matrix); for (int i = 0; i < order; i++) { for (int j = 0; j < order; j++) { Assert.AreEqual<double>(matrix[i, j], d.S[i, j]); } } }
public void CanSampleStatic() { InverseWishart.Sample(new Random(), 1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)); }
public void CanSample() { var d = new InverseWishart(1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)); d.Sample(); }
public void CanSetRandomSource() { var d = new InverseWishart(1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)); d.RandomSource = new Random(); }
public void CanSampleStatic() { InverseWishart.Sample(new System.Random(0), 1.0, Matrix <double> .Build.RandomPositiveDefinite(2, 1)); }
public void ValidateToString() { var d = new InverseWishart(1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)); Assert.AreEqual("InverseWishart(Nu = 1, Rows = 2, Columns = 2)", d.ToString()); }
public void FailSampleStatic() { Assert.Throws <ArgumentOutOfRangeException>(() => InverseWishart.Sample(new Random(), -1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2))); }
public void CanGetNu(double nu) { var d = new InverseWishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)); Assert.AreEqual(nu, d.DegreesOfFreedom); }
public void HasRandomSource() { var d = new InverseWishart(1.0, Matrix <double> .Build.RandomPositiveDefinite(2, 1)); Assert.IsNotNull(d.RandomSource); }
public void ValidateToString() { var d = new InverseWishart(1d, Matrix <double> .Build.RandomPositiveDefinite(2, 1)); Assert.AreEqual("InverseWishart(ν = 1, Rows = 2, Columns = 2)", d.ToString()); }
public void FailSetRandomSourceWithNullReference() { var d = new InverseWishart(1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)); Assert.Throws<ArgumentNullException>(() => d.RandomSource = null); }
public void HasRandomSource() { var d = new InverseWishart(1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)); Assert.IsNotNull(d.RandomSource); }
public void CanSample() { var d = new InverseWishart(1.0, Matrix <double> .Build.RandomPositiveDefinite(2, 1)); d.Sample(); }
public void FailSampleStatic() { Assert.That(() => InverseWishart.Sample(new System.Random(0), -1.0, Matrix <double> .Build.RandomPositiveDefinite(2, 1)), Throws.ArgumentException); }
public void CanSetNu(double nu) { var d = new InverseWishart(1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)); d.Nu = nu; }