commons-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r959803 [21/32] - in /websites/production/commons/content/proper/commons-math: jacoco/ jacoco/org.apache.commons.math3.fraction/ jacoco/org.apache.commons.math3.genetics/ jacoco/org.apache.commons.math3.geometry.euclidean.threed/ jacoco/org...
Date Mon, 27 Jul 2015 19:42:10 GMT
Modified: websites/production/commons/content/proper/commons-math/jacoco/org.apache.commons.math3.stat.inference/KolmogorovSmirnovTest.java.html
==============================================================================
--- websites/production/commons/content/proper/commons-math/jacoco/org.apache.commons.math3.stat.inference/KolmogorovSmirnovTest.java.html (original)
+++ websites/production/commons/content/proper/commons-math/jacoco/org.apache.commons.math3.stat.inference/KolmogorovSmirnovTest.java.html Mon Jul 27 19:42:09 2015
@@ -21,6 +21,7 @@ import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.Iterator;
 
+import org.apache.commons.math3.util.Precision;
 import org.apache.commons.math3.distribution.RealDistribution;
 import org.apache.commons.math3.exception.InsufficientDataException;
 import org.apache.commons.math3.exception.MathArithmeticException;
@@ -143,18 +144,18 @@ public class KolmogorovSmirnovTest {
     /**
      * Construct a KolmogorovSmirnovTest instance with a default random data generator.
      */
-<span class="fc" id="L146">    public KolmogorovSmirnovTest() {</span>
-<span class="fc" id="L147">        rng = new Well19937c();</span>
-<span class="fc" id="L148">    }</span>
+<span class="fc" id="L147">    public KolmogorovSmirnovTest() {</span>
+<span class="fc" id="L148">        rng = new Well19937c();</span>
+<span class="fc" id="L149">    }</span>
 
     /**
      * Construct a KolmogorovSmirnovTest with the provided random data generator.
      *
      * @param rng random data generator used by {@link #monteCarloP(double, int, int, boolean, int)}
      */
-<span class="fc" id="L155">    public KolmogorovSmirnovTest(RandomGenerator rng) {</span>
-<span class="fc" id="L156">        this.rng = rng;</span>
-<span class="fc" id="L157">    }</span>
+<span class="fc" id="L156">    public KolmogorovSmirnovTest(RandomGenerator rng) {</span>
+<span class="fc" id="L157">        this.rng = rng;</span>
+<span class="fc" id="L158">    }</span>
 
     /**
      * Computes the &lt;i&gt;p-value&lt;/i&gt;, or &lt;i&gt;observed significance level&lt;/i&gt;, of a one-sample &lt;a
@@ -172,7 +173,7 @@ public class KolmogorovSmirnovTest {
      * @throws NullArgumentException if {@code data} is null
      */
     public double kolmogorovSmirnovTest(RealDistribution distribution, double[] data, boolean exact) {
-<span class="fc" id="L175">        return 1d - cdf(kolmogorovSmirnovStatistic(distribution, data), data.length, exact);</span>
+<span class="fc" id="L176">        return 1d - cdf(kolmogorovSmirnovStatistic(distribution, data), data.length, exact);</span>
     }
 
     /**
@@ -188,21 +189,21 @@ public class KolmogorovSmirnovTest {
      * @throws NullArgumentException if {@code data} is null
      */
     public double kolmogorovSmirnovStatistic(RealDistribution distribution, double[] data) {
-<span class="fc" id="L191">        checkArray(data);</span>
-<span class="fc" id="L192">        final int n = data.length;</span>
-<span class="fc" id="L193">        final double nd = n;</span>
-<span class="fc" id="L194">        final double[] dataCopy = new double[n];</span>
-<span class="fc" id="L195">        System.arraycopy(data, 0, dataCopy, 0, n);</span>
-<span class="fc" id="L196">        Arrays.sort(dataCopy);</span>
-<span class="fc" id="L197">        double d = 0d;</span>
-<span class="fc bfc" id="L198" title="All 2 branches covered.">        for (int i = 1; i &lt;= n; i++) {</span>
-<span class="fc" id="L199">            final double yi = distribution.cumulativeProbability(dataCopy[i - 1]);</span>
-<span class="fc" id="L200">            final double currD = FastMath.max(yi - (i - 1) / nd, i / nd - yi);</span>
-<span class="fc bfc" id="L201" title="All 2 branches covered.">            if (currD &gt; d) {</span>
-<span class="fc" id="L202">                d = currD;</span>
+<span class="fc" id="L192">        checkArray(data);</span>
+<span class="fc" id="L193">        final int n = data.length;</span>
+<span class="fc" id="L194">        final double nd = n;</span>
+<span class="fc" id="L195">        final double[] dataCopy = new double[n];</span>
+<span class="fc" id="L196">        System.arraycopy(data, 0, dataCopy, 0, n);</span>
+<span class="fc" id="L197">        Arrays.sort(dataCopy);</span>
+<span class="fc" id="L198">        double d = 0d;</span>
+<span class="fc bfc" id="L199" title="All 2 branches covered.">        for (int i = 1; i &lt;= n; i++) {</span>
+<span class="fc" id="L200">            final double yi = distribution.cumulativeProbability(dataCopy[i - 1]);</span>
+<span class="fc" id="L201">            final double currD = FastMath.max(yi - (i - 1) / nd, i / nd - yi);</span>
+<span class="fc bfc" id="L202" title="All 2 branches covered.">            if (currD &gt; d) {</span>
+<span class="fc" id="L203">                d = currD;</span>
             }
         }
-<span class="fc" id="L205">        return d;</span>
+<span class="fc" id="L206">        return d;</span>
     }
 
     /**
@@ -240,14 +241,14 @@ public class KolmogorovSmirnovTest {
      * @throws NullArgumentException if either {@code x} or {@code y} is null
      */
     public double kolmogorovSmirnovTest(double[] x, double[] y, boolean strict) {
-<span class="fc" id="L243">        final long lengthProduct = (long) x.length * y.length;</span>
-<span class="fc bfc" id="L244" title="All 2 branches covered.">        if (lengthProduct &lt; SMALL_SAMPLE_PRODUCT) {</span>
-<span class="fc" id="L245">            return exactP(kolmogorovSmirnovStatistic(x, y), x.length, y.length, strict);</span>
+<span class="fc" id="L244">        final long lengthProduct = (long) x.length * y.length;</span>
+<span class="fc bfc" id="L245" title="All 2 branches covered.">        if (lengthProduct &lt; SMALL_SAMPLE_PRODUCT) {</span>
+<span class="fc" id="L246">            return exactP(kolmogorovSmirnovStatistic(x, y), x.length, y.length, strict);</span>
         }
-<span class="pc bpc" id="L247" title="1 of 2 branches missed.">        if (lengthProduct &lt; LARGE_SAMPLE_PRODUCT) {</span>
-<span class="nc" id="L248">            return monteCarloP(kolmogorovSmirnovStatistic(x, y), x.length, y.length, strict, MONTE_CARLO_ITERATIONS);</span>
+<span class="pc bpc" id="L248" title="1 of 2 branches missed.">        if (lengthProduct &lt; LARGE_SAMPLE_PRODUCT) {</span>
+<span class="nc" id="L249">            return monteCarloP(kolmogorovSmirnovStatistic(x, y), x.length, y.length, strict, MONTE_CARLO_ITERATIONS);</span>
         }
-<span class="fc" id="L250">        return approximateP(kolmogorovSmirnovStatistic(x, y), x.length, y.length);</span>
+<span class="fc" id="L251">        return approximateP(kolmogorovSmirnovStatistic(x, y), x.length, y.length);</span>
     }
 
     /**
@@ -266,7 +267,7 @@ public class KolmogorovSmirnovTest {
      * @throws NullArgumentException if either {@code x} or {@code y} is null
      */
     public double kolmogorovSmirnovTest(double[] x, double[] y) {
-<span class="fc" id="L269">        return kolmogorovSmirnovTest(x, y, true);</span>
+<span class="fc" id="L270">        return kolmogorovSmirnovTest(x, y, true);</span>
     }
 
     /**
@@ -284,65 +285,37 @@ public class KolmogorovSmirnovTest {
      * @throws NullArgumentException if either {@code x} or {@code y} is null
      */
     public double kolmogorovSmirnovStatistic(double[] x, double[] y) {
-<span class="fc" id="L287">        checkArray(x);</span>
-<span class="fc" id="L288">        checkArray(y);</span>
+<span class="fc" id="L288">        checkArray(x);</span>
+<span class="fc" id="L289">        checkArray(y);</span>
         // Copy and sort the sample arrays
-<span class="fc" id="L290">        final double[] sx = MathArrays.copyOf(x);</span>
-<span class="fc" id="L291">        final double[] sy = MathArrays.copyOf(y);</span>
-<span class="fc" id="L292">        Arrays.sort(sx);</span>
-<span class="fc" id="L293">        Arrays.sort(sy);</span>
-<span class="fc" id="L294">        final int n = sx.length;</span>
-<span class="fc" id="L295">        final int m = sy.length;</span>
+<span class="fc" id="L291">        final double[] sx = MathArrays.copyOf(x);</span>
+<span class="fc" id="L292">        final double[] sy = MathArrays.copyOf(y);</span>
+<span class="fc" id="L293">        Arrays.sort(sx);</span>
+<span class="fc" id="L294">        Arrays.sort(sy);</span>
+<span class="fc" id="L295">        final int n = sx.length;</span>
+<span class="fc" id="L296">        final int m = sy.length;</span>
 
-        // Find the max difference between cdf_x and cdf_y
-<span class="fc" id="L298">        double supD = 0d;</span>
-        // First walk x points
-<span class="fc bfc" id="L300" title="All 2 branches covered.">        for (int i = 0; i &lt; n; i++) {</span>
-<span class="fc" id="L301">            final double x_i = sx[i];</span>
-            // ties can be safely ignored
-<span class="fc bfc" id="L303" title="All 4 branches covered.">            if (i &gt; 0 &amp;&amp; x_i == sx[i-1]) {</span>
-<span class="fc" id="L304">                continue;</span>
-            }
-<span class="fc" id="L306">            final double cdf_x = edf(x_i, sx);</span>
-<span class="fc" id="L307">            final double cdf_y = edf(x_i, sy);</span>
-<span class="fc" id="L308">            final double curD = FastMath.abs(cdf_x - cdf_y);</span>
-<span class="fc bfc" id="L309" title="All 2 branches covered.">            if (curD &gt; supD) {</span>
-<span class="fc" id="L310">                supD = curD;</span>
-            }
-        }
-        // Now look at y
-<span class="fc bfc" id="L314" title="All 2 branches covered.">        for (int i = 0; i &lt; m; i++) {</span>
-<span class="fc" id="L315">            final double y_i = sy[i];</span>
-            // ties can be safely ignored
-<span class="fc bfc" id="L317" title="All 4 branches covered.">            if (i &gt; 0 &amp;&amp; y_i == sy[i-1]) {</span>
-<span class="fc" id="L318">                continue;</span>
-            }
-<span class="fc" id="L320">            final double cdf_x = edf(y_i, sx);</span>
-<span class="fc" id="L321">            final double cdf_y = edf(y_i, sy);</span>
-<span class="fc" id="L322">            final double curD = FastMath.abs(cdf_x - cdf_y);</span>
-<span class="fc bfc" id="L323" title="All 2 branches covered.">            if (curD &gt; supD) {</span>
-<span class="fc" id="L324">                supD = curD;</span>
-            }
-        }
-<span class="fc" id="L327">        return supD;</span>
-    }
+<span class="fc" id="L298">        int rankX = 0;</span>
+<span class="fc" id="L299">        int rankY = 0;</span>
 
-    /**
-     * Computes the empirical distribution function.
-     *
-     * @param x the given x
-     * @param samples the observations
-     * @return the empirical distribution function \(F_n(x)\)
-     */
-    private double edf(final double x, final double[] samples) {
-<span class="fc" id="L338">        final int n = samples.length;</span>
-<span class="fc" id="L339">        int index = Arrays.binarySearch(samples, x);</span>
-<span class="fc bfc" id="L340" title="All 2 branches covered.">        if (index &gt;= 0) {</span>
-<span class="fc bfc" id="L341" title="All 4 branches covered.">            while(index &lt; (n - 1) &amp;&amp; samples[index+1] == x) {</span>
-<span class="fc" id="L342">                ++index;</span>
+        // Find the max difference between cdf_x and cdf_y
+<span class="fc" id="L302">        double supD = 0d;</span>
+        do {
+<span class="fc bfc" id="L304" title="All 2 branches covered.">            double z = Double.compare(sx[rankX], sy[rankY]) &lt;= 0 ? sx[rankX] : sy[rankY];</span>
+<span class="fc bfc" id="L305" title="All 4 branches covered.">            while(rankX &lt; n &amp;&amp; Double.compare(sx[rankX], z) == 0) {</span>
+<span class="fc" id="L306">                rankX += 1;</span>
+            }
+<span class="fc bfc" id="L308" title="All 4 branches covered.">            while(rankY &lt; m &amp;&amp; Double.compare(sy[rankY], z) == 0) {</span>
+<span class="fc" id="L309">                rankY += 1;</span>
+            }
+<span class="fc" id="L311">            final double cdf_x = rankX / (double) n;</span>
+<span class="fc" id="L312">            final double cdf_y = rankY / (double) m;</span>
+<span class="fc" id="L313">            final double curD = FastMath.abs(cdf_x - cdf_y);</span>
+<span class="fc bfc" id="L314" title="All 2 branches covered.">            if (curD &gt; supD) {</span>
+<span class="fc" id="L315">                supD = curD;</span>
             }
-        }
-<span class="fc bfc" id="L345" title="All 2 branches covered.">        return index &gt;= 0 ? (index + 1d) / n : (-index - 1d) / n;</span>
+<span class="fc bfc" id="L317" title="All 4 branches covered.">        } while(rankX &lt; n &amp;&amp; rankY &lt; m);</span>
+<span class="fc" id="L318">        return supD;</span>
     }
 
     /**
@@ -358,7 +331,7 @@ public class KolmogorovSmirnovTest {
      * @throws NullArgumentException if {@code data} is null
      */
     public double kolmogorovSmirnovTest(RealDistribution distribution, double[] data) {
-<span class="fc" id="L361">        return kolmogorovSmirnovTest(distribution, data, false);</span>
+<span class="fc" id="L334">        return kolmogorovSmirnovTest(distribution, data, false);</span>
     }
 
     /**
@@ -374,10 +347,10 @@ public class KolmogorovSmirnovTest {
      * @throws NullArgumentException if {@code data} is null
      */
     public boolean kolmogorovSmirnovTest(RealDistribution distribution, double[] data, double alpha) {
-<span class="pc bpc" id="L377" title="2 of 4 branches missed.">        if ((alpha &lt;= 0) || (alpha &gt; 0.5)) {</span>
-<span class="nc" id="L378">            throw new OutOfRangeException(LocalizedFormats.OUT_OF_BOUND_SIGNIFICANCE_LEVEL, alpha, 0, 0.5);</span>
+<span class="pc bpc" id="L350" title="2 of 4 branches missed.">        if ((alpha &lt;= 0) || (alpha &gt; 0.5)) {</span>
+<span class="nc" id="L351">            throw new OutOfRangeException(LocalizedFormats.OUT_OF_BOUND_SIGNIFICANCE_LEVEL, alpha, 0, 0.5);</span>
         }
-<span class="fc bfc" id="L380" title="All 2 branches covered.">        return kolmogorovSmirnovTest(distribution, data) &lt; alpha;</span>
+<span class="fc bfc" id="L353" title="All 2 branches covered.">        return kolmogorovSmirnovTest(distribution, data) &lt; alpha;</span>
     }
 
     /**
@@ -395,7 +368,7 @@ public class KolmogorovSmirnovTest {
      */
     public double cdf(double d, int n)
         throws MathArithmeticException {
-<span class="nc" id="L398">        return cdf(d, n, false);</span>
+<span class="nc" id="L371">        return cdf(d, n, false);</span>
     }
 
     /**
@@ -414,7 +387,7 @@ public class KolmogorovSmirnovTest {
      */
     public double cdfExact(double d, int n)
         throws MathArithmeticException {
-<span class="nc" id="L417">        return cdf(d, n, true);</span>
+<span class="nc" id="L390">        return cdf(d, n, true);</span>
     }
 
     /**
@@ -436,31 +409,31 @@ public class KolmogorovSmirnovTest {
     public double cdf(double d, int n, boolean exact)
         throws MathArithmeticException {
 
-<span class="fc" id="L439">        final double ninv = 1 / ((double) n);</span>
-<span class="fc" id="L440">        final double ninvhalf = 0.5 * ninv;</span>
+<span class="fc" id="L412">        final double ninv = 1 / ((double) n);</span>
+<span class="fc" id="L413">        final double ninvhalf = 0.5 * ninv;</span>
 
-<span class="pc bpc" id="L442" title="1 of 2 branches missed.">        if (d &lt;= ninvhalf) {</span>
-<span class="nc" id="L443">            return 0;</span>
-<span class="pc bpc" id="L444" title="2 of 4 branches missed.">        } else if (ninvhalf &lt; d &amp;&amp; d &lt;= ninv) {</span>
-<span class="nc" id="L445">            double res = 1;</span>
-<span class="nc" id="L446">            final double f = 2 * d - ninv;</span>
+<span class="pc bpc" id="L415" title="1 of 2 branches missed.">        if (d &lt;= ninvhalf) {</span>
+<span class="nc" id="L416">            return 0;</span>
+<span class="pc bpc" id="L417" title="2 of 4 branches missed.">        } else if (ninvhalf &lt; d &amp;&amp; d &lt;= ninv) {</span>
+<span class="nc" id="L418">            double res = 1;</span>
+<span class="nc" id="L419">            final double f = 2 * d - ninv;</span>
             // n! f^n = n*f * (n-1)*f * ... * 1*x
-<span class="nc bnc" id="L448" title="All 2 branches missed.">            for (int i = 1; i &lt;= n; ++i) {</span>
-<span class="nc" id="L449">                res *= i * f;</span>
+<span class="nc bnc" id="L421" title="All 2 branches missed.">            for (int i = 1; i &lt;= n; ++i) {</span>
+<span class="nc" id="L422">                res *= i * f;</span>
             }
-<span class="nc" id="L451">            return res;</span>
-<span class="pc bpc" id="L452" title="3 of 4 branches missed.">        } else if (1 - ninv &lt;= d &amp;&amp; d &lt; 1) {</span>
-<span class="nc" id="L453">            return 1 - 2 * Math.pow(1 - d, n);</span>
-<span class="pc bpc" id="L454" title="1 of 2 branches missed.">        } else if (1 &lt;= d) {</span>
-<span class="nc" id="L455">            return 1;</span>
+<span class="nc" id="L424">            return res;</span>
+<span class="pc bpc" id="L425" title="3 of 4 branches missed.">        } else if (1 - ninv &lt;= d &amp;&amp; d &lt; 1) {</span>
+<span class="nc" id="L426">            return 1 - 2 * Math.pow(1 - d, n);</span>
+<span class="pc bpc" id="L427" title="1 of 2 branches missed.">        } else if (1 &lt;= d) {</span>
+<span class="nc" id="L428">            return 1;</span>
         }
-<span class="pc bpc" id="L457" title="1 of 2 branches missed.">        if (exact) {</span>
-<span class="nc" id="L458">            return exactK(d, n);</span>
+<span class="pc bpc" id="L430" title="1 of 2 branches missed.">        if (exact) {</span>
+<span class="nc" id="L431">            return exactK(d, n);</span>
         }
-<span class="fc bfc" id="L460" title="All 2 branches covered.">        if (n &lt;= 140) {</span>
-<span class="fc" id="L461">            return roundedK(d, n);</span>
+<span class="fc bfc" id="L433" title="All 2 branches covered.">        if (n &lt;= 140) {</span>
+<span class="fc" id="L434">            return roundedK(d, n);</span>
         }
-<span class="fc" id="L463">        return pelzGood(d, n);</span>
+<span class="fc" id="L436">        return pelzGood(d, n);</span>
     }
 
     /**
@@ -478,15 +451,15 @@ public class KolmogorovSmirnovTest {
     private double exactK(double d, int n)
         throws MathArithmeticException {
 
-<span class="nc" id="L481">        final int k = (int) Math.ceil(n * d);</span>
+<span class="nc" id="L454">        final int k = (int) Math.ceil(n * d);</span>
 
-<span class="nc" id="L483">        final FieldMatrix&lt;BigFraction&gt; H = this.createExactH(d, n);</span>
-<span class="nc" id="L484">        final FieldMatrix&lt;BigFraction&gt; Hpower = H.power(n);</span>
+<span class="nc" id="L456">        final FieldMatrix&lt;BigFraction&gt; H = this.createExactH(d, n);</span>
+<span class="nc" id="L457">        final FieldMatrix&lt;BigFraction&gt; Hpower = H.power(n);</span>
 
-<span class="nc" id="L486">        BigFraction pFrac = Hpower.getEntry(k - 1, k - 1);</span>
+<span class="nc" id="L459">        BigFraction pFrac = Hpower.getEntry(k - 1, k - 1);</span>
 
-<span class="nc bnc" id="L488" title="All 2 branches missed.">        for (int i = 1; i &lt;= n; ++i) {</span>
-<span class="nc" id="L489">            pFrac = pFrac.multiply(i).divide(n);</span>
+<span class="nc bnc" id="L461" title="All 2 branches missed.">        for (int i = 1; i &lt;= n; ++i) {</span>
+<span class="nc" id="L462">            pFrac = pFrac.multiply(i).divide(n);</span>
         }
 
         /*
@@ -494,7 +467,7 @@ public class KolmogorovSmirnovTest {
          * divides afterwards. That gives NaN quite easy. This does not (scale is the number of
          * digits):
          */
-<span class="nc" id="L497">        return pFrac.bigDecimalValue(20, BigDecimal.ROUND_HALF_UP).doubleValue();</span>
+<span class="nc" id="L470">        return pFrac.bigDecimalValue(20, BigDecimal.ROUND_HALF_UP).doubleValue();</span>
     }
 
     /**
@@ -506,16 +479,16 @@ public class KolmogorovSmirnovTest {
      */
     private double roundedK(double d, int n) {
 
-<span class="fc" id="L509">        final int k = (int) Math.ceil(n * d);</span>
-<span class="fc" id="L510">        final RealMatrix H = this.createRoundedH(d, n);</span>
-<span class="fc" id="L511">        final RealMatrix Hpower = H.power(n);</span>
+<span class="fc" id="L482">        final int k = (int) Math.ceil(n * d);</span>
+<span class="fc" id="L483">        final RealMatrix H = this.createRoundedH(d, n);</span>
+<span class="fc" id="L484">        final RealMatrix Hpower = H.power(n);</span>
 
-<span class="fc" id="L513">        double pFrac = Hpower.getEntry(k - 1, k - 1);</span>
-<span class="fc bfc" id="L514" title="All 2 branches covered.">        for (int i = 1; i &lt;= n; ++i) {</span>
-<span class="fc" id="L515">            pFrac *= (double) i / (double) n;</span>
+<span class="fc" id="L486">        double pFrac = Hpower.getEntry(k - 1, k - 1);</span>
+<span class="fc bfc" id="L487" title="All 2 branches covered.">        for (int i = 1; i &lt;= n; ++i) {</span>
+<span class="fc" id="L488">            pFrac *= (double) i / (double) n;</span>
         }
 
-<span class="fc" id="L518">        return pFrac;</span>
+<span class="fc" id="L491">        return pFrac;</span>
     }
 
     /**
@@ -529,133 +502,133 @@ public class KolmogorovSmirnovTest {
     public double pelzGood(double d, int n) {
 
         // Change the variable since approximation is for the distribution evaluated at d / sqrt(n)
-<span class="fc" id="L532">        final double sqrtN = FastMath.sqrt(n);</span>
-<span class="fc" id="L533">        final double z = d * sqrtN;</span>
-<span class="fc" id="L534">        final double z2 = d * d * n;</span>
-<span class="fc" id="L535">        final double z4 = z2 * z2;</span>
-<span class="fc" id="L536">        final double z6 = z4 * z2;</span>
-<span class="fc" id="L537">        final double z8 = z4 * z4;</span>
+<span class="fc" id="L505">        final double sqrtN = FastMath.sqrt(n);</span>
+<span class="fc" id="L506">        final double z = d * sqrtN;</span>
+<span class="fc" id="L507">        final double z2 = d * d * n;</span>
+<span class="fc" id="L508">        final double z4 = z2 * z2;</span>
+<span class="fc" id="L509">        final double z6 = z4 * z2;</span>
+<span class="fc" id="L510">        final double z8 = z4 * z4;</span>
 
         // Eventual return value
-<span class="fc" id="L540">        double ret = 0;</span>
+<span class="fc" id="L513">        double ret = 0;</span>
 
         // Compute K_0(z)
-<span class="fc" id="L543">        double sum = 0;</span>
-<span class="fc" id="L544">        double increment = 0;</span>
-<span class="fc" id="L545">        double kTerm = 0;</span>
-<span class="fc" id="L546">        double z2Term = PI_SQUARED / (8 * z2);</span>
-<span class="fc" id="L547">        int k = 1;</span>
-<span class="pc bpc" id="L548" title="1 of 2 branches missed.">        for (; k &lt; MAXIMUM_PARTIAL_SUM_COUNT; k++) {</span>
-<span class="fc" id="L549">            kTerm = 2 * k - 1;</span>
-<span class="fc" id="L550">            increment = FastMath.exp(-z2Term * kTerm * kTerm);</span>
-<span class="fc" id="L551">            sum += increment;</span>
-<span class="fc bfc" id="L552" title="All 2 branches covered.">            if (increment &lt;= PG_SUM_RELATIVE_ERROR * sum) {</span>
-<span class="fc" id="L553">                break;</span>
+<span class="fc" id="L516">        double sum = 0;</span>
+<span class="fc" id="L517">        double increment = 0;</span>
+<span class="fc" id="L518">        double kTerm = 0;</span>
+<span class="fc" id="L519">        double z2Term = PI_SQUARED / (8 * z2);</span>
+<span class="fc" id="L520">        int k = 1;</span>
+<span class="pc bpc" id="L521" title="1 of 2 branches missed.">        for (; k &lt; MAXIMUM_PARTIAL_SUM_COUNT; k++) {</span>
+<span class="fc" id="L522">            kTerm = 2 * k - 1;</span>
+<span class="fc" id="L523">            increment = FastMath.exp(-z2Term * kTerm * kTerm);</span>
+<span class="fc" id="L524">            sum += increment;</span>
+<span class="fc bfc" id="L525" title="All 2 branches covered.">            if (increment &lt;= PG_SUM_RELATIVE_ERROR * sum) {</span>
+<span class="fc" id="L526">                break;</span>
             }
         }
-<span class="pc bpc" id="L556" title="1 of 2 branches missed.">        if (k == MAXIMUM_PARTIAL_SUM_COUNT) {</span>
-<span class="nc" id="L557">            throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT);</span>
+<span class="pc bpc" id="L529" title="1 of 2 branches missed.">        if (k == MAXIMUM_PARTIAL_SUM_COUNT) {</span>
+<span class="nc" id="L530">            throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT);</span>
         }
-<span class="fc" id="L559">        ret = sum * FastMath.sqrt(2 * FastMath.PI) / z;</span>
+<span class="fc" id="L532">        ret = sum * FastMath.sqrt(2 * FastMath.PI) / z;</span>
 
         // K_1(z)
         // Sum is -inf to inf, but k term is always (k + 1/2) ^ 2, so really have
         // twice the sum from k = 0 to inf (k = -1 is same as 0, -2 same as 1, ...)
-<span class="fc" id="L564">        final double twoZ2 = 2 * z2;</span>
-<span class="fc" id="L565">        sum = 0;</span>
-<span class="fc" id="L566">        kTerm = 0;</span>
-<span class="fc" id="L567">        double kTerm2 = 0;</span>
-<span class="pc bpc" id="L568" title="1 of 2 branches missed.">        for (k = 0; k &lt; MAXIMUM_PARTIAL_SUM_COUNT; k++) {</span>
-<span class="fc" id="L569">            kTerm = k + 0.5;</span>
-<span class="fc" id="L570">            kTerm2 = kTerm * kTerm;</span>
-<span class="fc" id="L571">            increment = (PI_SQUARED * kTerm2 - z2) * FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2);</span>
-<span class="fc" id="L572">            sum += increment;</span>
-<span class="fc bfc" id="L573" title="All 2 branches covered.">            if (FastMath.abs(increment) &lt; PG_SUM_RELATIVE_ERROR * FastMath.abs(sum)) {</span>
-<span class="fc" id="L574">                break;</span>
+<span class="fc" id="L537">        final double twoZ2 = 2 * z2;</span>
+<span class="fc" id="L538">        sum = 0;</span>
+<span class="fc" id="L539">        kTerm = 0;</span>
+<span class="fc" id="L540">        double kTerm2 = 0;</span>
+<span class="pc bpc" id="L541" title="1 of 2 branches missed.">        for (k = 0; k &lt; MAXIMUM_PARTIAL_SUM_COUNT; k++) {</span>
+<span class="fc" id="L542">            kTerm = k + 0.5;</span>
+<span class="fc" id="L543">            kTerm2 = kTerm * kTerm;</span>
+<span class="fc" id="L544">            increment = (PI_SQUARED * kTerm2 - z2) * FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2);</span>
+<span class="fc" id="L545">            sum += increment;</span>
+<span class="fc bfc" id="L546" title="All 2 branches covered.">            if (FastMath.abs(increment) &lt; PG_SUM_RELATIVE_ERROR * FastMath.abs(sum)) {</span>
+<span class="fc" id="L547">                break;</span>
             }
         }
-<span class="pc bpc" id="L577" title="1 of 2 branches missed.">        if (k == MAXIMUM_PARTIAL_SUM_COUNT) {</span>
-<span class="nc" id="L578">            throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT);</span>
+<span class="pc bpc" id="L550" title="1 of 2 branches missed.">        if (k == MAXIMUM_PARTIAL_SUM_COUNT) {</span>
+<span class="nc" id="L551">            throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT);</span>
         }
-<span class="fc" id="L580">        final double sqrtHalfPi = FastMath.sqrt(PI / 2);</span>
+<span class="fc" id="L553">        final double sqrtHalfPi = FastMath.sqrt(PI / 2);</span>
         // Instead of doubling sum, divide by 3 instead of 6
-<span class="fc" id="L582">        ret += sum * sqrtHalfPi / (3 * z4 * sqrtN);</span>
+<span class="fc" id="L555">        ret += sum * sqrtHalfPi / (3 * z4 * sqrtN);</span>
 
         // K_2(z)
         // Same drill as K_1, but with two doubly infinite sums, all k terms are even powers.
-<span class="fc" id="L586">        final double z4Term = 2 * z4;</span>
-<span class="fc" id="L587">        final double z6Term = 6 * z6;</span>
-<span class="fc" id="L588">        z2Term = 5 * z2;</span>
-<span class="fc" id="L589">        final double pi4 = PI_SQUARED * PI_SQUARED;</span>
-<span class="fc" id="L590">        sum = 0;</span>
-<span class="fc" id="L591">        kTerm = 0;</span>
-<span class="fc" id="L592">        kTerm2 = 0;</span>
-<span class="pc bpc" id="L593" title="1 of 2 branches missed.">        for (k = 0; k &lt; MAXIMUM_PARTIAL_SUM_COUNT; k++) {</span>
-<span class="fc" id="L594">            kTerm = k + 0.5;</span>
-<span class="fc" id="L595">            kTerm2 = kTerm * kTerm;</span>
-<span class="fc" id="L596">            increment =  (z6Term + z4Term + PI_SQUARED * (z4Term - z2Term) * kTerm2 +</span>
+<span class="fc" id="L559">        final double z4Term = 2 * z4;</span>
+<span class="fc" id="L560">        final double z6Term = 6 * z6;</span>
+<span class="fc" id="L561">        z2Term = 5 * z2;</span>
+<span class="fc" id="L562">        final double pi4 = PI_SQUARED * PI_SQUARED;</span>
+<span class="fc" id="L563">        sum = 0;</span>
+<span class="fc" id="L564">        kTerm = 0;</span>
+<span class="fc" id="L565">        kTerm2 = 0;</span>
+<span class="pc bpc" id="L566" title="1 of 2 branches missed.">        for (k = 0; k &lt; MAXIMUM_PARTIAL_SUM_COUNT; k++) {</span>
+<span class="fc" id="L567">            kTerm = k + 0.5;</span>
+<span class="fc" id="L568">            kTerm2 = kTerm * kTerm;</span>
+<span class="fc" id="L569">            increment =  (z6Term + z4Term + PI_SQUARED * (z4Term - z2Term) * kTerm2 +</span>
                     pi4 * (1 - twoZ2) * kTerm2 * kTerm2) * FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2);
-<span class="fc" id="L598">            sum += increment;</span>
-<span class="fc bfc" id="L599" title="All 2 branches covered.">            if (FastMath.abs(increment) &lt; PG_SUM_RELATIVE_ERROR * FastMath.abs(sum)) {</span>
-<span class="fc" id="L600">                break;</span>
-            }
-        }
-<span class="pc bpc" id="L603" title="1 of 2 branches missed.">        if (k == MAXIMUM_PARTIAL_SUM_COUNT) {</span>
-<span class="nc" id="L604">            throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT);</span>
-        }
-<span class="fc" id="L606">        double sum2 = 0;</span>
-<span class="fc" id="L607">        kTerm2 = 0;</span>
-<span class="pc bpc" id="L608" title="1 of 2 branches missed.">        for (k = 1; k &lt; MAXIMUM_PARTIAL_SUM_COUNT; k++) {</span>
-<span class="fc" id="L609">            kTerm2 = k * k;</span>
-<span class="fc" id="L610">            increment = PI_SQUARED * kTerm2 * FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2);</span>
-<span class="fc" id="L611">            sum2 += increment;</span>
-<span class="fc bfc" id="L612" title="All 2 branches covered.">            if (FastMath.abs(increment) &lt; PG_SUM_RELATIVE_ERROR * FastMath.abs(sum2)) {</span>
-<span class="fc" id="L613">                break;</span>
+<span class="fc" id="L571">            sum += increment;</span>
+<span class="fc bfc" id="L572" title="All 2 branches covered.">            if (FastMath.abs(increment) &lt; PG_SUM_RELATIVE_ERROR * FastMath.abs(sum)) {</span>
+<span class="fc" id="L573">                break;</span>
+            }
+        }
+<span class="pc bpc" id="L576" title="1 of 2 branches missed.">        if (k == MAXIMUM_PARTIAL_SUM_COUNT) {</span>
+<span class="nc" id="L577">            throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT);</span>
+        }
+<span class="fc" id="L579">        double sum2 = 0;</span>
+<span class="fc" id="L580">        kTerm2 = 0;</span>
+<span class="pc bpc" id="L581" title="1 of 2 branches missed.">        for (k = 1; k &lt; MAXIMUM_PARTIAL_SUM_COUNT; k++) {</span>
+<span class="fc" id="L582">            kTerm2 = k * k;</span>
+<span class="fc" id="L583">            increment = PI_SQUARED * kTerm2 * FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2);</span>
+<span class="fc" id="L584">            sum2 += increment;</span>
+<span class="fc bfc" id="L585" title="All 2 branches covered.">            if (FastMath.abs(increment) &lt; PG_SUM_RELATIVE_ERROR * FastMath.abs(sum2)) {</span>
+<span class="fc" id="L586">                break;</span>
             }
         }
-<span class="pc bpc" id="L616" title="1 of 2 branches missed.">        if (k == MAXIMUM_PARTIAL_SUM_COUNT) {</span>
-<span class="nc" id="L617">            throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT);</span>
+<span class="pc bpc" id="L589" title="1 of 2 branches missed.">        if (k == MAXIMUM_PARTIAL_SUM_COUNT) {</span>
+<span class="nc" id="L590">            throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT);</span>
         }
         // Again, adjust coefficients instead of doubling sum, sum2
-<span class="fc" id="L620">        ret += (sqrtHalfPi / n) * (sum / (36 * z2 * z2 * z2 * z) - sum2 / (18 * z2 * z));</span>
+<span class="fc" id="L593">        ret += (sqrtHalfPi / n) * (sum / (36 * z2 * z2 * z2 * z) - sum2 / (18 * z2 * z));</span>
 
         // K_3(z) One more time with feeling - two doubly infinite sums, all k powers even.
         // Multiply coefficient denominators by 2, so omit doubling sums.
-<span class="fc" id="L624">        final double pi6 = pi4 * PI_SQUARED;</span>
-<span class="fc" id="L625">        sum = 0;</span>
-<span class="fc" id="L626">        double kTerm4 = 0;</span>
-<span class="fc" id="L627">        double kTerm6 = 0;</span>
-<span class="pc bpc" id="L628" title="1 of 2 branches missed.">        for (k = 0; k &lt; MAXIMUM_PARTIAL_SUM_COUNT; k++) {</span>
-<span class="fc" id="L629">            kTerm = k + 0.5;</span>
-<span class="fc" id="L630">            kTerm2 = kTerm * kTerm;</span>
-<span class="fc" id="L631">            kTerm4 = kTerm2 * kTerm2;</span>
-<span class="fc" id="L632">            kTerm6 = kTerm4 * kTerm2;</span>
-<span class="fc" id="L633">            increment = (pi6 * kTerm6 * (5 - 30 * z2) + pi4 * kTerm4 * (-60 * z2 + 212 * z4) +</span>
+<span class="fc" id="L597">        final double pi6 = pi4 * PI_SQUARED;</span>
+<span class="fc" id="L598">        sum = 0;</span>
+<span class="fc" id="L599">        double kTerm4 = 0;</span>
+<span class="fc" id="L600">        double kTerm6 = 0;</span>
+<span class="pc bpc" id="L601" title="1 of 2 branches missed.">        for (k = 0; k &lt; MAXIMUM_PARTIAL_SUM_COUNT; k++) {</span>
+<span class="fc" id="L602">            kTerm = k + 0.5;</span>
+<span class="fc" id="L603">            kTerm2 = kTerm * kTerm;</span>
+<span class="fc" id="L604">            kTerm4 = kTerm2 * kTerm2;</span>
+<span class="fc" id="L605">            kTerm6 = kTerm4 * kTerm2;</span>
+<span class="fc" id="L606">            increment = (pi6 * kTerm6 * (5 - 30 * z2) + pi4 * kTerm4 * (-60 * z2 + 212 * z4) +</span>
                     PI_SQUARED * kTerm2 * (135 * z4 - 96 * z6) - 30 * z6 - 90 * z8) *
                     FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2);
-<span class="fc" id="L636">            sum += increment;</span>
-<span class="fc bfc" id="L637" title="All 2 branches covered.">            if (FastMath.abs(increment) &lt; PG_SUM_RELATIVE_ERROR * FastMath.abs(sum)) {</span>
-<span class="fc" id="L638">                break;</span>
+<span class="fc" id="L609">            sum += increment;</span>
+<span class="fc bfc" id="L610" title="All 2 branches covered.">            if (FastMath.abs(increment) &lt; PG_SUM_RELATIVE_ERROR * FastMath.abs(sum)) {</span>
+<span class="fc" id="L611">                break;</span>
             }
         }
-<span class="pc bpc" id="L641" title="1 of 2 branches missed.">        if (k == MAXIMUM_PARTIAL_SUM_COUNT) {</span>
-<span class="nc" id="L642">            throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT);</span>
-        }
-<span class="fc" id="L644">        sum2 = 0;</span>
-<span class="pc bpc" id="L645" title="1 of 2 branches missed.">        for (k = 1; k &lt; MAXIMUM_PARTIAL_SUM_COUNT; k++) {</span>
-<span class="fc" id="L646">            kTerm2 = k * k;</span>
-<span class="fc" id="L647">            kTerm4 = kTerm2 * kTerm2;</span>
-<span class="fc" id="L648">            increment = (-pi4 * kTerm4 + 3 * PI_SQUARED * kTerm2 * z2) *</span>
+<span class="pc bpc" id="L614" title="1 of 2 branches missed.">        if (k == MAXIMUM_PARTIAL_SUM_COUNT) {</span>
+<span class="nc" id="L615">            throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT);</span>
+        }
+<span class="fc" id="L617">        sum2 = 0;</span>
+<span class="pc bpc" id="L618" title="1 of 2 branches missed.">        for (k = 1; k &lt; MAXIMUM_PARTIAL_SUM_COUNT; k++) {</span>
+<span class="fc" id="L619">            kTerm2 = k * k;</span>
+<span class="fc" id="L620">            kTerm4 = kTerm2 * kTerm2;</span>
+<span class="fc" id="L621">            increment = (-pi4 * kTerm4 + 3 * PI_SQUARED * kTerm2 * z2) *</span>
                     FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2);
-<span class="fc" id="L650">            sum2 += increment;</span>
-<span class="fc bfc" id="L651" title="All 2 branches covered.">            if (FastMath.abs(increment) &lt; PG_SUM_RELATIVE_ERROR * FastMath.abs(sum2)) {</span>
-<span class="fc" id="L652">                break;</span>
+<span class="fc" id="L623">            sum2 += increment;</span>
+<span class="fc bfc" id="L624" title="All 2 branches covered.">            if (FastMath.abs(increment) &lt; PG_SUM_RELATIVE_ERROR * FastMath.abs(sum2)) {</span>
+<span class="fc" id="L625">                break;</span>
             }
         }
-<span class="pc bpc" id="L655" title="1 of 2 branches missed.">        if (k == MAXIMUM_PARTIAL_SUM_COUNT) {</span>
-<span class="nc" id="L656">            throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT);</span>
+<span class="pc bpc" id="L628" title="1 of 2 branches missed.">        if (k == MAXIMUM_PARTIAL_SUM_COUNT) {</span>
+<span class="nc" id="L629">            throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT);</span>
         }
-<span class="fc" id="L658">        return ret + (sqrtHalfPi / (sqrtN * n)) * (sum / (3240 * z6 * z4) +</span>
+<span class="fc" id="L631">        return ret + (sqrtHalfPi / (sqrtN * n)) * (sum / (3240 * z6 * z4) +</span>
                 + sum2 / (108 * z6));
 
     }
@@ -674,33 +647,33 @@ public class KolmogorovSmirnovTest {
     private FieldMatrix&lt;BigFraction&gt; createExactH(double d, int n)
         throws NumberIsTooLargeException, FractionConversionException {
 
-<span class="nc" id="L677">        final int k = (int) Math.ceil(n * d);</span>
-<span class="nc" id="L678">        final int m = 2 * k - 1;</span>
-<span class="nc" id="L679">        final double hDouble = k - n * d;</span>
-<span class="nc bnc" id="L680" title="All 2 branches missed.">        if (hDouble &gt;= 1) {</span>
-<span class="nc" id="L681">            throw new NumberIsTooLargeException(hDouble, 1.0, false);</span>
+<span class="nc" id="L650">        final int k = (int) Math.ceil(n * d);</span>
+<span class="nc" id="L651">        final int m = 2 * k - 1;</span>
+<span class="nc" id="L652">        final double hDouble = k - n * d;</span>
+<span class="nc bnc" id="L653" title="All 2 branches missed.">        if (hDouble &gt;= 1) {</span>
+<span class="nc" id="L654">            throw new NumberIsTooLargeException(hDouble, 1.0, false);</span>
         }
-<span class="nc" id="L683">        BigFraction h = null;</span>
+<span class="nc" id="L656">        BigFraction h = null;</span>
         try {
-<span class="nc" id="L685">            h = new BigFraction(hDouble, 1.0e-20, 10000);</span>
-<span class="nc" id="L686">        } catch (final FractionConversionException e1) {</span>
+<span class="nc" id="L658">            h = new BigFraction(hDouble, 1.0e-20, 10000);</span>
+<span class="nc" id="L659">        } catch (final FractionConversionException e1) {</span>
             try {
-<span class="nc" id="L688">                h = new BigFraction(hDouble, 1.0e-10, 10000);</span>
-<span class="nc" id="L689">            } catch (final FractionConversionException e2) {</span>
-<span class="nc" id="L690">                h = new BigFraction(hDouble, 1.0e-5, 10000);</span>
-<span class="nc" id="L691">            }</span>
-<span class="nc" id="L692">        }</span>
-<span class="nc" id="L693">        final BigFraction[][] Hdata = new BigFraction[m][m];</span>
+<span class="nc" id="L661">                h = new BigFraction(hDouble, 1.0e-10, 10000);</span>
+<span class="nc" id="L662">            } catch (final FractionConversionException e2) {</span>
+<span class="nc" id="L663">                h = new BigFraction(hDouble, 1.0e-5, 10000);</span>
+<span class="nc" id="L664">            }</span>
+<span class="nc" id="L665">        }</span>
+<span class="nc" id="L666">        final BigFraction[][] Hdata = new BigFraction[m][m];</span>
 
         /*
          * Start by filling everything with either 0 or 1.
          */
-<span class="nc bnc" id="L698" title="All 2 branches missed.">        for (int i = 0; i &lt; m; ++i) {</span>
-<span class="nc bnc" id="L699" title="All 2 branches missed.">            for (int j = 0; j &lt; m; ++j) {</span>
-<span class="nc bnc" id="L700" title="All 2 branches missed.">                if (i - j + 1 &lt; 0) {</span>
-<span class="nc" id="L701">                    Hdata[i][j] = BigFraction.ZERO;</span>
+<span class="nc bnc" id="L671" title="All 2 branches missed.">        for (int i = 0; i &lt; m; ++i) {</span>
+<span class="nc bnc" id="L672" title="All 2 branches missed.">            for (int j = 0; j &lt; m; ++j) {</span>
+<span class="nc bnc" id="L673" title="All 2 branches missed.">                if (i - j + 1 &lt; 0) {</span>
+<span class="nc" id="L674">                    Hdata[i][j] = BigFraction.ZERO;</span>
                 } else {
-<span class="nc" id="L703">                    Hdata[i][j] = BigFraction.ONE;</span>
+<span class="nc" id="L676">                    Hdata[i][j] = BigFraction.ONE;</span>
                 }
             }
         }
@@ -709,26 +682,26 @@ public class KolmogorovSmirnovTest {
          * Setting up power-array to avoid calculating the same value twice: hPowers[0] = h^1 ...
          * hPowers[m-1] = h^m
          */
-<span class="nc" id="L712">        final BigFraction[] hPowers = new BigFraction[m];</span>
-<span class="nc" id="L713">        hPowers[0] = h;</span>
-<span class="nc bnc" id="L714" title="All 2 branches missed.">        for (int i = 1; i &lt; m; ++i) {</span>
-<span class="nc" id="L715">            hPowers[i] = h.multiply(hPowers[i - 1]);</span>
+<span class="nc" id="L685">        final BigFraction[] hPowers = new BigFraction[m];</span>
+<span class="nc" id="L686">        hPowers[0] = h;</span>
+<span class="nc bnc" id="L687" title="All 2 branches missed.">        for (int i = 1; i &lt; m; ++i) {</span>
+<span class="nc" id="L688">            hPowers[i] = h.multiply(hPowers[i - 1]);</span>
         }
 
         /*
          * First column and last row has special values (each other reversed).
          */
-<span class="nc bnc" id="L721" title="All 2 branches missed.">        for (int i = 0; i &lt; m; ++i) {</span>
-<span class="nc" id="L722">            Hdata[i][0] = Hdata[i][0].subtract(hPowers[i]);</span>
-<span class="nc" id="L723">            Hdata[m - 1][i] = Hdata[m - 1][i].subtract(hPowers[m - i - 1]);</span>
+<span class="nc bnc" id="L694" title="All 2 branches missed.">        for (int i = 0; i &lt; m; ++i) {</span>
+<span class="nc" id="L695">            Hdata[i][0] = Hdata[i][0].subtract(hPowers[i]);</span>
+<span class="nc" id="L696">            Hdata[m - 1][i] = Hdata[m - 1][i].subtract(hPowers[m - i - 1]);</span>
         }
 
         /*
          * [1] states: &quot;For 1/2 &lt; h &lt; 1 the bottom left element of the matrix should be (1 - 2*h^m +
          * (2h - 1)^m )/m!&quot; Since 0 &lt;= h &lt; 1, then if h &gt; 1/2 is sufficient to check:
          */
-<span class="nc bnc" id="L730" title="All 2 branches missed.">        if (h.compareTo(BigFraction.ONE_HALF) == 1) {</span>
-<span class="nc" id="L731">            Hdata[m - 1][0] = Hdata[m - 1][0].add(h.multiply(2).subtract(1).pow(m));</span>
+<span class="nc bnc" id="L703" title="All 2 branches missed.">        if (h.compareTo(BigFraction.ONE_HALF) == 1) {</span>
+<span class="nc" id="L704">            Hdata[m - 1][0] = Hdata[m - 1][0].add(h.multiply(2).subtract(1).pow(m));</span>
         }
 
         /*
@@ -739,16 +712,16 @@ public class KolmogorovSmirnovTest {
          * j'ing all the way to m. Also note that it is started at g = 2 because dividing by 1 isn't
          * really necessary.
          */
-<span class="nc bnc" id="L742" title="All 2 branches missed.">        for (int i = 0; i &lt; m; ++i) {</span>
-<span class="nc bnc" id="L743" title="All 2 branches missed.">            for (int j = 0; j &lt; i + 1; ++j) {</span>
-<span class="nc bnc" id="L744" title="All 2 branches missed.">                if (i - j + 1 &gt; 0) {</span>
-<span class="nc bnc" id="L745" title="All 2 branches missed.">                    for (int g = 2; g &lt;= i - j + 1; ++g) {</span>
-<span class="nc" id="L746">                        Hdata[i][j] = Hdata[i][j].divide(g);</span>
+<span class="nc bnc" id="L715" title="All 2 branches missed.">        for (int i = 0; i &lt; m; ++i) {</span>
+<span class="nc bnc" id="L716" title="All 2 branches missed.">            for (int j = 0; j &lt; i + 1; ++j) {</span>
+<span class="nc bnc" id="L717" title="All 2 branches missed.">                if (i - j + 1 &gt; 0) {</span>
+<span class="nc bnc" id="L718" title="All 2 branches missed.">                    for (int g = 2; g &lt;= i - j + 1; ++g) {</span>
+<span class="nc" id="L719">                        Hdata[i][j] = Hdata[i][j].divide(g);</span>
                     }
                 }
             }
         }
-<span class="nc" id="L751">        return new Array2DRowFieldMatrix&lt;BigFraction&gt;(BigFractionField.getInstance(), Hdata);</span>
+<span class="nc" id="L724">        return new Array2DRowFieldMatrix&lt;BigFraction&gt;(BigFractionField.getInstance(), Hdata);</span>
     }
 
     /***
@@ -763,23 +736,23 @@ public class KolmogorovSmirnovTest {
     private RealMatrix createRoundedH(double d, int n)
         throws NumberIsTooLargeException {
 
-<span class="fc" id="L766">        final int k = (int) Math.ceil(n * d);</span>
-<span class="fc" id="L767">        final int m = 2 * k - 1;</span>
-<span class="fc" id="L768">        final double h = k - n * d;</span>
-<span class="pc bpc" id="L769" title="1 of 2 branches missed.">        if (h &gt;= 1) {</span>
-<span class="nc" id="L770">            throw new NumberIsTooLargeException(h, 1.0, false);</span>
+<span class="fc" id="L739">        final int k = (int) Math.ceil(n * d);</span>
+<span class="fc" id="L740">        final int m = 2 * k - 1;</span>
+<span class="fc" id="L741">        final double h = k - n * d;</span>
+<span class="pc bpc" id="L742" title="1 of 2 branches missed.">        if (h &gt;= 1) {</span>
+<span class="nc" id="L743">            throw new NumberIsTooLargeException(h, 1.0, false);</span>
         }
-<span class="fc" id="L772">        final double[][] Hdata = new double[m][m];</span>
+<span class="fc" id="L745">        final double[][] Hdata = new double[m][m];</span>
 
         /*
          * Start by filling everything with either 0 or 1.
          */
-<span class="fc bfc" id="L777" title="All 2 branches covered.">        for (int i = 0; i &lt; m; ++i) {</span>
-<span class="fc bfc" id="L778" title="All 2 branches covered.">            for (int j = 0; j &lt; m; ++j) {</span>
-<span class="fc bfc" id="L779" title="All 2 branches covered.">                if (i - j + 1 &lt; 0) {</span>
-<span class="fc" id="L780">                    Hdata[i][j] = 0;</span>
+<span class="fc bfc" id="L750" title="All 2 branches covered.">        for (int i = 0; i &lt; m; ++i) {</span>
+<span class="fc bfc" id="L751" title="All 2 branches covered.">            for (int j = 0; j &lt; m; ++j) {</span>
+<span class="fc bfc" id="L752" title="All 2 branches covered.">                if (i - j + 1 &lt; 0) {</span>
+<span class="fc" id="L753">                    Hdata[i][j] = 0;</span>
                 } else {
-<span class="fc" id="L782">                    Hdata[i][j] = 1;</span>
+<span class="fc" id="L755">                    Hdata[i][j] = 1;</span>
                 }
             }
         }
@@ -788,26 +761,26 @@ public class KolmogorovSmirnovTest {
          * Setting up power-array to avoid calculating the same value twice: hPowers[0] = h^1 ...
          * hPowers[m-1] = h^m
          */
-<span class="fc" id="L791">        final double[] hPowers = new double[m];</span>
-<span class="fc" id="L792">        hPowers[0] = h;</span>
-<span class="fc bfc" id="L793" title="All 2 branches covered.">        for (int i = 1; i &lt; m; ++i) {</span>
-<span class="fc" id="L794">            hPowers[i] = h * hPowers[i - 1];</span>
+<span class="fc" id="L764">        final double[] hPowers = new double[m];</span>
+<span class="fc" id="L765">        hPowers[0] = h;</span>
+<span class="fc bfc" id="L766" title="All 2 branches covered.">        for (int i = 1; i &lt; m; ++i) {</span>
+<span class="fc" id="L767">            hPowers[i] = h * hPowers[i - 1];</span>
         }
 
         /*
          * First column and last row has special values (each other reversed).
          */
-<span class="fc bfc" id="L800" title="All 2 branches covered.">        for (int i = 0; i &lt; m; ++i) {</span>
-<span class="fc" id="L801">            Hdata[i][0] = Hdata[i][0] - hPowers[i];</span>
-<span class="fc" id="L802">            Hdata[m - 1][i] -= hPowers[m - i - 1];</span>
+<span class="fc bfc" id="L773" title="All 2 branches covered.">        for (int i = 0; i &lt; m; ++i) {</span>
+<span class="fc" id="L774">            Hdata[i][0] = Hdata[i][0] - hPowers[i];</span>
+<span class="fc" id="L775">            Hdata[m - 1][i] -= hPowers[m - i - 1];</span>
         }
 
         /*
          * [1] states: &quot;For 1/2 &lt; h &lt; 1 the bottom left element of the matrix should be (1 - 2*h^m +
          * (2h - 1)^m )/m!&quot; Since 0 &lt;= h &lt; 1, then if h &gt; 1/2 is sufficient to check:
          */
-<span class="fc bfc" id="L809" title="All 2 branches covered.">        if (Double.compare(h, 0.5) &gt; 0) {</span>
-<span class="fc" id="L810">            Hdata[m - 1][0] += FastMath.pow(2 * h - 1, m);</span>
+<span class="fc bfc" id="L782" title="All 2 branches covered.">        if (Double.compare(h, 0.5) &gt; 0) {</span>
+<span class="fc" id="L783">            Hdata[m - 1][0] += FastMath.pow(2 * h - 1, m);</span>
         }
 
         /*
@@ -818,16 +791,16 @@ public class KolmogorovSmirnovTest {
          * j'ing all the way to m. Also note that it is started at g = 2 because dividing by 1 isn't
          * really necessary.
          */
-<span class="fc bfc" id="L821" title="All 2 branches covered.">        for (int i = 0; i &lt; m; ++i) {</span>
-<span class="fc bfc" id="L822" title="All 2 branches covered.">            for (int j = 0; j &lt; i + 1; ++j) {</span>
-<span class="pc bpc" id="L823" title="1 of 2 branches missed.">                if (i - j + 1 &gt; 0) {</span>
-<span class="fc bfc" id="L824" title="All 2 branches covered.">                    for (int g = 2; g &lt;= i - j + 1; ++g) {</span>
-<span class="fc" id="L825">                        Hdata[i][j] /= g;</span>
+<span class="fc bfc" id="L794" title="All 2 branches covered.">        for (int i = 0; i &lt; m; ++i) {</span>
+<span class="fc bfc" id="L795" title="All 2 branches covered.">            for (int j = 0; j &lt; i + 1; ++j) {</span>
+<span class="pc bpc" id="L796" title="1 of 2 branches missed.">                if (i - j + 1 &gt; 0) {</span>
+<span class="fc bfc" id="L797" title="All 2 branches covered.">                    for (int g = 2; g &lt;= i - j + 1; ++g) {</span>
+<span class="fc" id="L798">                        Hdata[i][j] /= g;</span>
                     }
                 }
             }
         }
-<span class="fc" id="L830">        return MatrixUtils.createRealMatrix(Hdata);</span>
+<span class="fc" id="L803">        return MatrixUtils.createRealMatrix(Hdata);</span>
     }
 
     /**
@@ -838,14 +811,14 @@ public class KolmogorovSmirnovTest {
      * @throws InsufficientDataException if array is too short
      */
     private void checkArray(double[] array) {
-<span class="pc bpc" id="L841" title="1 of 2 branches missed.">        if (array == null) {</span>
-<span class="nc" id="L842">            throw new NullArgumentException(LocalizedFormats.NULL_NOT_ALLOWED);</span>
+<span class="pc bpc" id="L814" title="1 of 2 branches missed.">        if (array == null) {</span>
+<span class="nc" id="L815">            throw new NullArgumentException(LocalizedFormats.NULL_NOT_ALLOWED);</span>
         }
-<span class="pc bpc" id="L844" title="1 of 2 branches missed.">        if (array.length &lt; 2) {</span>
-<span class="nc" id="L845">            throw new InsufficientDataException(LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE, array.length,</span>
+<span class="pc bpc" id="L817" title="1 of 2 branches missed.">        if (array.length &lt; 2) {</span>
+<span class="nc" id="L818">            throw new InsufficientDataException(LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE, array.length,</span>
                                                 2);
         }
-<span class="fc" id="L848">    }</span>
+<span class="fc" id="L821">    }</span>
 
     /**
      * Computes \( 1 + 2 \sum_{i=1}^\infty (-1)^i e^{-2 i^2 t^2} \) stopping when successive partial
@@ -860,28 +833,28 @@ public class KolmogorovSmirnovTest {
      * @throws TooManyIterationsException if the series does not converge
      */
     public double ksSum(double t, double tolerance, int maxIterations) {
-<span class="fc bfc" id="L863" title="All 2 branches covered.">        if (t == 0.0) {</span>
-<span class="fc" id="L864">            return 1.0;</span>
+<span class="fc bfc" id="L836" title="All 2 branches covered.">        if (t == 0.0) {</span>
+<span class="fc" id="L837">            return 0.0;</span>
         }
 
         // TODO: for small t (say less than 1), the alternative expansion in part 3 of [1]
         // from class javadoc should be used.
 
-<span class="fc" id="L870">        final double x = -2 * t * t;</span>
-<span class="fc" id="L871">        int sign = -1;</span>
-<span class="fc" id="L872">        long i = 1;</span>
-<span class="fc" id="L873">        double partialSum = 0.5d;</span>
-<span class="fc" id="L874">        double delta = 1;</span>
-<span class="pc bpc" id="L875" title="1 of 4 branches missed.">        while (delta &gt; tolerance &amp;&amp; i &lt; maxIterations) {</span>
-<span class="fc" id="L876">            delta = FastMath.exp(x * i * i);</span>
-<span class="fc" id="L877">            partialSum += sign * delta;</span>
-<span class="fc" id="L878">            sign *= -1;</span>
-<span class="fc" id="L879">            i++;</span>
+<span class="fc" id="L843">        final double x = -2 * t * t;</span>
+<span class="fc" id="L844">        int sign = -1;</span>
+<span class="fc" id="L845">        long i = 1;</span>
+<span class="fc" id="L846">        double partialSum = 0.5d;</span>
+<span class="fc" id="L847">        double delta = 1;</span>
+<span class="pc bpc" id="L848" title="1 of 4 branches missed.">        while (delta &gt; tolerance &amp;&amp; i &lt; maxIterations) {</span>
+<span class="fc" id="L849">            delta = FastMath.exp(x * i * i);</span>
+<span class="fc" id="L850">            partialSum += sign * delta;</span>
+<span class="fc" id="L851">            sign *= -1;</span>
+<span class="fc" id="L852">            i++;</span>
         }
-<span class="pc bpc" id="L881" title="1 of 2 branches missed.">        if (i == maxIterations) {</span>
-<span class="nc" id="L882">            throw new TooManyIterationsException(maxIterations);</span>
+<span class="pc bpc" id="L854" title="1 of 2 branches missed.">        if (i == maxIterations) {</span>
+<span class="nc" id="L855">            throw new TooManyIterationsException(maxIterations);</span>
         }
-<span class="fc" id="L884">        return partialSum * 2;</span>
+<span class="fc" id="L857">        return partialSum * 2;</span>
     }
 
     /**
@@ -909,31 +882,31 @@ public class KolmogorovSmirnovTest {
      *         greater than (resp. greater than or equal to) {@code d}
      */
     public double exactP(double d, int n, int m, boolean strict) {
-<span class="fc" id="L912">        Iterator&lt;int[]&gt; combinationsIterator = CombinatoricsUtils.combinationsIterator(n + m, n);</span>
-<span class="fc" id="L913">        long tail = 0;</span>
-<span class="fc" id="L914">        final double[] nSet = new double[n];</span>
-<span class="fc" id="L915">        final double[] mSet = new double[m];</span>
-<span class="fc bfc" id="L916" title="All 2 branches covered.">        while (combinationsIterator.hasNext()) {</span>
+<span class="fc" id="L885">        Iterator&lt;int[]&gt; combinationsIterator = CombinatoricsUtils.combinationsIterator(n + m, n);</span>
+<span class="fc" id="L886">        long tail = 0;</span>
+<span class="fc" id="L887">        final double[] nSet = new double[n];</span>
+<span class="fc" id="L888">        final double[] mSet = new double[m];</span>
+<span class="fc" id="L889">        final double tol = 1e-12;  // d-values within tol of one another are considered equal</span>
+<span class="fc bfc" id="L890" title="All 2 branches covered.">        while (combinationsIterator.hasNext()) {</span>
             // Generate an n-set
-<span class="fc" id="L918">            final int[] nSetI = combinationsIterator.next();</span>
+<span class="fc" id="L892">            final int[] nSetI = combinationsIterator.next();</span>
             // Copy the n-set to nSet and its complement to mSet
-<span class="fc" id="L920">            int j = 0;</span>
-<span class="fc" id="L921">            int k = 0;</span>
-<span class="fc bfc" id="L922" title="All 2 branches covered.">            for (int i = 0; i &lt; n + m; i++) {</span>
-<span class="fc bfc" id="L923" title="All 4 branches covered.">                if (j &lt; n &amp;&amp; nSetI[j] == i) {</span>
-<span class="fc" id="L924">                    nSet[j++] = i;</span>
+<span class="fc" id="L894">            int j = 0;</span>
+<span class="fc" id="L895">            int k = 0;</span>
+<span class="fc bfc" id="L896" title="All 2 branches covered.">            for (int i = 0; i &lt; n + m; i++) {</span>
+<span class="fc bfc" id="L897" title="All 4 branches covered.">                if (j &lt; n &amp;&amp; nSetI[j] == i) {</span>
+<span class="fc" id="L898">                    nSet[j++] = i;</span>
                 } else {
-<span class="fc" id="L926">                    mSet[k++] = i;</span>
+<span class="fc" id="L900">                    mSet[k++] = i;</span>
                 }
             }
-<span class="fc" id="L929">            final double curD = kolmogorovSmirnovStatistic(nSet, mSet);</span>
-<span class="fc bfc" id="L930" title="All 2 branches covered.">            if (curD &gt; d) {</span>
-<span class="fc" id="L931">                tail++;</span>
-<span class="fc bfc" id="L932" title="All 4 branches covered.">            } else if (curD == d &amp;&amp; !strict) {</span>
-<span class="fc" id="L933">                tail++;</span>
+<span class="fc" id="L903">            final double curD = kolmogorovSmirnovStatistic(nSet, mSet);</span>
+<span class="fc" id="L904">            final int order = Precision.compareTo(curD, d, tol);</span>
+<span class="fc bfc" id="L905" title="All 6 branches covered.">            if (order &gt; 0 || (order == 0 &amp;&amp; !strict)) {</span>
+<span class="fc" id="L906">                tail++;</span>
             }
-<span class="fc" id="L935">        }</span>
-<span class="fc" id="L936">        return (double) tail / (double) CombinatoricsUtils.binomialCoefficient(n + m, n);</span>
+<span class="fc" id="L908">        }</span>
+<span class="fc" id="L909">        return (double) tail / (double) CombinatoricsUtils.binomialCoefficient(n + m, n);</span>
     }
 
     /**
@@ -955,12 +928,32 @@ public class KolmogorovSmirnovTest {
      *         \(D_{n,m}\) greater than {@code d}
      */
     public double approximateP(double d, int n, int m) {
-<span class="fc" id="L958">        final double dm = m;</span>
-<span class="fc" id="L959">        final double dn = n;</span>
-<span class="fc" id="L960">        return 1 - ksSum(d * FastMath.sqrt((dm * dn) / (dm + dn)), KS_SUM_CAUCHY_CRITERION, MAXIMUM_PARTIAL_SUM_COUNT);</span>
+<span class="fc" id="L931">        final double dm = m;</span>
+<span class="fc" id="L932">        final double dn = n;</span>
+<span class="fc" id="L933">        return 1 - ksSum(d * FastMath.sqrt((dm * dn) / (dm + dn)), KS_SUM_CAUCHY_CRITERION, MAXIMUM_PARTIAL_SUM_COUNT);</span>
     }
 
     /**
+     * Fills a boolean array randomly with a fixed number of {@code true} values.
+     * The method uses a simplified version of the Fisher-Yates shuffle algorithm.
+     * By processing first the {@code true} values followed by the remaining {@code false} values
+     * less random numbers need to be generated. The method is optimized for the case
+     * that the number of {@code true} values is larger than or equal to the number of
+     * {@code false} values.
+     *
+     * @param b boolean array
+     * @param numberOfTrueValues number of {@code true} values the boolean array should finally have
+     * @param rng random data generator
+     */
+    static void fillBooleanArrayRandomlyWithFixedNumberTrueValues(final boolean[] b, final int numberOfTrueValues, final RandomGenerator rng) {
+<span class="fc" id="L949">        Arrays.fill(b, true);</span>
+<span class="fc bfc" id="L950" title="All 2 branches covered.">        for (int k = numberOfTrueValues; k &lt; b.length; k++) {</span>
+<span class="fc" id="L951">            final int r = rng.nextInt(k + 1);</span>
+<span class="fc bfc" id="L952" title="All 2 branches covered.">            b[(b[r]) ? r : k] = false;</span>
+        }
+<span class="fc" id="L954">    }</span>
+
+    /**
      * Uses Monte Carlo simulation to approximate \(P(D_{n,m} &gt; d)\) where \(D_{n,m}\) is the
      * 2-sample Kolmogorov-Smirnov statistic. See
      * {@link #kolmogorovSmirnovStatistic(double[], double[])} for the definition of \(D_{n,m}\).
@@ -979,52 +972,41 @@ public class KolmogorovSmirnovTest {
      * @return proportion of randomly generated m-n partitions of m + n that result in \(D_{n,m}\)
      *         greater than (resp. greater than or equal to) {@code d}
      */
-    public double monteCarloP(double d, int n, int m, boolean strict, int iterations) {
-<span class="nc" id="L983">        final int[] nPlusMSet = MathArrays.natural(m + n);</span>
-<span class="nc" id="L984">        final double[] nSet = new double[n];</span>
-<span class="nc" id="L985">        final double[] mSet = new double[m];</span>
-<span class="nc" id="L986">        int tail = 0;</span>
-<span class="nc bnc" id="L987" title="All 2 branches missed.">        for (int i = 0; i &lt; iterations; i++) {</span>
-<span class="nc" id="L988">            copyPartition(nSet, mSet, nPlusMSet, n, m);</span>
-<span class="nc" id="L989">            final double curD = kolmogorovSmirnovStatistic(nSet, mSet);</span>
-<span class="nc bnc" id="L990" title="All 2 branches missed.">            if (curD &gt; d) {</span>
-<span class="nc" id="L991">                tail++;</span>
-<span class="nc bnc" id="L992" title="All 4 branches missed.">            } else if (curD == d &amp;&amp; !strict) {</span>
-<span class="nc" id="L993">                tail++;</span>
-            }
-<span class="nc" id="L995">            MathArrays.shuffle(nPlusMSet, rng);</span>
-<span class="nc" id="L996">            Arrays.sort(nPlusMSet, 0, n);</span>
-        }
-<span class="nc" id="L998">        return (double) tail / iterations;</span>
-    }
-
-    /**
-     * Copies the first {@code n} elements of {@code nSetI} into {@code nSet} and its complement
-     * relative to {@code m + n} into {@code mSet}. For example, if {@code m = 3}, {@code n = 3} and
-     * {@code nSetI = [1,4,5,2,3,0]} then after this method returns, we will have
-     * {@code nSet = [1,4,5], mSet = [0,2,3]}.
-     * &lt;p&gt;
-     * &lt;strong&gt;Precondition:&lt;/strong&gt; The first {@code n} elements of {@code nSetI} must be sorted
-     * in ascending order.
-     * &lt;/p&gt;
-     *
-     * @param nSet array to fill with the first {@code n} elements of {@code nSetI}
-     * @param mSet array to fill with the {@code m} complementary elements of {@code nSet} relative
-     *        to {@code m + n}
-     * @param nSetI array whose first {@code n} elements specify the members of {@code nSet}
-     * @param n number of elements in the first output array
-     * @param m number of elements in the second output array
-     */
-    private void copyPartition(double[] nSet, double[] mSet, int[] nSetI, int n, int m) {
-<span class="nc" id="L1019">        int j = 0;</span>
-<span class="nc" id="L1020">        int k = 0;</span>
-<span class="nc bnc" id="L1021" title="All 2 branches missed.">        for (int i = 0; i &lt; n + m; i++) {</span>
-<span class="nc bnc" id="L1022" title="All 4 branches missed.">            if (j &lt; n &amp;&amp; nSetI[j] == i) {</span>
-<span class="nc" id="L1023">                nSet[j++] = i;</span>
-            } else {
-<span class="nc" id="L1025">                mSet[k++] = i;</span>
+    public double monteCarloP(final double d, final int n, final int m, final boolean strict,
+                              final int iterations) {
+        // ensure that nn is always the max of (n, m) to require fewer random numbers
+<span class="fc" id="L978">        final int nn = FastMath.max(n, m);</span>
+<span class="fc" id="L979">        final int mm = FastMath.min(n, m);</span>
+<span class="fc" id="L980">        final int sum = nn + mm;</span>
+<span class="fc" id="L981">        final double tol = 1e-12;  // d-values within tol of one another are considered equal</span>
+
+<span class="fc" id="L983">        int tail = 0;</span>
+<span class="fc" id="L984">        final boolean b[] = new boolean[sum];</span>
+<span class="fc bfc" id="L985" title="All 2 branches covered.">        for (int i = 0; i &lt; iterations; i++) {</span>
+<span class="fc" id="L986">            fillBooleanArrayRandomlyWithFixedNumberTrueValues(b, nn, rng);</span>
+<span class="fc bfc" id="L987" title="All 2 branches covered.">            int rankN = b[0] ? 1 : 0;</span>
+<span class="fc bfc" id="L988" title="All 2 branches covered.">            int rankM = b[0] ? 0 : 1;</span>
+<span class="fc" id="L989">            boolean previous = b[0];</span>
+<span class="fc bfc" id="L990" title="All 2 branches covered.">            for(int j = 1; j &lt; b.length; ++j) {</span>
+<span class="fc bfc" id="L991" title="All 2 branches covered.">                if (b[j] != previous) {</span>
+<span class="fc" id="L992">                    final double cdf_n = rankN / (double) nn;</span>
+<span class="fc" id="L993">                    final double cdf_m = rankM / (double) mm;</span>
+<span class="fc" id="L994">                    final double curD = FastMath.abs(cdf_n - cdf_m);</span>
+<span class="fc" id="L995">                    final int order = Precision.compareTo(curD, d, tol);</span>
+<span class="pc bpc" id="L996" title="1 of 6 branches missed.">                    if (order &gt; 0 || (order == 0 &amp;&amp; !strict)) {</span>
+<span class="fc" id="L997">                        tail++;</span>
+<span class="fc" id="L998">                        break;</span>
+                    }
+                }
+<span class="fc" id="L1001">                previous = b[j];</span>
+<span class="fc bfc" id="L1002" title="All 2 branches covered.">                if (b[j]) {</span>
+<span class="fc" id="L1003">                    rankN++;</span>
+                } else {
+<span class="fc" id="L1005">                    rankM++;</span>
+                }
             }
         }
-<span class="nc" id="L1028">    }</span>
+<span class="fc" id="L1009">        return (double) tail / iterations;</span>
+    }
 }
 </pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.4.201502262128</span></div></body></html>
\ No newline at end of file



Mime
View raw message