Java Code Examples for org.apache.commons.math3.util.MathArrays#distance()

The following examples show how to use org.apache.commons.math3.util.MathArrays#distance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LearnReadOrientationModelEngine.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public ArtifactPrior learnPriorForArtifactStates() {
    // Initialize the prior for artifact
    final double[] pseudocounts = getFlatPrior(refAllele);
    double[] statePrior = Arrays.copyOf(pseudocounts, F1R2FilterConstants.NUM_STATES);
    double l2Distance;

    do {
        final double[] oldStatePrior = Arrays.copyOf(statePrior, F1R2FilterConstants.NUM_STATES);

        // Responsibilities are updated by side effect to save space
        takeEstep(statePrior);
        statePrior = takeMstep(pseudocounts);

        // TODO: make sure EM increases the likelihood
        // newLikelihood >= oldLikelihood : "M step must increase the likelihood";
        l2Distance = MathArrays.distance(oldStatePrior, statePrior);

        numIterations.increment();
    } while (l2Distance > convergenceThreshold && numIterations.intValue() < maxEMIterations);

    if (numIterations.intValue() == maxEMIterations){
        logger.info(String.format("Context %s: with %s ref and %s alt examples, EM failed to converge within %d steps",
                referenceContext, numRefExamples, numAltExamples, maxEMIterations));
    } else {
        logger.info(String.format("Context %s: with %s ref and %s alt examples, EM converged in %d steps",
                referenceContext, numRefExamples, numAltExamples, numIterations.intValue()));
    }

    return new ArtifactPrior(referenceContext, statePrior, numExamples, numAltExamples);
}
 
Example 2
Source File: EuclideanDoublePoint.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double distanceFrom(final EuclideanDoublePoint p) {
    return MathArrays.distance(point, p.getPoint());
}
 
Example 3
Source File: EuclideanIntegerPoint.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double distanceFrom(final EuclideanIntegerPoint p) {
    return MathArrays.distance(point, p.getPoint());
}
 
Example 4
Source File: EuclideanDoublePoint.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double distanceFrom(final EuclideanDoublePoint p) {
    return MathArrays.distance(point, p.getPoint());
}
 
Example 5
Source File: EuclideanDistance.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double compute(double[] a, double[] b) {
    return MathArrays.distance(a, b);
}
 
Example 6
Source File: EuclideanIntegerPoint.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double distanceFrom(final EuclideanIntegerPoint p) {
    return MathArrays.distance(point, p.getPoint());
}
 
Example 7
Source File: EuclideanDoublePoint.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double distanceFrom(final EuclideanDoublePoint p) {
    return MathArrays.distance(point, p.getPoint());
}
 
Example 8
Source File: EuclideanDistance.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double compute(double[] a, double[] b) {
    return MathArrays.distance(a, b);
}
 
Example 9
Source File: EuclideanIntegerPoint.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double distanceFrom(final EuclideanIntegerPoint p) {
    return MathArrays.distance(point, p.getPoint());
}
 
Example 10
Source File: EuclideanDistance.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double compute(double[] a, double[] b) {
    return MathArrays.distance(a, b);
}
 
Example 11
Source File: EuclideanIntegerPoint.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double distanceFrom(final EuclideanIntegerPoint p) {
    return MathArrays.distance(point, p.getPoint());
}
 
Example 12
Source File: EuclideanIntegerPoint.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double distanceFrom(final EuclideanIntegerPoint p) {
    return MathArrays.distance(point, p.getPoint());
}
 
Example 13
Source File: EuclideanDoublePoint.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double distanceFrom(final EuclideanDoublePoint p) {
    return MathArrays.distance(point, p.getPoint());
}
 
Example 14
Source File: EuclideanDistance.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double compute(double[] a, double[] b) {
    return MathArrays.distance(a, b);
}
 
Example 15
Source File: EuclideanIntegerPoint.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double distanceFrom(final EuclideanIntegerPoint p) {
    return MathArrays.distance(point, p.getPoint());
}
 
Example 16
Source File: EuclideanIntegerPoint.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double distanceFrom(final EuclideanIntegerPoint p) {
    return MathArrays.distance(point, p.getPoint());
}
 
Example 17
Source File: EuclideanIntegerPoint.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double distanceFrom(final EuclideanIntegerPoint p) {
    return MathArrays.distance(point, p.getPoint());
}
 
Example 18
Source File: EuclideanDoublePoint.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double distanceFrom(final EuclideanDoublePoint p) {
    return MathArrays.distance(point, p.getPoint());
}