use of org.ojalgo.random.Normal1D in project ojAlgo by optimatika.
the class GaussianProcess method getDistribution.
public Normal getDistribution(final double evaluationPoint) {
final Normal1D tmpVal = this.getDistribution(new Double[] { evaluationPoint });
final double tmpLocation = tmpVal.getExpected().doubleValue(0);
final double tmpScale = tmpVal.getStandardDeviation().doubleValue(0);
return new Normal(tmpLocation, tmpScale);
}
use of org.ojalgo.random.Normal1D in project ojAlgo by optimatika.
the class GaussianField method getDistribution.
public Normal1D getDistribution(final boolean cleanCovariances, final K... evaluationPoint) {
final MatrixStore<Double> tmpRegCoef = this.getRegressionCoefficients(evaluationPoint);
final MatrixStore<Double> tmpM1 = this.getM1(evaluationPoint);
final MatrixStore<Double> tmpM2differenses = this.getM2differenses();
final PrimitiveDenseStore tmpLocations = FACTORY.makeZero(tmpM1.countRows(), tmpM1.countColumns());
tmpLocations.fillMatching(tmpM1, ADD, tmpRegCoef.multiply(tmpM2differenses));
final MatrixStore<Double> tmpC11 = this.getC11(evaluationPoint);
final MatrixStore<Double> tmpC21 = this.getC21(evaluationPoint);
final PrimitiveDenseStore tmpCovariances = FACTORY.makeZero(tmpC11.countRows(), tmpC11.countColumns());
tmpCovariances.fillMatching(tmpC11, SUBTRACT, tmpRegCoef.multiply(tmpC21));
if (cleanCovariances) {
final Eigenvalue<Double> tmpEvD = Eigenvalue.PRIMITIVE.make(true);
tmpEvD.decompose(tmpCovariances);
final MatrixStore<Double> tmpV = tmpEvD.getV();
final PhysicalStore<Double> tmpD = tmpEvD.getD().copy();
final double tmpLargest = tmpD.doubleValue(0, 0);
final double tmpLimit = PrimitiveFunction.MAX.invoke(PrimitiveMath.MACHINE_EPSILON * tmpLargest, 1E-12);
final int tmpLength = (int) Math.min(tmpD.countRows(), tmpD.countColumns());
for (int ij = 0; ij < tmpLength; ij++) {
if (tmpD.doubleValue(ij, ij) < tmpLimit) {
tmpD.set(ij, ij, tmpLimit);
}
}
tmpCovariances.fillMatching(tmpV.multiply(tmpD).multiply(tmpV.logical().transpose().get()));
}
return new Normal1D(tmpLocations, tmpCovariances);
}
Aggregations