| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"> |
| <title>KolmogorovSmirnovTest (Apache Commons Math 3.3 API)</title> |
| <link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style"> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="KolmogorovSmirnovTest (Apache Commons Math 3.3 API)"; |
| } |
| //--> |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="topNav"><a name="navbar_top"> |
| <!-- --> |
| </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="class-use/KolmogorovSmirnovTest.html">Use</a></li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../../../help-doc.html">Help</a></li> |
| </ul> |
| <div class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../../../org/apache/commons/math3/stat/inference/GTest.html" title="class in org.apache.commons.math3.stat.inference"><span class="strong">Prev Class</span></a></li> |
| <li><a href="../../../../../../org/apache/commons/math3/stat/inference/MannWhitneyUTest.html" title="class in org.apache.commons.math3.stat.inference"><span class="strong">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../../index.html?org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html" target="_top">Frames</a></li> |
| <li><a href="KolmogorovSmirnovTest.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_top"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li><a href="#field_summary">Field</a> | </li> |
| <li><a href="#constructor_summary">Constr</a> | </li> |
| <li><a href="#method_summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li><a href="#field_detail">Field</a> | </li> |
| <li><a href="#constructor_detail">Constr</a> | </li> |
| <li><a href="#method_detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip-navbar_top"> |
| <!-- --> |
| </a></div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="subTitle">org.apache.commons.math3.stat.inference</div> |
| <h2 title="Class KolmogorovSmirnovTest" class="title">Class KolmogorovSmirnovTest</h2> |
| </div> |
| <div class="contentContainer"> |
| <ul class="inheritance"> |
| <li><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li> |
| <li> |
| <ul class="inheritance"> |
| <li>org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest</li> |
| </ul> |
| </li> |
| </ul> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <hr> |
| <br> |
| <pre>public class <span class="strong">KolmogorovSmirnovTest</span> |
| extends <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre> |
| <div class="block">Implementation of the <a href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> |
| Kolmogorov-Smirnov (K-S) test</a> for equality of continuous distributions. |
| <p> |
| The K-S test uses a statistic based on the maximum deviation of the empirical distribution of |
| sample data points from the distribution expected under the null hypothesis. For one-sample tests |
| evaluating the null hypothesis that a set of sample data points follow a given distribution, the |
| test statistic is \(D_n=\sup_x |F_n(x)-F(x)|\), where \(F\) is the expected distribution and |
| \(F_n\) is the empirical distribution of the \(n\) sample data points. The distribution of |
| \(D_n\) is estimated using a method based on [1] with certain quick decisions for extreme values |
| given in [2]. |
| </p> |
| <p> |
| Two-sample tests are also supported, evaluating the null hypothesis that the two samples |
| <code>x</code> and <code>y</code> come from the same underlying distribution. In this case, the test |
| statistic is \(D_{n,m}=\sup_t | F_n(t)-F_m(t)|\) where \(n\) is the length of <code>x</code>, \(m\) is |
| the length of <code>y</code>, \(F_n\) is the empirical distribution that puts mass \(1/n\) at each of |
| the values in <code>x</code> and \(F_m\) is the empirical distribution of the <code>y</code> values. The |
| default 2-sample test method, <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovTest(double[], double[])"><code>kolmogorovSmirnovTest(double[], double[])</code></a> works as |
| follows: |
| <ul> |
| <li>For very small samples (where the product of the sample sizes is less than |
| <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#SMALL_SAMPLE_PRODUCT">200</a>), the exact distribution is used to compute the p-value for the |
| 2-sample test.</li> |
| <li>For mid-size samples (product of sample sizes greater than or equal to |
| <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#SMALL_SAMPLE_PRODUCT">200</a> but less than <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#LARGE_SAMPLE_PRODUCT">10000</a>), Monte Carlo |
| simulation is used to compute the p-value. The simulation randomly generates partitions of \(m + |
| n\) into an \(m\)-set and an \(n\)-set and reports the proportion that give \(D\) values |
| exceeding the observed value.</li> |
| <li>When the product of the sample sizes exceeds <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#LARGE_SAMPLE_PRODUCT">10000</a>, the asymptotic |
| distribution of \(D_{n,m}\) is used. See <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#approximateP(double, int, int)"><code>approximateP(double, int, int)</code></a> for details on |
| the approximation.</li> |
| </ul> |
| </p> |
| <p> |
| In the two-sample case, \(D_{n,m}\) has a discrete distribution. This makes the p-value |
| associated with the null hypothesis \(H_0 : D_{n,m} \ge d \) differ from \(H_0 : D_{n,m} > d \) |
| by the mass of the observed value \(d\). To distinguish these, the two-sample tests use a boolean |
| <code>strict</code> parameter. This parameter is ignored for large samples. |
| </p> |
| <p> |
| The methods used by the 2-sample default implementation are also exposed directly: |
| <ul> |
| <li><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#exactP(double, int, int, boolean)"><code>exactP(double, int, int, boolean)</code></a> computes exact 2-sample p-values</li> |
| <li><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#monteCarloP(double, int, int, boolean, int)"><code>monteCarloP(double, int, int, boolean, int)</code></a> computes 2-sample p-values by Monte |
| Carlo simulation</li> |
| <li><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#approximateP(double, int, int)"><code>approximateP(double, int, int)</code></a> uses the asymptotic distribution The <code>boolean</code> |
| arguments in the first two methods allow the probability used to estimate the p-value to be |
| expressed using strict or non-strict inequality. See |
| <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovTest(double[], double[], boolean)"><code>kolmogorovSmirnovTest(double[], double[], boolean)</code></a>.</li> |
| </ul> |
| </p> |
| <p> |
| References: |
| <ul> |
| <li>[1] <a href="http://www.jstatsoft.org/v08/i18/"> Evaluating Kolmogorov's Distribution</a> by |
| George Marsaglia, Wai Wan Tsang, and Jingbo Wang</li> |
| <li>[2] <a href="http://www.jstatsoft.org/v39/i11/"> Computing the Two-Sided Kolmogorov-Smirnov |
| Distribution</a> by Richard Simard and Pierre L'Ecuyer</li> |
| </ul> |
| <br/> |
| Note that [1] contains an error in computing h, refer to <a |
| href="https://issues.apache.org/jira/browse/MATH-437">MATH-437</a> for details. |
| </p></div> |
| <dl><dt><span class="strong">Since:</span></dt> |
| <dd>3.3</dd> |
| <dt><span class="strong">Version:</span></dt> |
| <dd>$Id: KolmogorovSmirnovTest.java 1591211 2014-04-30 08:20:51Z luc $</dd></dl> |
| </li> |
| </ul> |
| </div> |
| <div class="summary"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- =========== FIELD SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="field_summary"> |
| <!-- --> |
| </a> |
| <h3>Field Summary</h3> |
| <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation"> |
| <caption><span>Fields</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Field and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>protected static double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#KS_SUM_CAUCHY_CRITERION">KS_SUM_CAUCHY_CRITERION</a></strong></code> |
| <div class="block">Convergence criterion for <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#ksSum(double, double, int)"><code>ksSum(double, double, int)</code></a></div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>protected static int</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#LARGE_SAMPLE_PRODUCT">LARGE_SAMPLE_PRODUCT</a></strong></code> |
| <div class="block">When product of sample sizes exceeds this value, 2-sample K-S test uses asymptotic |
| distribution for strict inequality p-value.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>protected static int</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#MAXIMUM_PARTIAL_SUM_COUNT">MAXIMUM_PARTIAL_SUM_COUNT</a></strong></code> |
| <div class="block">Bound on the number of partial sums in <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#ksSum(double, double, int)"><code>ksSum(double, double, int)</code></a></div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>protected static int</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#MONTE_CARLO_ITERATIONS">MONTE_CARLO_ITERATIONS</a></strong></code> |
| <div class="block">Default number of iterations used by <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#monteCarloP(double, int, int, boolean, int)"><code>monteCarloP(double, int, int, boolean, int)</code></a></div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>protected static int</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#SMALL_SAMPLE_PRODUCT">SMALL_SAMPLE_PRODUCT</a></strong></code> |
| <div class="block">When product of sample sizes is less than this value, 2-sample K-S test is exact</div> |
| </td> |
| </tr> |
| </table> |
| </li> |
| </ul> |
| <!-- ======== CONSTRUCTOR SUMMARY ======== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="constructor_summary"> |
| <!-- --> |
| </a> |
| <h3>Constructor Summary</h3> |
| <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation"> |
| <caption><span>Constructors</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colOne" scope="col">Constructor and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colOne"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#KolmogorovSmirnovTest()">KolmogorovSmirnovTest</a></strong>()</code> |
| <div class="block">Construct a KolmogorovSmirnovTest instance with a default random data generator.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colOne"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#KolmogorovSmirnovTest(org.apache.commons.math3.random.RandomGenerator)">KolmogorovSmirnovTest</a></strong>(<a href="../../../../../../org/apache/commons/math3/random/RandomGenerator.html" title="interface in org.apache.commons.math3.random">RandomGenerator</a> rng)</code> |
| <div class="block">Construct a KolmogorovSmirnovTest with the provided random data generator.</div> |
| </td> |
| </tr> |
| </table> |
| </li> |
| </ul> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method_summary"> |
| <!-- --> |
| </a> |
| <h3>Method Summary</h3> |
| <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> |
| <caption><span>Methods</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Method and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#approximateP(double, int, int)">approximateP</a></strong>(double d, |
| int n, |
| int m)</code> |
| <div class="block">Uses the Kolmogorov-Smirnov distribution to approximate \(P(D_{n,m} > d)\) where \(D_{n,m}\) |
| is the 2-sample Kolmogorov-Smirnov statistic.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#cdf(double, int)">cdf</a></strong>(double d, |
| int n)</code> |
| <div class="block">Calculates \(P(D_n < d)\) using the method described in [1] with quick decisions for extreme |
| values given in [2] (see above).</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#cdf(double, int, boolean)">cdf</a></strong>(double d, |
| int n, |
| boolean exact)</code> |
| <div class="block">Calculates <code>P(D_n < d)</code> using method described in [1] with quick decisions for extreme |
| values given in [2] (see above).</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#cdfExact(double, int)">cdfExact</a></strong>(double d, |
| int n)</code> |
| <div class="block">Calculates <code>P(D_n < d)</code>.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#exactP(double, int, int, boolean)">exactP</a></strong>(double d, |
| int n, |
| int m, |
| boolean strict)</code> |
| <div class="block">Computes \(P(D_{n,m} > d)\) if <code>strict</code> is <code>true</code>; otherwise \(P(D_{n,m} \ge |
| d)\), where \(D_{n,m}\) is the 2-sample Kolmogorov-Smirnov statistic.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovStatistic(double[], double[])">kolmogorovSmirnovStatistic</a></strong>(double[] x, |
| double[] y)</code> |
| <div class="block">Computes the two-sample Kolmogorov-Smirnov test statistic, \(D_{n,m}=\sup_x |F_n(x)-F_m(x)|\) |
| where \(n\) is the length of <code>x</code>, \(m\) is the length of <code>y</code>, \(F_n\) is the |
| empirical distribution that puts mass \(1/n\) at each of the values in <code>x</code> and \(F_m\) |
| is the empirical distribution of the <code>y</code> values.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovStatistic(org.apache.commons.math3.distribution.RealDistribution, double[])">kolmogorovSmirnovStatistic</a></strong>(<a href="../../../../../../org/apache/commons/math3/distribution/RealDistribution.html" title="interface in org.apache.commons.math3.distribution">RealDistribution</a> distribution, |
| double[] data)</code> |
| <div class="block">Computes the one-sample Kolmogorov-Smirnov test statistic, \(D_n=\sup_x |F_n(x)-F(x)|\) where |
| \(F\) is the distribution (cdf) function associated with <code>distribution</code>, \(n\) is the |
| length of <code>data</code> and \(F_n\) is the empirical distribution that puts mass \(1/n\) at |
| each of the values in <code>data</code>.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovTest(double[], double[])">kolmogorovSmirnovTest</a></strong>(double[] x, |
| double[] y)</code> |
| <div class="block">Computes the <i>p-value</i>, or <i>observed significance level</i>, of a two-sample <a |
| href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov test</a> |
| evaluating the null hypothesis that <code>x</code> and <code>y</code> are samples drawn from the same |
| probability distribution.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovTest(double[], double[], boolean)">kolmogorovSmirnovTest</a></strong>(double[] x, |
| double[] y, |
| boolean strict)</code> |
| <div class="block">Computes the <i>p-value</i>, or <i>observed significance level</i>, of a two-sample <a |
| href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov test</a> |
| evaluating the null hypothesis that <code>x</code> and <code>y</code> are samples drawn from the same |
| probability distribution.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovTest(org.apache.commons.math3.distribution.RealDistribution, double[])">kolmogorovSmirnovTest</a></strong>(<a href="../../../../../../org/apache/commons/math3/distribution/RealDistribution.html" title="interface in org.apache.commons.math3.distribution">RealDistribution</a> distribution, |
| double[] data)</code> |
| <div class="block">Computes the <i>p-value</i>, or <i>observed significance level</i>, of a one-sample <a |
| href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov test</a> |
| evaluating the null hypothesis that <code>data</code> conforms to <code>distribution</code>.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovTest(org.apache.commons.math3.distribution.RealDistribution, double[], boolean)">kolmogorovSmirnovTest</a></strong>(<a href="../../../../../../org/apache/commons/math3/distribution/RealDistribution.html" title="interface in org.apache.commons.math3.distribution">RealDistribution</a> distribution, |
| double[] data, |
| boolean exact)</code> |
| <div class="block">Computes the <i>p-value</i>, or <i>observed significance level</i>, of a one-sample <a |
| href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov test</a> |
| evaluating the null hypothesis that <code>data</code> conforms to <code>distribution</code>.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>boolean</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovTest(org.apache.commons.math3.distribution.RealDistribution, double[], double)">kolmogorovSmirnovTest</a></strong>(<a href="../../../../../../org/apache/commons/math3/distribution/RealDistribution.html" title="interface in org.apache.commons.math3.distribution">RealDistribution</a> distribution, |
| double[] data, |
| double alpha)</code> |
| <div class="block">Performs a <a href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov |
| test</a> evaluating the null hypothesis that <code>data</code> conforms to <code>distribution</code>.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#ksSum(double, double, int)">ksSum</a></strong>(double t, |
| double tolerance, |
| int maxIterations)</code> |
| <div class="block">Computes \( 1 + 2 \sum_{i=1}^\infty (-1)^i e^{-2 i^2 t^2} \) stopping when successive partial |
| sums are within <code>tolerance</code> of one another, or when <code>maxIterations</code> partial sums |
| have been computed.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>double</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#monteCarloP(double, int, int, boolean, int)">monteCarloP</a></strong>(double d, |
| int n, |
| int m, |
| boolean strict, |
| int iterations)</code> |
| <div class="block">Uses Monte Carlo simulation to approximate \(P(D_{n,m} > d)\) where \(D_{n,m}\) is the |
| 2-sample Kolmogorov-Smirnov statistic.</div> |
| </td> |
| </tr> |
| </table> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods_inherited_from_class_java.lang.Object"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class java.lang.<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3> |
| <code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</a></code></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="details"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ============ FIELD DETAIL =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="field_detail"> |
| <!-- --> |
| </a> |
| <h3>Field Detail</h3> |
| <a name="MAXIMUM_PARTIAL_SUM_COUNT"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>MAXIMUM_PARTIAL_SUM_COUNT</h4> |
| <pre>protected static final int MAXIMUM_PARTIAL_SUM_COUNT</pre> |
| <div class="block">Bound on the number of partial sums in <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#ksSum(double, double, int)"><code>ksSum(double, double, int)</code></a></div> |
| <dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../../constant-values.html#org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest.MAXIMUM_PARTIAL_SUM_COUNT">Constant Field Values</a></dd></dl> |
| </li> |
| </ul> |
| <a name="KS_SUM_CAUCHY_CRITERION"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>KS_SUM_CAUCHY_CRITERION</h4> |
| <pre>protected static final double KS_SUM_CAUCHY_CRITERION</pre> |
| <div class="block">Convergence criterion for <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#ksSum(double, double, int)"><code>ksSum(double, double, int)</code></a></div> |
| <dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../../constant-values.html#org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest.KS_SUM_CAUCHY_CRITERION">Constant Field Values</a></dd></dl> |
| </li> |
| </ul> |
| <a name="SMALL_SAMPLE_PRODUCT"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>SMALL_SAMPLE_PRODUCT</h4> |
| <pre>protected static final int SMALL_SAMPLE_PRODUCT</pre> |
| <div class="block">When product of sample sizes is less than this value, 2-sample K-S test is exact</div> |
| <dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../../constant-values.html#org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest.SMALL_SAMPLE_PRODUCT">Constant Field Values</a></dd></dl> |
| </li> |
| </ul> |
| <a name="LARGE_SAMPLE_PRODUCT"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>LARGE_SAMPLE_PRODUCT</h4> |
| <pre>protected static final int LARGE_SAMPLE_PRODUCT</pre> |
| <div class="block">When product of sample sizes exceeds this value, 2-sample K-S test uses asymptotic |
| distribution for strict inequality p-value.</div> |
| <dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../../constant-values.html#org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest.LARGE_SAMPLE_PRODUCT">Constant Field Values</a></dd></dl> |
| </li> |
| </ul> |
| <a name="MONTE_CARLO_ITERATIONS"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>MONTE_CARLO_ITERATIONS</h4> |
| <pre>protected static final int MONTE_CARLO_ITERATIONS</pre> |
| <div class="block">Default number of iterations used by <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#monteCarloP(double, int, int, boolean, int)"><code>monteCarloP(double, int, int, boolean, int)</code></a></div> |
| <dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../../constant-values.html#org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest.MONTE_CARLO_ITERATIONS">Constant Field Values</a></dd></dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <!-- ========= CONSTRUCTOR DETAIL ======== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="constructor_detail"> |
| <!-- --> |
| </a> |
| <h3>Constructor Detail</h3> |
| <a name="KolmogorovSmirnovTest()"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>KolmogorovSmirnovTest</h4> |
| <pre>public KolmogorovSmirnovTest()</pre> |
| <div class="block">Construct a KolmogorovSmirnovTest instance with a default random data generator.</div> |
| </li> |
| </ul> |
| <a name="KolmogorovSmirnovTest(org.apache.commons.math3.random.RandomGenerator)"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>KolmogorovSmirnovTest</h4> |
| <pre>public KolmogorovSmirnovTest(<a href="../../../../../../org/apache/commons/math3/random/RandomGenerator.html" title="interface in org.apache.commons.math3.random">RandomGenerator</a> rng)</pre> |
| <div class="block">Construct a KolmogorovSmirnovTest with the provided random data generator.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>rng</code> - random data generator used by <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#monteCarloP(double, int, int, boolean, int)"><code>monteCarloP(double, int, int, boolean, int)</code></a></dd></dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <!-- ============ METHOD DETAIL ========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method_detail"> |
| <!-- --> |
| </a> |
| <h3>Method Detail</h3> |
| <a name="kolmogorovSmirnovTest(org.apache.commons.math3.distribution.RealDistribution, double[], boolean)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>kolmogorovSmirnovTest</h4> |
| <pre>public double kolmogorovSmirnovTest(<a href="../../../../../../org/apache/commons/math3/distribution/RealDistribution.html" title="interface in org.apache.commons.math3.distribution">RealDistribution</a> distribution, |
| double[] data, |
| boolean exact)</pre> |
| <div class="block">Computes the <i>p-value</i>, or <i>observed significance level</i>, of a one-sample <a |
| href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov test</a> |
| evaluating the null hypothesis that <code>data</code> conforms to <code>distribution</code>. If |
| <code>exact</code> is true, the distribution used to compute the p-value is computed using |
| extended precision. See <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#cdfExact(double, int)"><code>cdfExact(double, int)</code></a>.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>distribution</code> - reference distribution</dd><dd><code>data</code> - sample being being evaluated</dd><dd><code>exact</code> - whether or not to force exact computation of the p-value</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>the p-value associated with the null hypothesis that <code>data</code> is a sample from |
| <code>distribution</code></dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/InsufficientDataException.html" title="class in org.apache.commons.math3.exception">InsufficientDataException</a></code> - if <code>data</code> does not have length at least 2</dd> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/NullArgumentException.html" title="class in org.apache.commons.math3.exception">NullArgumentException</a></code> - if <code>data</code> is null</dd></dl> |
| </li> |
| </ul> |
| <a name="kolmogorovSmirnovStatistic(org.apache.commons.math3.distribution.RealDistribution, double[])"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>kolmogorovSmirnovStatistic</h4> |
| <pre>public double kolmogorovSmirnovStatistic(<a href="../../../../../../org/apache/commons/math3/distribution/RealDistribution.html" title="interface in org.apache.commons.math3.distribution">RealDistribution</a> distribution, |
| double[] data)</pre> |
| <div class="block">Computes the one-sample Kolmogorov-Smirnov test statistic, \(D_n=\sup_x |F_n(x)-F(x)|\) where |
| \(F\) is the distribution (cdf) function associated with <code>distribution</code>, \(n\) is the |
| length of <code>data</code> and \(F_n\) is the empirical distribution that puts mass \(1/n\) at |
| each of the values in <code>data</code>.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>distribution</code> - reference distribution</dd><dd><code>data</code> - sample being evaluated</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>Kolmogorov-Smirnov statistic \(D_n\)</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/InsufficientDataException.html" title="class in org.apache.commons.math3.exception">InsufficientDataException</a></code> - if <code>data</code> does not have length at least 2</dd> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/NullArgumentException.html" title="class in org.apache.commons.math3.exception">NullArgumentException</a></code> - if <code>data</code> is null</dd></dl> |
| </li> |
| </ul> |
| <a name="kolmogorovSmirnovTest(double[], double[], boolean)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>kolmogorovSmirnovTest</h4> |
| <pre>public double kolmogorovSmirnovTest(double[] x, |
| double[] y, |
| boolean strict)</pre> |
| <div class="block">Computes the <i>p-value</i>, or <i>observed significance level</i>, of a two-sample <a |
| href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov test</a> |
| evaluating the null hypothesis that <code>x</code> and <code>y</code> are samples drawn from the same |
| probability distribution. Specifically, what is returned is an estimate of the probability |
| that the <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovStatistic(double[], double[])"><code>kolmogorovSmirnovStatistic(double[], double[])</code></a> associated with a randomly |
| selected partition of the combined sample into subsamples of sizes <code>x.length</code> and |
| <code>y.length</code> will strictly exceed (if <code>strict</code> is <code>true</code>) or be at least as |
| large as <code>strict = false</code>) as <code>kolmogorovSmirnovStatistic(x, y)</code>. |
| <ul> |
| <li>For very small samples (where the product of the sample sizes is less than |
| <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#SMALL_SAMPLE_PRODUCT">200</a>), the exact distribution is used to compute the p-value. This |
| is accomplished by enumerating all partitions of the combined sample into two subsamples of |
| the respective sample sizes, computing \(D_{n,m}\) for each partition and returning the |
| proportion of partitions that give \(D\) values exceeding the observed value.</li> |
| <li>For mid-size samples (product of sample sizes greater than or equal to |
| <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#SMALL_SAMPLE_PRODUCT">200</a> but less than <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#LARGE_SAMPLE_PRODUCT">10000</a>), Monte Carlo |
| simulation is used to compute the p-value. The simulation randomly generates partitions and |
| reports the proportion that give \(D\) values exceeding the observed value.</li> |
| <li>When the product of the sample sizes exceeds <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#LARGE_SAMPLE_PRODUCT">10000</a>, the |
| asymptotic distribution of \(D_{n,m}\) is used. See <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#approximateP(double, int, int)"><code>approximateP(double, int, int)</code></a> |
| for details on the approximation.</li> |
| </ul></div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first sample dataset</dd><dd><code>y</code> - second sample dataset</dd><dd><code>strict</code> - whether or not the probability to compute is expressed as a strict inequality |
| (ignored for large samples)</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>p-value associated with the null hypothesis that <code>x</code> and <code>y</code> represent |
| samples from the same distribution</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/InsufficientDataException.html" title="class in org.apache.commons.math3.exception">InsufficientDataException</a></code> - if either <code>x</code> or <code>y</code> does not have length at |
| least 2</dd> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/NullArgumentException.html" title="class in org.apache.commons.math3.exception">NullArgumentException</a></code> - if either <code>x</code> or <code>y</code> is null</dd></dl> |
| </li> |
| </ul> |
| <a name="kolmogorovSmirnovTest(double[], double[])"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>kolmogorovSmirnovTest</h4> |
| <pre>public double kolmogorovSmirnovTest(double[] x, |
| double[] y)</pre> |
| <div class="block">Computes the <i>p-value</i>, or <i>observed significance level</i>, of a two-sample <a |
| href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov test</a> |
| evaluating the null hypothesis that <code>x</code> and <code>y</code> are samples drawn from the same |
| probability distribution. Assumes the strict form of the inequality used to compute the |
| p-value. See <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovTest(org.apache.commons.math3.distribution.RealDistribution, double[], boolean)"><code>kolmogorovSmirnovTest(RealDistribution, double[], boolean)</code></a>.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first sample dataset</dd><dd><code>y</code> - second sample dataset</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>p-value associated with the null hypothesis that <code>x</code> and <code>y</code> represent |
| samples from the same distribution</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/InsufficientDataException.html" title="class in org.apache.commons.math3.exception">InsufficientDataException</a></code> - if either <code>x</code> or <code>y</code> does not have length at |
| least 2</dd> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/NullArgumentException.html" title="class in org.apache.commons.math3.exception">NullArgumentException</a></code> - if either <code>x</code> or <code>y</code> is null</dd></dl> |
| </li> |
| </ul> |
| <a name="kolmogorovSmirnovStatistic(double[], double[])"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>kolmogorovSmirnovStatistic</h4> |
| <pre>public double kolmogorovSmirnovStatistic(double[] x, |
| double[] y)</pre> |
| <div class="block">Computes the two-sample Kolmogorov-Smirnov test statistic, \(D_{n,m}=\sup_x |F_n(x)-F_m(x)|\) |
| where \(n\) is the length of <code>x</code>, \(m\) is the length of <code>y</code>, \(F_n\) is the |
| empirical distribution that puts mass \(1/n\) at each of the values in <code>x</code> and \(F_m\) |
| is the empirical distribution of the <code>y</code> values.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first sample</dd><dd><code>y</code> - second sample</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>test statistic \(D_{n,m}\) used to evaluate the null hypothesis that <code>x</code> and |
| <code>y</code> represent samples from the same underlying distribution</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/InsufficientDataException.html" title="class in org.apache.commons.math3.exception">InsufficientDataException</a></code> - if either <code>x</code> or <code>y</code> does not have length at |
| least 2</dd> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/NullArgumentException.html" title="class in org.apache.commons.math3.exception">NullArgumentException</a></code> - if either <code>x</code> or <code>y</code> is null</dd></dl> |
| </li> |
| </ul> |
| <a name="kolmogorovSmirnovTest(org.apache.commons.math3.distribution.RealDistribution, double[])"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>kolmogorovSmirnovTest</h4> |
| <pre>public double kolmogorovSmirnovTest(<a href="../../../../../../org/apache/commons/math3/distribution/RealDistribution.html" title="interface in org.apache.commons.math3.distribution">RealDistribution</a> distribution, |
| double[] data)</pre> |
| <div class="block">Computes the <i>p-value</i>, or <i>observed significance level</i>, of a one-sample <a |
| href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov test</a> |
| evaluating the null hypothesis that <code>data</code> conforms to <code>distribution</code>.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>distribution</code> - reference distribution</dd><dd><code>data</code> - sample being being evaluated</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>the p-value associated with the null hypothesis that <code>data</code> is a sample from |
| <code>distribution</code></dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/InsufficientDataException.html" title="class in org.apache.commons.math3.exception">InsufficientDataException</a></code> - if <code>data</code> does not have length at least 2</dd> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/NullArgumentException.html" title="class in org.apache.commons.math3.exception">NullArgumentException</a></code> - if <code>data</code> is null</dd></dl> |
| </li> |
| </ul> |
| <a name="kolmogorovSmirnovTest(org.apache.commons.math3.distribution.RealDistribution, double[], double)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>kolmogorovSmirnovTest</h4> |
| <pre>public boolean kolmogorovSmirnovTest(<a href="../../../../../../org/apache/commons/math3/distribution/RealDistribution.html" title="interface in org.apache.commons.math3.distribution">RealDistribution</a> distribution, |
| double[] data, |
| double alpha)</pre> |
| <div class="block">Performs a <a href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov |
| test</a> evaluating the null hypothesis that <code>data</code> conforms to <code>distribution</code>.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>distribution</code> - reference distribution</dd><dd><code>data</code> - sample being being evaluated</dd><dd><code>alpha</code> - significance level of the test</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>true iff the null hypothesis that <code>data</code> is a sample from <code>distribution</code> |
| can be rejected with confidence 1 - <code>alpha</code></dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/InsufficientDataException.html" title="class in org.apache.commons.math3.exception">InsufficientDataException</a></code> - if <code>data</code> does not have length at least 2</dd> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/NullArgumentException.html" title="class in org.apache.commons.math3.exception">NullArgumentException</a></code> - if <code>data</code> is null</dd></dl> |
| </li> |
| </ul> |
| <a name="cdf(double, int)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>cdf</h4> |
| <pre>public double cdf(double d, |
| int n) |
| throws <a href="../../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre> |
| <div class="block">Calculates \(P(D_n < d)\) using the method described in [1] with quick decisions for extreme |
| values given in [2] (see above). The result is not exact as with |
| <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#cdfExact(double, int)"><code>cdfExact(double, int)</code></a> because calculations are based on |
| <code>double</code> rather than <a href="../../../../../../org/apache/commons/math3/fraction/BigFraction.html" title="class in org.apache.commons.math3.fraction"><code>BigFraction</code></a>.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>d</code> - statistic</dd><dd><code>n</code> - sample size</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>\(P(D_n < d)\)</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if algorithm fails to convert <code>h</code> to a |
| <a href="../../../../../../org/apache/commons/math3/fraction/BigFraction.html" title="class in org.apache.commons.math3.fraction"><code>BigFraction</code></a> in expressing <code>d</code> as \((k |
| - h) / m\) for integer <code>k, m</code> and \(0 \le h < 1\)</dd></dl> |
| </li> |
| </ul> |
| <a name="cdfExact(double, int)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>cdfExact</h4> |
| <pre>public double cdfExact(double d, |
| int n) |
| throws <a href="../../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre> |
| <div class="block">Calculates <code>P(D_n < d)</code>. The result is exact in the sense that BigFraction/BigReal is |
| used everywhere at the expense of very slow execution time. Almost never choose this in real |
| applications unless you are very sure; this is almost solely for verification purposes. |
| Normally, you would choose <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#cdf(double, int)"><code>cdf(double, int)</code></a>. See the class |
| javadoc for definitions and algorithm description.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>d</code> - statistic</dd><dd><code>n</code> - sample size</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>\(P(D_n < d)\)</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the algorithm fails to convert <code>h</code> to a |
| <a href="../../../../../../org/apache/commons/math3/fraction/BigFraction.html" title="class in org.apache.commons.math3.fraction"><code>BigFraction</code></a> in expressing <code>d</code> as \((k |
| - h) / m\) for integer <code>k, m</code> and \(0 \le h < 1\)</dd></dl> |
| </li> |
| </ul> |
| <a name="cdf(double, int, boolean)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>cdf</h4> |
| <pre>public double cdf(double d, |
| int n, |
| boolean exact) |
| throws <a href="../../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre> |
| <div class="block">Calculates <code>P(D_n < d)</code> using method described in [1] with quick decisions for extreme |
| values given in [2] (see above).</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>d</code> - statistic</dd><dd><code>n</code> - sample size</dd><dd><code>exact</code> - whether the probability should be calculated exact using |
| <a href="../../../../../../org/apache/commons/math3/fraction/BigFraction.html" title="class in org.apache.commons.math3.fraction"><code>BigFraction</code></a> everywhere at the expense of |
| very slow execution time, or if <code>double</code> should be used convenient places to |
| gain speed. Almost never choose <code>true</code> in real applications unless you are very |
| sure; <code>true</code> is almost solely for verification purposes.</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>\(P(D_n < d)\)</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if algorithm fails to convert <code>h</code> to a |
| <a href="../../../../../../org/apache/commons/math3/fraction/BigFraction.html" title="class in org.apache.commons.math3.fraction"><code>BigFraction</code></a> in expressing <code>d</code> as \((k |
| - h) / m\) for integer <code>k, m</code> and \(0 \le h < 1\).</dd></dl> |
| </li> |
| </ul> |
| <a name="ksSum(double, double, int)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>ksSum</h4> |
| <pre>public double ksSum(double t, |
| double tolerance, |
| int maxIterations)</pre> |
| <div class="block">Computes \( 1 + 2 \sum_{i=1}^\infty (-1)^i e^{-2 i^2 t^2} \) stopping when successive partial |
| sums are within <code>tolerance</code> of one another, or when <code>maxIterations</code> partial sums |
| have been computed. If the sum does not converge before <code>maxIterations</code> iterations a |
| <a href="../../../../../../org/apache/commons/math3/exception/TooManyIterationsException.html" title="class in org.apache.commons.math3.exception"><code>TooManyIterationsException</code></a> is thrown.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>t</code> - argument</dd><dd><code>tolerance</code> - Cauchy criterion for partial sums</dd><dd><code>maxIterations</code> - maximum number of partial sums to compute</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>Kolmogorov sum evaluated at t</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/commons/math3/exception/TooManyIterationsException.html" title="class in org.apache.commons.math3.exception">TooManyIterationsException</a></code> - if the series does not converge</dd></dl> |
| </li> |
| </ul> |
| <a name="exactP(double, int, int, boolean)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>exactP</h4> |
| <pre>public double exactP(double d, |
| int n, |
| int m, |
| boolean strict)</pre> |
| <div class="block">Computes \(P(D_{n,m} > d)\) if <code>strict</code> is <code>true</code>; otherwise \(P(D_{n,m} \ge |
| d)\), where \(D_{n,m}\) is the 2-sample Kolmogorov-Smirnov statistic. See |
| <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovStatistic(double[], double[])"><code>kolmogorovSmirnovStatistic(double[], double[])</code></a> for the definition of \(D_{n,m}\). |
| <p> |
| The returned probability is exact, obtained by enumerating all partitions of <code>m + n</code> |
| into <code>m</code> and <code>n</code> sets, computing \(D_{n,m}\) for each partition and counting the |
| number of partitions that yield \(D_{n,m}\) values exceeding (resp. greater than or equal to) |
| <code>d</code>. |
| </p> |
| <p> |
| <strong>USAGE NOTE</strong>: Since this method enumerates all combinations in \({m+n} \choose |
| {n}\), it is very slow if called for large <code>m, n</code>. For this reason, |
| <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovTest(double[], double[])"><code>kolmogorovSmirnovTest(double[], double[])</code></a> uses this only for <code>m * n < </code> |
| <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#SMALL_SAMPLE_PRODUCT">200</a>. |
| </p></div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>d</code> - D-statistic value</dd><dd><code>n</code> - first sample size</dd><dd><code>m</code> - second sample size</dd><dd><code>strict</code> - whether or not the probability to compute is expressed as a strict inequality</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>probability that a randomly selected m-n partition of m + n generates \(D_{n,m}\) |
| greater than (resp. greater than or equal to) <code>d</code></dd></dl> |
| </li> |
| </ul> |
| <a name="approximateP(double, int, int)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>approximateP</h4> |
| <pre>public double approximateP(double d, |
| int n, |
| int m)</pre> |
| <div class="block">Uses the Kolmogorov-Smirnov distribution to approximate \(P(D_{n,m} > d)\) where \(D_{n,m}\) |
| is the 2-sample Kolmogorov-Smirnov statistic. See |
| <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovStatistic(double[], double[])"><code>kolmogorovSmirnovStatistic(double[], double[])</code></a> for the definition of \(D_{n,m}\). |
| <p> |
| Specifically, what is returned is \(1 - k(d \sqrt{mn / (m + n)})\) where \(k(t) = 1 + 2 |
| \sum_{i=1}^\infty (-1)^i e^{-2 i^2 t^2}\). See <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#ksSum(double, double, int)"><code>ksSum(double, double, int)</code></a> for |
| details on how convergence of the sum is determined. This implementation passes <code>ksSum</code> |
| <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#KS_SUM_CAUCHY_CRITERION">1.0E-20</a> as <code>tolerance</code> and |
| <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#MAXIMUM_PARTIAL_SUM_COUNT">100000</a> as <code>maxIterations</code>. |
| </p></div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>d</code> - D-statistic value</dd><dd><code>n</code> - first sample size</dd><dd><code>m</code> - second sample size</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>approximate probability that a randomly selected m-n partition of m + n generates |
| \(D_{n,m}\) greater than <code>d</code></dd></dl> |
| </li> |
| </ul> |
| <a name="monteCarloP(double, int, int, boolean, int)"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>monteCarloP</h4> |
| <pre>public double monteCarloP(double d, |
| int n, |
| int m, |
| boolean strict, |
| int iterations)</pre> |
| <div class="block">Uses Monte Carlo simulation to approximate \(P(D_{n,m} > d)\) where \(D_{n,m}\) is the |
| 2-sample Kolmogorov-Smirnov statistic. See |
| <a href="../../../../../../org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html#kolmogorovSmirnovStatistic(double[], double[])"><code>kolmogorovSmirnovStatistic(double[], double[])</code></a> for the definition of \(D_{n,m}\). |
| <p> |
| The simulation generates <code>iterations</code> random partitions of <code>m + n</code> into an |
| <code>n</code> set and an <code>m</code> set, computing \(D_{n,m}\) for each partition and returning |
| the proportion of values that are greater than <code>d</code>, or greater than or equal to |
| <code>d</code> if <code>strict</code> is <code>false</code>. |
| </p></div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>d</code> - D-statistic value</dd><dd><code>n</code> - first sample size</dd><dd><code>m</code> - second sample size</dd><dd><code>iterations</code> - number of random partitions to generate</dd><dd><code>strict</code> - whether or not the probability to compute is expressed as a strict inequality</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>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</code></dd></dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| <!-- ========= END OF CLASS DATA ========= --> |
| <!-- ======= START OF BOTTOM NAVBAR ====== --> |
| <div class="bottomNav"><a name="navbar_bottom"> |
| <!-- --> |
| </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="class-use/KolmogorovSmirnovTest.html">Use</a></li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../../../help-doc.html">Help</a></li> |
| </ul> |
| <div class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../../../org/apache/commons/math3/stat/inference/GTest.html" title="class in org.apache.commons.math3.stat.inference"><span class="strong">Prev Class</span></a></li> |
| <li><a href="../../../../../../org/apache/commons/math3/stat/inference/MannWhitneyUTest.html" title="class in org.apache.commons.math3.stat.inference"><span class="strong">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../../index.html?org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html" target="_top">Frames</a></li> |
| <li><a href="KolmogorovSmirnovTest.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_bottom"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li><a href="#field_summary">Field</a> | </li> |
| <li><a href="#constructor_summary">Constr</a> | </li> |
| <li><a href="#method_summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li><a href="#field_detail">Field</a> | </li> |
| <li><a href="#constructor_detail">Constr</a> | </li> |
| <li><a href="#method_detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip-navbar_bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| <p class="legalCopy"><small>Copyright © 2003–2014 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p> |
| </body> |
| </html> |