From aeff4183d5c072e5cb85a45f077c1a0ca988dfad Mon Sep 17 00:00:00 2001 From: Evelina Gabasova Date: Sat, 6 Sep 2014 12:42:41 +0100 Subject: [PATCH 1/2] Bug fix in MatrixNormal density with unit test for non-square matrices --- src/Numerics/Distributions/MatrixNormal.cs | 4 +-- .../Multivariate/MatrixNormalTests.cs | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/Numerics/Distributions/MatrixNormal.cs b/src/Numerics/Distributions/MatrixNormal.cs index 0884d611..c014d7d4 100644 --- a/src/Numerics/Distributions/MatrixNormal.cs +++ b/src/Numerics/Distributions/MatrixNormal.cs @@ -207,8 +207,8 @@ namespace MathNet.Numerics.Distributions return Math.Exp(-0.5*cholK.Solve(a.Transpose()*cholV.Solve(a)).Trace()) /Math.Pow(2.0*Constants.Pi, x.RowCount*x.ColumnCount/2.0) - /Math.Pow(cholV.Determinant, x.RowCount/2.0) - /Math.Pow(cholK.Determinant, x.ColumnCount/2.0); + /Math.Pow(cholK.Determinant, x.RowCount/2.0) + /Math.Pow(cholV.Determinant, x.ColumnCount/2.0); } /// diff --git a/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs b/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs index 747ac91b..f924d3bb 100644 --- a/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs +++ b/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs @@ -250,6 +250,36 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate AssertHelpers.AlmostEqualRelative(0.00015682927366491211, d.Density(x), 16); } + /// + /// Validate density with non-square matrices. + /// + [Test] + public void ValidateNonsquareDensity() + { + const int Rows = 2; + const int Cols = 1; + var m = Matrix.Build.Dense(Rows, Cols); + m[0, 0] = 0.156065579983862; + m[1, 0] = -0.806288628097313; + + var v = Matrix.Build.Dense(Rows, Rows); + v[0, 0] = 0.674457817054746; + v[0, 1] = 0.878930403442185; + v[1, 0] = 0.878930403442185; + v[1, 1] = 1.76277498368061; + + var k = Matrix.Build.Dense(Cols, Cols); + k[0, 0] = 0.674457817054746; + + var d = new MatrixNormal(m, v, k); + + var x = Matrix.Build.Dense(Rows, Cols); + x[0, 0] = 2; + x[1, 0] = 1.5; + + AssertHelpers.AlmostEqualRelative(0.008613384131384546, d.Density(x), 12); + } + /// /// Can sample. /// From 84cc4a911d7e8c23fa37b780dbcc551fb2048311 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Sat, 6 Sep 2014 14:48:19 +0200 Subject: [PATCH 2/2] Release v3.2.3 --- CONTRIBUTORS.md | 1 + RELEASENOTES.md | 5 ++++- src/FSharp/AssemblyInfo.fs | 6 +++--- src/FSharpUnitTests/AssemblyInfo.fs | 6 +++--- src/Numerics/Properties/AssemblyInfo.cs | 6 +++--- src/UnitTests/Properties/AssemblyInfo.cs | 6 +++--- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 18260942..12f5b7e1 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -37,6 +37,7 @@ Feel free to add a link to your personal site/blog and/or twitter handle.* - Robin Neatherway - Andrew Kazyrevich - Ethar Alali +- Evelina Gabasova - Feodor Fitsner - Iain McDonald - Gregor959 diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 08d41454..38dd91e0 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,4 +1,7 @@ -### 3.2.2 - 3014-09-05 +### 3.2.3 - 2014-09-06 +* Bug fix: MatrixNormal distribution: density for non-square matrices *~Evelina Gabasova* + +### 3.2.2 - 2014-09-05 * Bug fix: MatrixNormal distribution: density computation switched row and column covariance *~Evelina Gabasova* ### 3.2.1 - 2014-08-05 diff --git a/src/FSharp/AssemblyInfo.fs b/src/FSharp/AssemblyInfo.fs index fc0d5105..9ef9ac46 100644 --- a/src/FSharp/AssemblyInfo.fs +++ b/src/FSharp/AssemblyInfo.fs @@ -45,9 +45,9 @@ open System.Runtime.InteropServices [] [] -[] -[] -[] +[] +[] +[] #if PORTABLE #else diff --git a/src/FSharpUnitTests/AssemblyInfo.fs b/src/FSharpUnitTests/AssemblyInfo.fs index c9a295ed..a9000444 100644 --- a/src/FSharpUnitTests/AssemblyInfo.fs +++ b/src/FSharpUnitTests/AssemblyInfo.fs @@ -10,9 +10,9 @@ open System.Runtime.InteropServices [] [] -[] -[] -[] +[] +[] +[] #if PORTABLE #else diff --git a/src/Numerics/Properties/AssemblyInfo.cs b/src/Numerics/Properties/AssemblyInfo.cs index 3bf34c78..803a55a9 100644 --- a/src/Numerics/Properties/AssemblyInfo.cs +++ b/src/Numerics/Properties/AssemblyInfo.cs @@ -45,9 +45,9 @@ using System.Runtime.InteropServices; [assembly: CLSCompliant(true)] [assembly: NeutralResourcesLanguage("en")] -[assembly: AssemblyVersion("3.2.2.0")] -[assembly: AssemblyFileVersion("3.2.2.0")] -[assembly: AssemblyInformationalVersion("3.2.2")] +[assembly: AssemblyVersion("3.2.3.0")] +[assembly: AssemblyFileVersion("3.2.3.0")] +[assembly: AssemblyInformationalVersion("3.2.3")] #if PORTABLE diff --git a/src/UnitTests/Properties/AssemblyInfo.cs b/src/UnitTests/Properties/AssemblyInfo.cs index 48444453..70a86bce 100644 --- a/src/UnitTests/Properties/AssemblyInfo.cs +++ b/src/UnitTests/Properties/AssemblyInfo.cs @@ -9,8 +9,8 @@ using MathNet.Numerics.UnitTests; [assembly: ComVisible(false)] [assembly: Guid("04157581-63f3-447b-a277-83c6e69126a4")] -[assembly: AssemblyVersion("3.2.2.0")] -[assembly: AssemblyFileVersion("3.2.2.0")] -[assembly: AssemblyInformationalVersion("3.2.2")] +[assembly: AssemblyVersion("3.2.3.0")] +[assembly: AssemblyFileVersion("3.2.3.0")] +[assembly: AssemblyInformationalVersion("3.2.3")] [assembly: UseLinearAlgebraProvider]