/** * Construct the Gaussian with the provided center and covariance * * @param mean * centre of the Gaussian * @param covar * covariance of the Gaussian */ public CachingMultivariateGaussian(Matrix mean, Matrix covar) { N = mean.getColumnDimension(); this.mean = mean; this.covar = covar; cacheValues(); }
/** * Construct the Gaussian with the zero mean and unit variance * * @param ndims * number of dimensions */ public CachingMultivariateGaussian(int ndims) { N = ndims; this.mean = new Matrix(1, N); this.covar = Matrix.identity(N, N); cacheValues(); }
/** * Estimate a multidimensional Gaussian from the data * * @param samples * the data * @return the Gaussian with the best fit to the data */ public static CachingMultivariateGaussian estimate(float[][] samples) { final int ndims = samples[0].length; final CachingMultivariateGaussian gauss = new CachingMultivariateGaussian(); gauss.N = ndims; final MeanAndCovariance res = new MeanAndCovariance(samples); gauss.mean = res.mean; gauss.covar = res.covar; gauss.cacheValues(); return gauss; }
/** * Estimate a multidimensional Gaussian from the data * * @param samples * the data * @return the Gaussian with the best fit to the data */ public static MultivariateGaussian estimate(double[][] samples) { final int ndims = samples[0].length; final CachingMultivariateGaussian gauss = new CachingMultivariateGaussian(); gauss.N = ndims; final MeanAndCovariance res = new MeanAndCovariance(samples); gauss.mean = res.mean; gauss.covar = res.covar; gauss.cacheValues(); return gauss; }