commons-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r948064 [35/38] - in /websites/production/commons/content/proper/commons-math/testapidocs: ./ org/apache/commons/math3/ org/apache/commons/math3/analysis/ org/apache/commons/math3/analysis/class-use/ org/apache/commons/math3/analysis/differ...
Date Fri, 17 Apr 2015 19:44:43 GMT
Modified: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/random/EmpiricalDistributionTest.html
==============================================================================
--- websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/random/EmpiricalDistributionTest.html
(original)
+++ websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/random/EmpiricalDistributionTest.html
Fri Apr 17 19:43:52 2015
@@ -441,118 +441,137 @@
 <span class="sourceLineNo">433</span>    }<a name="line.433"></a>
 <span class="sourceLineNo">434</span>    <a name="line.434"></a>
 <span class="sourceLineNo">435</span>    /**<a name="line.435"></a>
-<span class="sourceLineNo">436</span>     * Find the bin that x belongs (relative
to {@link #makeDistribution()}).<a name="line.436"></a>
+<span class="sourceLineNo">436</span>     * MATH-1203, MATH-1208<a name="line.436"></a>
 <span class="sourceLineNo">437</span>     */<a name="line.437"></a>
-<span class="sourceLineNo">438</span>    private int findBin(double x) {<a
name="line.438"></a>
-<span class="sourceLineNo">439</span>        // Number of bins below x should
be trunc(x/10)<a name="line.439"></a>
-<span class="sourceLineNo">440</span>        final double nMinus = FastMath.floor(x
/ 10);<a name="line.440"></a>
-<span class="sourceLineNo">441</span>        final int bin =  (int) FastMath.round(nMinus);<a
name="line.441"></a>
-<span class="sourceLineNo">442</span>        // If x falls on a bin boundary,
it is in the lower bin<a name="line.442"></a>
-<span class="sourceLineNo">443</span>        return FastMath.floor(x / 10) ==
x / 10 ? bin - 1 : bin;<a name="line.443"></a>
-<span class="sourceLineNo">444</span>    }<a name="line.444"></a>
-<span class="sourceLineNo">445</span>    <a name="line.445"></a>
-<span class="sourceLineNo">446</span>    /**<a name="line.446"></a>
-<span class="sourceLineNo">447</span>     * Find the within-bin kernel for the
bin with lower bound lower<a name="line.447"></a>
-<span class="sourceLineNo">448</span>     * and upper bound upper. All bins other
than the first contain 10 points<a name="line.448"></a>
-<span class="sourceLineNo">449</span>     * exclusive of the lower bound and
are centered at (lower + upper + 1) / 2.<a name="line.449"></a>
-<span class="sourceLineNo">450</span>     * The first bin includes its lower
bound, 0, so has different mean and<a name="line.450"></a>
-<span class="sourceLineNo">451</span>     * standard deviation.<a name="line.451"></a>
-<span class="sourceLineNo">452</span>     */<a name="line.452"></a>
-<span class="sourceLineNo">453</span>    private RealDistribution findKernel(double
lower, double upper) {<a name="line.453"></a>
-<span class="sourceLineNo">454</span>        if (lower &lt; 1) {<a name="line.454"></a>
-<span class="sourceLineNo">455</span>            return new NormalDistribution(5d,
3.3166247903554);<a name="line.455"></a>
-<span class="sourceLineNo">456</span>        } else {<a name="line.456"></a>
-<span class="sourceLineNo">457</span>            return new NormalDistribution((upper
+ lower + 1) / 2d, 3.0276503540974917); <a name="line.457"></a>
-<span class="sourceLineNo">458</span>        }<a name="line.458"></a>
-<span class="sourceLineNo">459</span>    }<a name="line.459"></a>
-<span class="sourceLineNo">460</span>    <a name="line.460"></a>
-<span class="sourceLineNo">461</span>    @Test<a name="line.461"></a>
-<span class="sourceLineNo">462</span>    public void testKernelOverrideConstant()
{<a name="line.462"></a>
-<span class="sourceLineNo">463</span>        final EmpiricalDistribution dist
= new ConstantKernelEmpiricalDistribution(5);<a name="line.463"></a>
-<span class="sourceLineNo">464</span>        final double[] data = {1d,2d,3d,
4d,5d,6d, 7d,8d,9d, 10d,11d,12d, 13d,14d,15d};<a name="line.464"></a>
-<span class="sourceLineNo">465</span>        dist.load(data);<a name="line.465"></a>
-<span class="sourceLineNo">466</span>        // Bin masses concentrated on 2,
5, 8, 11, 14 &lt;- effectively discrete uniform distribution over these<a name="line.466"></a>
-<span class="sourceLineNo">467</span>        double[] values = {2d, 5d, 8d, 11d,
14d};<a name="line.467"></a>
-<span class="sourceLineNo">468</span>        for (int i = 0; i &lt; 20; i++)
{<a name="line.468"></a>
-<span class="sourceLineNo">469</span>            Assert.assertTrue(Arrays.binarySearch(values,
dist.sample()) &gt;= 0);<a name="line.469"></a>
-<span class="sourceLineNo">470</span>        }<a name="line.470"></a>
-<span class="sourceLineNo">471</span>        final double tol = 10E-12;<a
name="line.471"></a>
-<span class="sourceLineNo">472</span>        Assert.assertEquals(0.0, dist.cumulativeProbability(1),
tol);<a name="line.472"></a>
-<span class="sourceLineNo">473</span>        Assert.assertEquals(0.2, dist.cumulativeProbability(2),
tol);<a name="line.473"></a>
-<span class="sourceLineNo">474</span>        Assert.assertEquals(0.6, dist.cumulativeProbability(10),
tol);<a name="line.474"></a>
-<span class="sourceLineNo">475</span>        Assert.assertEquals(0.8, dist.cumulativeProbability(12),
tol);<a name="line.475"></a>
-<span class="sourceLineNo">476</span>        Assert.assertEquals(0.8, dist.cumulativeProbability(13),
tol);<a name="line.476"></a>
-<span class="sourceLineNo">477</span>        Assert.assertEquals(1.0, dist.cumulativeProbability(15),
tol);<a name="line.477"></a>
-<span class="sourceLineNo">478</span><a name="line.478"></a>
-<span class="sourceLineNo">479</span>        Assert.assertEquals(2.0, dist.inverseCumulativeProbability(0.1),
tol);<a name="line.479"></a>
-<span class="sourceLineNo">480</span>        Assert.assertEquals(2.0, dist.inverseCumulativeProbability(0.2),
tol);<a name="line.480"></a>
-<span class="sourceLineNo">481</span>        Assert.assertEquals(5.0, dist.inverseCumulativeProbability(0.3),
tol);<a name="line.481"></a>
-<span class="sourceLineNo">482</span>        Assert.assertEquals(5.0, dist.inverseCumulativeProbability(0.4),
tol);<a name="line.482"></a>
-<span class="sourceLineNo">483</span>        Assert.assertEquals(8.0, dist.inverseCumulativeProbability(0.5),
tol);<a name="line.483"></a>
-<span class="sourceLineNo">484</span>        Assert.assertEquals(8.0, dist.inverseCumulativeProbability(0.6),
tol);<a name="line.484"></a>
-<span class="sourceLineNo">485</span>    }<a name="line.485"></a>
-<span class="sourceLineNo">486</span>    <a name="line.486"></a>
-<span class="sourceLineNo">487</span>    @Test<a name="line.487"></a>
-<span class="sourceLineNo">488</span>    public void testKernelOverrideUniform()
{<a name="line.488"></a>
-<span class="sourceLineNo">489</span>        final EmpiricalDistribution dist
= new UniformKernelEmpiricalDistribution(5);<a name="line.489"></a>
-<span class="sourceLineNo">490</span>        final double[] data = {1d,2d,3d,
4d,5d,6d, 7d,8d,9d, 10d,11d,12d, 13d,14d,15d};<a name="line.490"></a>
-<span class="sourceLineNo">491</span>        dist.load(data);<a name="line.491"></a>
-<span class="sourceLineNo">492</span>        // Kernels are uniform distributions
on [1,3], [4,6], [7,9], [10,12], [13,15]<a name="line.492"></a>
-<span class="sourceLineNo">493</span>        final double bounds[] = {3d, 6d,
9d, 12d};<a name="line.493"></a>
-<span class="sourceLineNo">494</span>        final double tol = 10E-12; <a
name="line.494"></a>
-<span class="sourceLineNo">495</span>        for (int i = 0; i &lt; 20; i++)
{<a name="line.495"></a>
-<span class="sourceLineNo">496</span>            final double v = dist.sample();<a
name="line.496"></a>
-<span class="sourceLineNo">497</span>            // Make sure v is not in the
excluded range between bins - that is (bounds[i], bounds[i] + 1)<a name="line.497"></a>
-<span class="sourceLineNo">498</span>            for (int j = 0; j &lt; bounds.length;
j++) {<a name="line.498"></a>
-<span class="sourceLineNo">499</span>                Assert.assertFalse(v &gt;
bounds[j] + tol &amp;&amp; v &lt; bounds[j] + 1 - tol);<a name="line.499"></a>
-<span class="sourceLineNo">500</span>            }<a name="line.500"></a>
-<span class="sourceLineNo">501</span>        }   <a name="line.501"></a>
-<span class="sourceLineNo">502</span>        Assert.assertEquals(0.0, dist.cumulativeProbability(1),
tol);<a name="line.502"></a>
-<span class="sourceLineNo">503</span>        Assert.assertEquals(0.1, dist.cumulativeProbability(2),
tol);<a name="line.503"></a>
-<span class="sourceLineNo">504</span>        Assert.assertEquals(0.6, dist.cumulativeProbability(10),
tol);<a name="line.504"></a>
-<span class="sourceLineNo">505</span>        Assert.assertEquals(0.8, dist.cumulativeProbability(12),
tol);<a name="line.505"></a>
-<span class="sourceLineNo">506</span>        Assert.assertEquals(0.8, dist.cumulativeProbability(13),
tol);<a name="line.506"></a>
-<span class="sourceLineNo">507</span>        Assert.assertEquals(1.0, dist.cumulativeProbability(15),
tol);<a name="line.507"></a>
-<span class="sourceLineNo">508</span><a name="line.508"></a>
-<span class="sourceLineNo">509</span>        Assert.assertEquals(2.0, dist.inverseCumulativeProbability(0.1),
tol);<a name="line.509"></a>
-<span class="sourceLineNo">510</span>        Assert.assertEquals(3.0, dist.inverseCumulativeProbability(0.2),
tol);<a name="line.510"></a>
-<span class="sourceLineNo">511</span>        Assert.assertEquals(5.0, dist.inverseCumulativeProbability(0.3),
tol);<a name="line.511"></a>
-<span class="sourceLineNo">512</span>        Assert.assertEquals(6.0, dist.inverseCumulativeProbability(0.4),
tol);<a name="line.512"></a>
-<span class="sourceLineNo">513</span>        Assert.assertEquals(8.0, dist.inverseCumulativeProbability(0.5),
tol);<a name="line.513"></a>
-<span class="sourceLineNo">514</span>        Assert.assertEquals(9.0, dist.inverseCumulativeProbability(0.6),
tol);<a name="line.514"></a>
-<span class="sourceLineNo">515</span>    }<a name="line.515"></a>
-<span class="sourceLineNo">516</span>    <a name="line.516"></a>
-<span class="sourceLineNo">517</span>    <a name="line.517"></a>
-<span class="sourceLineNo">518</span>    /**<a name="line.518"></a>
-<span class="sourceLineNo">519</span>     * Empirical distribution using a constant
smoothing kernel.<a name="line.519"></a>
-<span class="sourceLineNo">520</span>     */<a name="line.520"></a>
-<span class="sourceLineNo">521</span>    private class ConstantKernelEmpiricalDistribution
extends EmpiricalDistribution {<a name="line.521"></a>
-<span class="sourceLineNo">522</span>        private static final long serialVersionUID
= 1L;<a name="line.522"></a>
-<span class="sourceLineNo">523</span>        public ConstantKernelEmpiricalDistribution(int
i) {<a name="line.523"></a>
-<span class="sourceLineNo">524</span>            super(i);<a name="line.524"></a>
-<span class="sourceLineNo">525</span>        }<a name="line.525"></a>
-<span class="sourceLineNo">526</span>        // Use constant distribution equal
to bin mean within bin<a name="line.526"></a>
-<span class="sourceLineNo">527</span>        @Override<a name="line.527"></a>
-<span class="sourceLineNo">528</span>        protected RealDistribution getKernel(SummaryStatistics
bStats) {<a name="line.528"></a>
-<span class="sourceLineNo">529</span>            return new ConstantRealDistribution(bStats.getMean());<a
name="line.529"></a>
-<span class="sourceLineNo">530</span>        }<a name="line.530"></a>
-<span class="sourceLineNo">531</span>    }<a name="line.531"></a>
-<span class="sourceLineNo">532</span>    <a name="line.532"></a>
-<span class="sourceLineNo">533</span>    /**<a name="line.533"></a>
-<span class="sourceLineNo">534</span>     * Empirical distribution using a uniform
smoothing kernel.<a name="line.534"></a>
-<span class="sourceLineNo">535</span>     */<a name="line.535"></a>
-<span class="sourceLineNo">536</span>    private class UniformKernelEmpiricalDistribution
extends EmpiricalDistribution {<a name="line.536"></a>
-<span class="sourceLineNo">537</span>        private static final long serialVersionUID
= 2963149194515159653L;<a name="line.537"></a>
-<span class="sourceLineNo">538</span>        public UniformKernelEmpiricalDistribution(int
i) {<a name="line.538"></a>
-<span class="sourceLineNo">539</span>            super(i);<a name="line.539"></a>
-<span class="sourceLineNo">540</span>        }<a name="line.540"></a>
-<span class="sourceLineNo">541</span>        @Override<a name="line.541"></a>
-<span class="sourceLineNo">542</span>        protected RealDistribution getKernel(SummaryStatistics
bStats) {<a name="line.542"></a>
-<span class="sourceLineNo">543</span>            return new UniformRealDistribution(randomData.getRandomGenerator(),
bStats.getMin(), bStats.getMax(),<a name="line.543"></a>
-<span class="sourceLineNo">544</span>                    UniformRealDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);<a
name="line.544"></a>
-<span class="sourceLineNo">545</span>        }<a name="line.545"></a>
-<span class="sourceLineNo">546</span>    }<a name="line.546"></a>
-<span class="sourceLineNo">547</span>}<a name="line.547"></a>
+<span class="sourceLineNo">438</span>    @Test<a name="line.438"></a>
+<span class="sourceLineNo">439</span>    public void testNoBinVariance() {<a
name="line.439"></a>
+<span class="sourceLineNo">440</span>        final double[] data = {0, 0, 1,
1};<a name="line.440"></a>
+<span class="sourceLineNo">441</span>        EmpiricalDistribution dist = new
EmpiricalDistribution(2);<a name="line.441"></a>
+<span class="sourceLineNo">442</span>        dist.load(data);<a name="line.442"></a>
+<span class="sourceLineNo">443</span>        dist.reseedRandomGenerator(1000);<a
name="line.443"></a>
+<span class="sourceLineNo">444</span>        for (int i = 0; i &lt; 1000;
i++) {<a name="line.444"></a>
+<span class="sourceLineNo">445</span>            final double dev = dist.sample();<a
name="line.445"></a>
+<span class="sourceLineNo">446</span>            Assert.assertTrue(dev == 0 ||
dev == 1);<a name="line.446"></a>
+<span class="sourceLineNo">447</span>        }<a name="line.447"></a>
+<span class="sourceLineNo">448</span>        Assert.assertEquals(0.5, dist.cumulativeProbability(0),
Double.MIN_VALUE);<a name="line.448"></a>
+<span class="sourceLineNo">449</span>        Assert.assertEquals(1.0, dist.cumulativeProbability(1),
Double.MIN_VALUE);<a name="line.449"></a>
+<span class="sourceLineNo">450</span>        Assert.assertEquals(0.5, dist.cumulativeProbability(0.5),
Double.MIN_VALUE);<a name="line.450"></a>
+<span class="sourceLineNo">451</span>        Assert.assertEquals(0.5, dist.cumulativeProbability(0.7),
Double.MIN_VALUE);<a name="line.451"></a>
+<span class="sourceLineNo">452</span>    }   <a name="line.452"></a>
+<span class="sourceLineNo">453</span>    <a name="line.453"></a>
+<span class="sourceLineNo">454</span>    /**<a name="line.454"></a>
+<span class="sourceLineNo">455</span>     * Find the bin that x belongs (relative
to {@link #makeDistribution()}).<a name="line.455"></a>
+<span class="sourceLineNo">456</span>     */<a name="line.456"></a>
+<span class="sourceLineNo">457</span>    private int findBin(double x) {<a
name="line.457"></a>
+<span class="sourceLineNo">458</span>        // Number of bins below x should
be trunc(x/10)<a name="line.458"></a>
+<span class="sourceLineNo">459</span>        final double nMinus = FastMath.floor(x
/ 10);<a name="line.459"></a>
+<span class="sourceLineNo">460</span>        final int bin =  (int) FastMath.round(nMinus);<a
name="line.460"></a>
+<span class="sourceLineNo">461</span>        // If x falls on a bin boundary,
it is in the lower bin<a name="line.461"></a>
+<span class="sourceLineNo">462</span>        return FastMath.floor(x / 10) ==
x / 10 ? bin - 1 : bin;<a name="line.462"></a>
+<span class="sourceLineNo">463</span>    }<a name="line.463"></a>
+<span class="sourceLineNo">464</span>    <a name="line.464"></a>
+<span class="sourceLineNo">465</span>    /**<a name="line.465"></a>
+<span class="sourceLineNo">466</span>     * Find the within-bin kernel for the
bin with lower bound lower<a name="line.466"></a>
+<span class="sourceLineNo">467</span>     * and upper bound upper. All bins other
than the first contain 10 points<a name="line.467"></a>
+<span class="sourceLineNo">468</span>     * exclusive of the lower bound and
are centered at (lower + upper + 1) / 2.<a name="line.468"></a>
+<span class="sourceLineNo">469</span>     * The first bin includes its lower
bound, 0, so has different mean and<a name="line.469"></a>
+<span class="sourceLineNo">470</span>     * standard deviation.<a name="line.470"></a>
+<span class="sourceLineNo">471</span>     */<a name="line.471"></a>
+<span class="sourceLineNo">472</span>    private RealDistribution findKernel(double
lower, double upper) {<a name="line.472"></a>
+<span class="sourceLineNo">473</span>        if (lower &lt; 1) {<a name="line.473"></a>
+<span class="sourceLineNo">474</span>            return new NormalDistribution(5d,
3.3166247903554);<a name="line.474"></a>
+<span class="sourceLineNo">475</span>        } else {<a name="line.475"></a>
+<span class="sourceLineNo">476</span>            return new NormalDistribution((upper
+ lower + 1) / 2d, 3.0276503540974917); <a name="line.476"></a>
+<span class="sourceLineNo">477</span>        }<a name="line.477"></a>
+<span class="sourceLineNo">478</span>    }<a name="line.478"></a>
+<span class="sourceLineNo">479</span>    <a name="line.479"></a>
+<span class="sourceLineNo">480</span>    @Test<a name="line.480"></a>
+<span class="sourceLineNo">481</span>    public void testKernelOverrideConstant()
{<a name="line.481"></a>
+<span class="sourceLineNo">482</span>        final EmpiricalDistribution dist
= new ConstantKernelEmpiricalDistribution(5);<a name="line.482"></a>
+<span class="sourceLineNo">483</span>        final double[] data = {1d,2d,3d,
4d,5d,6d, 7d,8d,9d, 10d,11d,12d, 13d,14d,15d};<a name="line.483"></a>
+<span class="sourceLineNo">484</span>        dist.load(data);<a name="line.484"></a>
+<span class="sourceLineNo">485</span>        // Bin masses concentrated on 2,
5, 8, 11, 14 &lt;- effectively discrete uniform distribution over these<a name="line.485"></a>
+<span class="sourceLineNo">486</span>        double[] values = {2d, 5d, 8d, 11d,
14d};<a name="line.486"></a>
+<span class="sourceLineNo">487</span>        for (int i = 0; i &lt; 20; i++)
{<a name="line.487"></a>
+<span class="sourceLineNo">488</span>            Assert.assertTrue(Arrays.binarySearch(values,
dist.sample()) &gt;= 0);<a name="line.488"></a>
+<span class="sourceLineNo">489</span>        }<a name="line.489"></a>
+<span class="sourceLineNo">490</span>        final double tol = 10E-12;<a
name="line.490"></a>
+<span class="sourceLineNo">491</span>        Assert.assertEquals(0.0, dist.cumulativeProbability(1),
tol);<a name="line.491"></a>
+<span class="sourceLineNo">492</span>        Assert.assertEquals(0.2, dist.cumulativeProbability(2),
tol);<a name="line.492"></a>
+<span class="sourceLineNo">493</span>        Assert.assertEquals(0.6, dist.cumulativeProbability(10),
tol);<a name="line.493"></a>
+<span class="sourceLineNo">494</span>        Assert.assertEquals(0.8, dist.cumulativeProbability(12),
tol);<a name="line.494"></a>
+<span class="sourceLineNo">495</span>        Assert.assertEquals(0.8, dist.cumulativeProbability(13),
tol);<a name="line.495"></a>
+<span class="sourceLineNo">496</span>        Assert.assertEquals(1.0, dist.cumulativeProbability(15),
tol);<a name="line.496"></a>
+<span class="sourceLineNo">497</span><a name="line.497"></a>
+<span class="sourceLineNo">498</span>        Assert.assertEquals(2.0, dist.inverseCumulativeProbability(0.1),
tol);<a name="line.498"></a>
+<span class="sourceLineNo">499</span>        Assert.assertEquals(2.0, dist.inverseCumulativeProbability(0.2),
tol);<a name="line.499"></a>
+<span class="sourceLineNo">500</span>        Assert.assertEquals(5.0, dist.inverseCumulativeProbability(0.3),
tol);<a name="line.500"></a>
+<span class="sourceLineNo">501</span>        Assert.assertEquals(5.0, dist.inverseCumulativeProbability(0.4),
tol);<a name="line.501"></a>
+<span class="sourceLineNo">502</span>        Assert.assertEquals(8.0, dist.inverseCumulativeProbability(0.5),
tol);<a name="line.502"></a>
+<span class="sourceLineNo">503</span>        Assert.assertEquals(8.0, dist.inverseCumulativeProbability(0.6),
tol);<a name="line.503"></a>
+<span class="sourceLineNo">504</span>    }<a name="line.504"></a>
+<span class="sourceLineNo">505</span>    <a name="line.505"></a>
+<span class="sourceLineNo">506</span>    @Test<a name="line.506"></a>
+<span class="sourceLineNo">507</span>    public void testKernelOverrideUniform()
{<a name="line.507"></a>
+<span class="sourceLineNo">508</span>        final EmpiricalDistribution dist
= new UniformKernelEmpiricalDistribution(5);<a name="line.508"></a>
+<span class="sourceLineNo">509</span>        final double[] data = {1d,2d,3d,
4d,5d,6d, 7d,8d,9d, 10d,11d,12d, 13d,14d,15d};<a name="line.509"></a>
+<span class="sourceLineNo">510</span>        dist.load(data);<a name="line.510"></a>
+<span class="sourceLineNo">511</span>        // Kernels are uniform distributions
on [1,3], [4,6], [7,9], [10,12], [13,15]<a name="line.511"></a>
+<span class="sourceLineNo">512</span>        final double bounds[] = {3d, 6d,
9d, 12d};<a name="line.512"></a>
+<span class="sourceLineNo">513</span>        final double tol = 10E-12; <a
name="line.513"></a>
+<span class="sourceLineNo">514</span>        for (int i = 0; i &lt; 20; i++)
{<a name="line.514"></a>
+<span class="sourceLineNo">515</span>            final double v = dist.sample();<a
name="line.515"></a>
+<span class="sourceLineNo">516</span>            // Make sure v is not in the
excluded range between bins - that is (bounds[i], bounds[i] + 1)<a name="line.516"></a>
+<span class="sourceLineNo">517</span>            for (int j = 0; j &lt; bounds.length;
j++) {<a name="line.517"></a>
+<span class="sourceLineNo">518</span>                Assert.assertFalse(v &gt;
bounds[j] + tol &amp;&amp; v &lt; bounds[j] + 1 - tol);<a name="line.518"></a>
+<span class="sourceLineNo">519</span>            }<a name="line.519"></a>
+<span class="sourceLineNo">520</span>        }   <a name="line.520"></a>
+<span class="sourceLineNo">521</span>        Assert.assertEquals(0.0, dist.cumulativeProbability(1),
tol);<a name="line.521"></a>
+<span class="sourceLineNo">522</span>        Assert.assertEquals(0.1, dist.cumulativeProbability(2),
tol);<a name="line.522"></a>
+<span class="sourceLineNo">523</span>        Assert.assertEquals(0.6, dist.cumulativeProbability(10),
tol);<a name="line.523"></a>
+<span class="sourceLineNo">524</span>        Assert.assertEquals(0.8, dist.cumulativeProbability(12),
tol);<a name="line.524"></a>
+<span class="sourceLineNo">525</span>        Assert.assertEquals(0.8, dist.cumulativeProbability(13),
tol);<a name="line.525"></a>
+<span class="sourceLineNo">526</span>        Assert.assertEquals(1.0, dist.cumulativeProbability(15),
tol);<a name="line.526"></a>
+<span class="sourceLineNo">527</span><a name="line.527"></a>
+<span class="sourceLineNo">528</span>        Assert.assertEquals(2.0, dist.inverseCumulativeProbability(0.1),
tol);<a name="line.528"></a>
+<span class="sourceLineNo">529</span>        Assert.assertEquals(3.0, dist.inverseCumulativeProbability(0.2),
tol);<a name="line.529"></a>
+<span class="sourceLineNo">530</span>        Assert.assertEquals(5.0, dist.inverseCumulativeProbability(0.3),
tol);<a name="line.530"></a>
+<span class="sourceLineNo">531</span>        Assert.assertEquals(6.0, dist.inverseCumulativeProbability(0.4),
tol);<a name="line.531"></a>
+<span class="sourceLineNo">532</span>        Assert.assertEquals(8.0, dist.inverseCumulativeProbability(0.5),
tol);<a name="line.532"></a>
+<span class="sourceLineNo">533</span>        Assert.assertEquals(9.0, dist.inverseCumulativeProbability(0.6),
tol);<a name="line.533"></a>
+<span class="sourceLineNo">534</span>    }<a name="line.534"></a>
+<span class="sourceLineNo">535</span>    <a name="line.535"></a>
+<span class="sourceLineNo">536</span>    <a name="line.536"></a>
+<span class="sourceLineNo">537</span>    /**<a name="line.537"></a>
+<span class="sourceLineNo">538</span>     * Empirical distribution using a constant
smoothing kernel.<a name="line.538"></a>
+<span class="sourceLineNo">539</span>     */<a name="line.539"></a>
+<span class="sourceLineNo">540</span>    private class ConstantKernelEmpiricalDistribution
extends EmpiricalDistribution {<a name="line.540"></a>
+<span class="sourceLineNo">541</span>        private static final long serialVersionUID
= 1L;<a name="line.541"></a>
+<span class="sourceLineNo">542</span>        public ConstantKernelEmpiricalDistribution(int
i) {<a name="line.542"></a>
+<span class="sourceLineNo">543</span>            super(i);<a name="line.543"></a>
+<span class="sourceLineNo">544</span>        }<a name="line.544"></a>
+<span class="sourceLineNo">545</span>        // Use constant distribution equal
to bin mean within bin<a name="line.545"></a>
+<span class="sourceLineNo">546</span>        @Override<a name="line.546"></a>
+<span class="sourceLineNo">547</span>        protected RealDistribution getKernel(SummaryStatistics
bStats) {<a name="line.547"></a>
+<span class="sourceLineNo">548</span>            return new ConstantRealDistribution(bStats.getMean());<a
name="line.548"></a>
+<span class="sourceLineNo">549</span>        }<a name="line.549"></a>
+<span class="sourceLineNo">550</span>    }<a name="line.550"></a>
+<span class="sourceLineNo">551</span>    <a name="line.551"></a>
+<span class="sourceLineNo">552</span>    /**<a name="line.552"></a>
+<span class="sourceLineNo">553</span>     * Empirical distribution using a uniform
smoothing kernel.<a name="line.553"></a>
+<span class="sourceLineNo">554</span>     */<a name="line.554"></a>
+<span class="sourceLineNo">555</span>    private class UniformKernelEmpiricalDistribution
extends EmpiricalDistribution {<a name="line.555"></a>
+<span class="sourceLineNo">556</span>        private static final long serialVersionUID
= 2963149194515159653L;<a name="line.556"></a>
+<span class="sourceLineNo">557</span>        public UniformKernelEmpiricalDistribution(int
i) {<a name="line.557"></a>
+<span class="sourceLineNo">558</span>            super(i);<a name="line.558"></a>
+<span class="sourceLineNo">559</span>        }<a name="line.559"></a>
+<span class="sourceLineNo">560</span>        @Override<a name="line.560"></a>
+<span class="sourceLineNo">561</span>        protected RealDistribution getKernel(SummaryStatistics
bStats) {<a name="line.561"></a>
+<span class="sourceLineNo">562</span>            return new UniformRealDistribution(randomData.getRandomGenerator(),
bStats.getMin(), bStats.getMax(),<a name="line.562"></a>
+<span class="sourceLineNo">563</span>                    UniformRealDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);<a
name="line.563"></a>
+<span class="sourceLineNo">564</span>        }<a name="line.564"></a>
+<span class="sourceLineNo">565</span>    }<a name="line.565"></a>
+<span class="sourceLineNo">566</span>}<a name="line.566"></a>
 
 
 



Mime
View raw message