@Test public void testApply() { MultivariateGaussianDistribution distribution = new MultivariateGaussianDistribution( VectorUtils.of(1, 2), new DenseMatrix(new double[][] {new double[] {1, -0.5}, new double[] {-0.5, 1}}) ); Assert.assertEquals(0.183, distribution.prob(VectorUtils.of(1, 2)), 0.01); Assert.assertEquals(0.094, distribution.prob(VectorUtils.of(0, 2)), 0.01); }
@Override public double prob(Vector x) { Vector delta = x.minus(mean); Matrix ePower = delta.toMatrix(true) .times(invCovariance) .times(delta.toMatrix(false)) .times(-0.5); assert ePower.columnSize() == 1 && ePower.rowSize() == 1; return Math.pow(Math.E, ePower.get(0, 0)) / normalizer; }
MultivariateGaussianDistribution implements Distribution { @Override public double prob(Vector x) { Vector delta = x.minus(mean); Matrix ePower = delta.toMatrix(true) .times(invCovariance) .times(delta.toMatrix(false)) .times(-0.5); assert ePower.columnSize() == 1 && ePower.rowSize() == 1; return Math.pow(Math.E, ePower.get(0, 0)) / normalizer; } }
MultivariateGaussianDistribution implements Distribution { @Override public double prob(Vector x) { Vector delta = x.minus(mean); Matrix ePower = delta.toMatrix(true) .times(invCovariance) .times(delta.toMatrix(false)) .times(-0.5); assert ePower.columnSize() == 1 && ePower.rowSize() == 1; return Math.pow(Math.E, ePower.get(0, 0)) / normalizer; } MultivariateGaussianDistribution(Vector mean, Matrix covariance); }
MultivariateGaussianDistribution implements Distribution { @Override public double prob(Vector x) { Vector delta = x.minus(mean); Matrix ePower = delta.toMatrix(true) .times(invCovariance) .times(delta.toMatrix(false)) .times(-0.5); assert ePower.columnSize() == 1 && ePower.rowSize() == 1; return Math.pow(Math.E, ePower.get(0, 0)) / normalizer; } MultivariateGaussianDistribution(Vector mean, Matrix covariance); @Override double prob(Vector x); @Override int dimension(); Vector mean(); Matrix covariance(); }
MultivariateGaussianDistribution implements Distribution { @Override public double prob(Vector x) { Vector delta = x.minus(mean); Matrix ePower = delta.toMatrix(true) .times(invCovariance) .times(delta.toMatrix(false)) .times(-0.5); assert ePower.columnSize() == 1 && ePower.rowSize() == 1; return Math.pow(Math.E, ePower.get(0, 0)) / normalizer; } MultivariateGaussianDistribution(Vector mean, Matrix covariance); @Override double prob(Vector x); @Override int dimension(); Vector mean(); Matrix covariance();  }