@Test public void testCdf() { System.out.println("cdf"); MultivariateGaussianDistribution instance = new MultivariateGaussianDistribution(mu, new Matrix(sigma)); for (int i = 0; i < x.length; i++) { assertEquals(cdf[i], instance.cdf(x[i]), 1E-2); } }
@Override public double cdf(double[] x) { if (x.length != dim) { throw new IllegalArgumentException("Sample has different dimension."); } int Nmax = 10000; double alph = GaussianDistribution.getInstance().quantile(0.999); double errMax = 0.001; double[] v = x.clone(); MathEx.sub(v, mu); double p = 0.0; double varSum = 0.0; double[] e = new double[dim]; double[] f = new double[dim]; e[0] = GaussianDistribution.getInstance().cdf(v[0] / sigmaL.get(0, 0)); f[0] = e[0]; double[] y = new double[dim]; double err = 2 * errMax; int N; for (N = 1; err > errMax && N <= Nmax; N++) { double[] w = MathEx.random(dim - 1); for (int i = 1; i < dim; i++) { y[i - 1] = GaussianDistribution.getInstance().quantile(w[i - 1] * e[i - 1]); double q = 0.0; for (int j = 0; j < i; j++) { q += sigmaL.get(i, j) * y[j]; } e[i] = GaussianDistribution.getInstance().cdf((v[i] - q) / sigmaL.get(i, i)); f[i] = e[i] * f[i - 1]; } double del = (f[dim - 1] - p) / N; p += del; varSum = (N - 2) * varSum / N + del * del; err = alph * Math.sqrt(varSum); } return p; }
MultivariateGaussianDistribution implements MultivariateDistribution, MultivariateExponentialFamily { @Override public double cdf(double[] x) { if (x.length != dim) { throw new IllegalArgumentException("Sample has different dimension."); } int Nmax = 10000; double alph = GaussianDistribution.getInstance().quantile(0.999); double errMax = 0.001; double[] v = x.clone(); MathEx.sub(v, mu); double p = 0.0; double varSum = 0.0; double[] e = new double[dim]; double[] f = new double[dim]; e[0] = GaussianDistribution.getInstance().cdf(v[0] / sigmaL.get(0, 0)); f[0] = e[0]; double[] y = new double[dim]; double err = 2 * errMax; int N; for (N = 1; err > errMax && N <= Nmax; N++) { double[] w = MathEx.random(dim - 1); for (int i = 1; i < dim; i++) { y[i - 1] = GaussianDistribution.getInstance().quantile(w[i - 1] * e[i - 1]); double q = 0.0; for (int j = 0; j < i; j++) { q += sigmaL.get(i, j) * y[j]; } e[i] = GaussianDistribution.getInstance().cdf((v[i] - q) / sigmaL.get(i, i)); f[i] = e[i] * f[i - 1]; } double del = (f[dim - 1] - p) / N; p += del; varSum = (N - 2) * varSum / N + del * del; err = alph * Math.sqrt(varSum); } return p; } }
MultivariateGaussianDistribution implements MultivariateDistribution, MultivariateExponentialFamily { @Override public double cdf(double[] x) { if (x.length != dim) { throw new IllegalArgumentException("Sample has different dimension."); } int Nmax = 10000; double alph = GaussianDistribution.getInstance().quantile(0.999); double errMax = 0.001; double[] v = x.clone(); MathEx.sub(v, mu); double p = 0.0; double varSum = 0.0; double[] e = new double[dim]; double[] f = new double[dim]; e[0] = GaussianDistribution.getInstance().cdf(v[0] / sigmaL.get(0, 0)); f[0] = e[0]; double[] y = new double[dim]; double err = 2 * errMax; int N; for (N = 1; err > errMax && N <= Nmax; N++) { double[] w = MathEx.random(dim - 1); for (int i = 1; i < dim; i++) { y[i - 1] = GaussianDistribution.getInstance().quantile(w[i - 1] * e[i - 1]); double q = 0.0; for (int j = 0; j < i; j++) { q += sigmaL.get(i, j) * y[j]; } e[i] = GaussianDistribution.getInstance().cdf((v[i] - q) / sigmaL.get(i, i)); f[i] = e[i] * f[i - 1]; } double del = (f[dim - 1] - p) / N; p += del; varSum = (N - 2) * varSum / N + del * del; err = alph * Math.sqrt(varSum); } return p; } MultivariateGaussianDistribution(double[] mean, double variance);  MultivariateGaussianDistribution(double[] mean, double[] variance);  MultivariateGaussianDistribution(double[] mean, Matrix cov); }
MultivariateGaussianDistribution implements MultivariateDistribution, MultivariateExponentialFamily { @Override public double cdf(double[] x) { if (x.length != dim) { throw new IllegalArgumentException("Sample has different dimension."); } int Nmax = 10000; double alph = GaussianDistribution.getInstance().quantile(0.999); double errMax = 0.001; double[] v = x.clone(); MathEx.sub(v, mu); double p = 0.0; double varSum = 0.0; double[] e = new double[dim]; double[] f = new double[dim]; e[0] = GaussianDistribution.getInstance().cdf(v[0] / sigmaL.get(0, 0)); f[0] = e[0]; double[] y = new double[dim]; double err = 2 * errMax; int N; for (N = 1; err > errMax && N <= Nmax; N++) { double[] w = MathEx.random(dim - 1); for (int i = 1; i < dim; i++) { y[i - 1] = GaussianDistribution.getInstance().quantile(w[i - 1] * e[i - 1]); double q = 0.0; for (int j = 0; j < i; j++) { q += sigmaL.get(i, j) * y[j]; } e[i] = GaussianDistribution.getInstance().cdf((v[i] - q) / sigmaL.get(i, i)); f[i] = e[i] * f[i - 1]; } double del = (f[dim - 1] - p) / N; p += del; varSum = (N - 2) * varSum / N + del * del; err = alph * Math.sqrt(varSum); } return p; } MultivariateGaussianDistribution(double[] mean, double variance);  MultivariateGaussianDistribution(double[] mean, double[] variance);  MultivariateGaussianDistribution(double[] mean, Matrix cov); static MultivariateGaussianDistribution fit(double[][] data); static MultivariateGaussianDistribution fit(double[][] data, boolean diagonal); @Override int length(); @Override double entropy(); @Override double[] mean(); @Override Matrix cov(); double scatter(); @Override double logp(double[] x); @Override double p(double[] x); @Override double cdf(double[] x); double[] rand(); double[][] rand(int n); @Override MultivariateMixture.Component M(double[][] data, double[] posteriori); @Override String toString(); }
MultivariateGaussianDistribution implements MultivariateDistribution, MultivariateExponentialFamily { @Override public double cdf(double[] x) { if (x.length != dim) { throw new IllegalArgumentException("Sample has different dimension."); } int Nmax = 10000; double alph = GaussianDistribution.getInstance().quantile(0.999); double errMax = 0.001; double[] v = x.clone(); MathEx.sub(v, mu); double p = 0.0; double varSum = 0.0; double[] e = new double[dim]; double[] f = new double[dim]; e[0] = GaussianDistribution.getInstance().cdf(v[0] / sigmaL.get(0, 0)); f[0] = e[0]; double[] y = new double[dim]; double err = 2 * errMax; int N; for (N = 1; err > errMax && N <= Nmax; N++) { double[] w = MathEx.random(dim - 1); for (int i = 1; i < dim; i++) { y[i - 1] = GaussianDistribution.getInstance().quantile(w[i - 1] * e[i - 1]); double q = 0.0; for (int j = 0; j < i; j++) { q += sigmaL.get(i, j) * y[j]; } e[i] = GaussianDistribution.getInstance().cdf((v[i] - q) / sigmaL.get(i, i)); f[i] = e[i] * f[i - 1]; } double del = (f[dim - 1] - p) / N; p += del; varSum = (N - 2) * varSum / N + del * del; err = alph * Math.sqrt(varSum); } return p; } MultivariateGaussianDistribution(double[] mean, double variance);  MultivariateGaussianDistribution(double[] mean, double[] variance);  MultivariateGaussianDistribution(double[] mean, Matrix cov); static MultivariateGaussianDistribution fit(double[][] data); static MultivariateGaussianDistribution fit(double[][] data, boolean diagonal); @Override int length(); @Override double entropy(); @Override double[] mean(); @Override Matrix cov(); double scatter(); @Override double logp(double[] x); @Override double p(double[] x); @Override double cdf(double[] x); double[] rand(); double[][] rand(int n); @Override MultivariateMixture.Component M(double[][] data, double[] posteriori); @Override String toString(); final double[] mu; final Matrix sigma; final boolean diagonal; }