/** * Gets the covariance matrix of the Gaussian. * * @return The covariance matrix of the Gaussian. */ public Matrix getCovariance() { if (this.covariance == null) { this.covariance = this.covarianceInverse.inverse(); } return this.covariance; }
/** * Gets the covariance matrix of the Gaussian. * * @return The covariance matrix of the Gaussian. */ public Matrix getCovariance() { if (this.covariance == null) { this.covariance = this.covarianceInverse.inverse(); } return this.covariance; }
/** * Gets the inverse of the covariance matrix. * * @return The inverse of the covariance matrix. */ public Matrix getCovarianceInverse() { // Need to recompute the covariance inverse. if (this.covarianceInverse == null) { this.covarianceInverse = this.covariance.inverse(); } return this.covarianceInverse; }
/** * Gets the inverse of the covariance matrix. * * @return The inverse of the covariance matrix. */ public Matrix getCovarianceInverse() { // Need to recompute the covariance inverse. if (this.covarianceInverse == null) { this.covarianceInverse = this.covariance.inverse(); } return this.covarianceInverse; }
/** * Gets the inverse of the covariance matrix. * * @return The inverse of the covariance matrix. */ public Matrix getCovarianceInverse() { // Need to recompute the covariance inverse. if (this.covarianceInverse == null) { this.covarianceInverse = this.covariance.inverse(); } return this.covarianceInverse; }
/** * Gets the covariance matrix of the Gaussian. * * @return The covariance matrix of the Gaussian. */ public Matrix getCovariance() { if (this.covariance == null) { this.covariance = this.covarianceInverse.inverse(); } return this.covariance; }
/** * Computes the mean of the Gaussian, but involves a matrix * inversion and multiplication, so it's expensive. * @return * Mean of the Gaussian. */ public Vector getMean() { return this.covarianceInverse.inverse().times( this.z ); }
/** * Computes the mean of the Gaussian, but involves a matrix * inversion and multiplication, so it's expensive. * @return * Mean of the Gaussian. */ public Vector getMean() { return this.covarianceInverse.inverse().times( this.z ); }
/** * Computes the mean of the Gaussian, but involves a matrix * inversion and multiplication, so it's expensive. * @return * Mean of the Gaussian. */ public Vector getMean() { return this.covarianceInverse.inverse().times( this.z ); }
/** * Computes the mean of the Gaussian, but involves a matrix * inversion and multiplication, so it's expensive. * @return * Mean of the Gaussian. */ public Vector getMean() { return this.covarianceInverse.inverse().times( this.z ); }
/** * Computes the mean of the Gaussian, but involves a matrix * inversion and multiplication, so it's expensive. * @return * Mean of the Gaussian. */ public Vector getMean() { return this.covarianceInverse.inverse().times( this.z ); }
/** * Computes the mean of the Gaussian, but involves a matrix * inversion and multiplication, so it's expensive. * @return * Mean of the Gaussian. */ public Vector getMean() { return this.covarianceInverse.inverse().times( this.z ); }
/** * Computes the covariance of the distribution, which involves inverting * the precision matrix. * @return * covariance of the distribution, which involves inverting the * precision matrix. */ public Matrix getCovariance() { final double scale = this.degreesOfFreedom / (this.degreesOfFreedom-2.0); Matrix C = this.getPrecision().inverse(); C.scaleEquals(scale); return C; }
/** * Computes the covariance of the distribution, which involves inverting * the precision matrix. * @return * covariance of the distribution, which involves inverting the * precision matrix. */ public Matrix getCovariance() { final double scale = this.degreesOfFreedom / (this.degreesOfFreedom-2.0); Matrix C = this.getPrecision().inverse(); C.scaleEquals(scale); return C; }
/** * Computes the covariance of the distribution, which involves inverting * the precision matrix. * @return * covariance of the distribution, which involves inverting the * precision matrix. */ public Matrix getCovariance() { final double scale = this.degreesOfFreedom / (this.degreesOfFreedom-2.0); Matrix C = this.getPrecision().inverse(); C.scaleEquals(scale); return C; }
@Override public double logEvaluate( final Matrix input) { final int m = this.getDegreesOfFreedom(); final int p = this.getInputDimensionality(); double logSum = 0.0; logSum += (m/2.0) * this.inverseScale.logDeterminant().getRealPart(); logSum -= ((m+p+1.0)/2.0) * input.logDeterminant().getRealPart(); logSum -= this.inverseScale.times( input.inverse() ).trace() / 2.0; logSum -= (m*p/2.0)*LOG_OF_2; logSum -= MultivariateGammaFunction.logEvaluate(m/2.0, p); return logSum; }
@Override public double logEvaluate( final Matrix input) { final int m = this.getDegreesOfFreedom(); final int p = this.getInputDimensionality(); double logSum = 0.0; logSum += (m/2.0) * this.inverseScale.logDeterminant().getRealPart(); logSum -= ((m+p+1.0)/2.0) * input.logDeterminant().getRealPart(); logSum -= this.inverseScale.times( input.inverse() ).trace() / 2.0; logSum -= (m*p/2.0)*LOG_OF_2; logSum -= MultivariateGammaFunction.logEvaluate(m/2.0, p); return logSum; }
public MultivariateStudentTDistribution createPredictiveDistribution( NormalInverseWishartDistribution posterior) { Vector mean = posterior.getGaussian().getMean(); double dofs = posterior.getInverseWishart().getDegreesOfFreedom() - posterior.getInverseWishart().getInputDimensionality() + 1.0; Matrix covariance = posterior.getInverseWishart().getInverseScale().scale( (posterior.getCovarianceDivisor()+1.0) / (posterior.getCovarianceDivisor()*dofs) ); Matrix precision = covariance.inverse(); return new MultivariateStudentTDistribution( dofs, mean, precision ); }
public MultivariateStudentTDistribution createPredictiveDistribution( NormalInverseWishartDistribution posterior) { Vector mean = posterior.getGaussian().getMean(); double dofs = posterior.getInverseWishart().getDegreesOfFreedom() - posterior.getInverseWishart().getInputDimensionality() + 1.0; Matrix covariance = posterior.getInverseWishart().getInverseScale().scale( (posterior.getCovarianceDivisor()+1.0) / (posterior.getCovarianceDivisor()*dofs) ); Matrix precision = covariance.inverse(); return new MultivariateStudentTDistribution( dofs, mean, precision ); }
public MultivariateStudentTDistribution createPredictiveDistribution( NormalInverseWishartDistribution posterior) { Vector mean = posterior.getGaussian().getMean(); double dofs = posterior.getInverseWishart().getDegreesOfFreedom() - posterior.getInverseWishart().getInputDimensionality() + 1.0; Matrix covariance = posterior.getInverseWishart().getInverseScale().scale( (posterior.getCovarianceDivisor()+1.0) / (posterior.getCovarianceDivisor()*dofs) ); Matrix precision = covariance.inverse(); return new MultivariateStudentTDistribution( dofs, mean, precision ); }