/** * Return A^(T) * input. * * @param input The vector to multiply by the transpose of A * @return A^(T) * input */ public Vector transposeMult(Vector input) { // NOTE: This computes A^(T)x by the following: // return (x^(T)A)^(T) // But as we don't have to transpose vectors in this code, it requires // no real transposes at all. return input.times(m); }
/** * Return A^(T) * input. * * @param input The vector to multiply by the transpose of A * @return A^(T) * input */ public Vector transposeMult(Vector input) { // NOTE: This computes A^(T)x by the following: // return (x^(T)A)^(T) // But as we don't have to transpose vectors in this code, it requires // no real transposes at all. return input.times(m); }
/** * Return A^(T) * input. * * @param input The vector to multiply by the transpose of A * @return A^(T) * input */ public Vector transposeMult(Vector input) { // NOTE: This computes A^(T)x by the following: // return (x^(T)A)^(T) // But as we don't have to transpose vectors in this code, it requires // no real transposes at all. return input.times(m); }
public Vector evaluate( final Vectorizable input) { // Apply the transform to the input vector. return input.convertToVector().times(this.transform); }
public Vector evaluate( final Vectorizable input) { // Apply the transform to the input vector. return input.convertToVector().times(this.transform); }
public Vector evaluate( final Vectorizable input) { // Apply the transform to the input vector. return input.convertToVector().times(this.transform); }
/** * Computes the scale component for the inverse-gamma distribution * @return * Scale component for the inverse-gamma distribution */ public double getScale() { Vector mean = this.getMean(); Matrix Ci = this.covarianceInverse; return 0.5 * (this.outputSumSquared - mean.times(Ci).dotProduct(mean)); }
/** * Computes the scale component for the inverse-gamma distribution * @return * Scale component for the inverse-gamma distribution */ public double getScale() { Vector mean = this.getMean(); Matrix Ci = this.covarianceInverse; return 0.5 * (this.outputSumSquared - mean.times(Ci).dotProduct(mean)); }
/** * Computes the scale component for the inverse-gamma distribution * @return * Scale component for the inverse-gamma distribution */ public double getScale() { Vector mean = this.getMean(); Matrix Ci = this.covarianceInverse; return 0.5 * (this.outputSumSquared - mean.times(Ci).dotProduct(mean)); }
/** * Normalizes the given double value by subtracting the mean and dividing * by the standard deviation (the square root of the variance). * * @param value The value to normalize. * @return The normalized value. */ public Vector evaluate( final Vectorizable value) { final Vector input = value.convertToVector(); return input.minus(this.getMean()).times( this.getCovarianceInverseSquareRoot()); }
/** * Normalizes the given double value by subtracting the mean and dividing * by the standard deviation (the square root of the variance). * * @param value The value to normalize. * @return The normalized value. */ public Vector evaluate( final Vectorizable value) { final Vector input = value.convertToVector(); return input.minus(this.getMean()).times( this.getCovarianceInverseSquareRoot()); }
/** * Normalizes the given double value by subtracting the mean and dividing * by the standard deviation (the square root of the variance). * * @param value The value to normalize. * @return The normalized value. */ public Vector evaluate( final Vectorizable value) { final Vector input = value.convertToVector(); return input.minus(this.getMean()).times( this.getCovarianceInverseSquareRoot()); }
public double logEvaluate( Vector input) { final int dim = this.getInputDimensionality(); final double logDet = this.getLogDeterminantPrecision(); final Vector delta = input.minus(this.mean); final double z2 = delta.times(this.getPrecision()).dotProduct(delta); final double d2pv2 = dim/2.0+this.degreesOfFreedom/2.0; double logSum = 0.0; logSum += MathUtil.logGammaFunction( d2pv2 ); logSum -= MathUtil.logGammaFunction( this.degreesOfFreedom/2.0 ); logSum += 0.5 * logDet; logSum -= (dim/2.0)*Math.log(Math.PI*this.degreesOfFreedom); logSum -= d2pv2*Math.log( 1.0 + z2/this.degreesOfFreedom ); return logSum; }
public double logEvaluate( Vector input) { final int dim = this.getInputDimensionality(); final double logDet = this.getLogDeterminantPrecision(); final Vector delta = input.minus(this.mean); final double z2 = delta.times(this.getPrecision()).dotProduct(delta); final double d2pv2 = dim/2.0+this.degreesOfFreedom/2.0; double logSum = 0.0; logSum += MathUtil.logGammaFunction( d2pv2 ); logSum -= MathUtil.logGammaFunction( this.degreesOfFreedom/2.0 ); logSum += 0.5 * logDet; logSum -= (dim/2.0)*Math.log(Math.PI*this.degreesOfFreedom); logSum -= d2pv2*Math.log( 1.0 + z2/this.degreesOfFreedom ); return logSum; }
@Override public UnivariateGaussian.PDF evaluate( Vectorizable input) { // Bishop's equations 3.58-3.59 Vector x = input.convertToVector(); double mean = x.dotProduct( this.posterior.getMean() ); double variance = x.times( this.posterior.getCovariance() ).dotProduct(x) + outputVariance; return new UnivariateGaussian.PDF( mean, variance ); }
@Override public UnivariateGaussian.PDF evaluate( Vectorizable input) { // Bishop's equations 3.58-3.59 Vector x = input.convertToVector(); double mean = x.dotProduct( this.posterior.getMean() ); double variance = x.times( this.posterior.getCovariance() ).dotProduct(x) + outputVariance; return new UnivariateGaussian.PDF( mean, variance ); }
@Override public UnivariateGaussian.PDF evaluate( Vectorizable input) { // Bishop's equations 3.58-3.59 Vector x = input.convertToVector(); double mean = x.dotProduct( this.posterior.getMean() ); double variance = x.times( this.posterior.getCovariance() ).dotProduct(x) + outputVariance; return new UnivariateGaussian.PDF( mean, variance ); }
@Override public StudentTDistribution evaluate( Vectorizable input) { Vector x = input.convertToVector(); double mean = x.dotProduct( this.posterior.getMean() ); double dofs = this.posterior.getInverseGamma().getShape() * 2.0; double v = x.times( this.posterior.getGaussian().getCovariance() ).dotProduct(x); double anbn = this.posterior.getInverseGamma().getShape() / this.posterior.getInverseGamma().getScale(); double precision = anbn / (1.0 + v); return new StudentTDistribution( dofs, mean, precision ); }
@Override public StudentTDistribution evaluate( Vectorizable input) { Vector x = input.convertToVector(); double mean = x.dotProduct( this.posterior.getMean() ); double dofs = this.posterior.getInverseGamma().getShape() * 2.0; double v = x.times( this.posterior.getGaussian().getCovariance() ).dotProduct(x); double anbn = this.posterior.getInverseGamma().getShape() / this.posterior.getInverseGamma().getScale(); double precision = anbn / (1.0 + v); return new StudentTDistribution( dofs, mean, precision ); }
@Override public StudentTDistribution evaluate( Vectorizable input) { Vector x = input.convertToVector(); double mean = x.dotProduct( this.posterior.getMean() ); double dofs = this.posterior.getInverseGamma().getShape() * 2.0; double v = x.times( this.posterior.getGaussian().getCovariance() ).dotProduct(x); double anbn = this.posterior.getInverseGamma().getShape() / this.posterior.getInverseGamma().getScale(); double precision = anbn / (1.0 + v); return new StudentTDistribution( dofs, mean, precision ); }