Search in sources :

Example 1 with Normal1D

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);
}
Also used : Normal(org.ojalgo.random.Normal) Normal1D(org.ojalgo.random.Normal1D)

Example 2 with Normal1D

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);
}
Also used : ComparableToDouble(org.ojalgo.type.keyvalue.ComparableToDouble) PrimitiveDenseStore(org.ojalgo.matrix.store.PrimitiveDenseStore) Normal1D(org.ojalgo.random.Normal1D)

Aggregations

Normal1D (org.ojalgo.random.Normal1D)2 PrimitiveDenseStore (org.ojalgo.matrix.store.PrimitiveDenseStore)1 Normal (org.ojalgo.random.Normal)1 ComparableToDouble (org.ojalgo.type.keyvalue.ComparableToDouble)1