commons-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r948064 [36/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/stat/descriptive/DescriptiveStatisticsTest.html
==============================================================================
--- websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/stat/descriptive/DescriptiveStatisticsTest.html (original)
+++ websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/stat/descriptive/DescriptiveStatisticsTest.html Fri Apr 17 19:43:52 2015
@@ -38,347 +38,361 @@
 <span class="sourceLineNo">030</span>import org.junit.Test;<a name="line.30"></a>
 <span class="sourceLineNo">031</span><a name="line.31"></a>
 <span class="sourceLineNo">032</span>/**<a name="line.32"></a>
-<span class="sourceLineNo">033</span> * Test cases for the DescriptiveStatistics class.<a name="line.33"></a>
-<span class="sourceLineNo">034</span> *<a name="line.34"></a>
-<span class="sourceLineNo">035</span> *          2007) $<a name="line.35"></a>
-<span class="sourceLineNo">036</span> */<a name="line.36"></a>
-<span class="sourceLineNo">037</span>public class DescriptiveStatisticsTest {<a name="line.37"></a>
-<span class="sourceLineNo">038</span><a name="line.38"></a>
-<span class="sourceLineNo">039</span>    protected DescriptiveStatistics createDescriptiveStatistics() {<a name="line.39"></a>
-<span class="sourceLineNo">040</span>        return new DescriptiveStatistics();<a name="line.40"></a>
-<span class="sourceLineNo">041</span>    }<a name="line.41"></a>
-<span class="sourceLineNo">042</span><a name="line.42"></a>
-<span class="sourceLineNo">043</span>    @Test<a name="line.43"></a>
-<span class="sourceLineNo">044</span>    public void testSetterInjection() {<a name="line.44"></a>
-<span class="sourceLineNo">045</span>        DescriptiveStatistics stats = createDescriptiveStatistics();<a name="line.45"></a>
-<span class="sourceLineNo">046</span>        stats.addValue(1);<a name="line.46"></a>
-<span class="sourceLineNo">047</span>        stats.addValue(3);<a name="line.47"></a>
-<span class="sourceLineNo">048</span>        Assert.assertEquals(2, stats.getMean(), 1E-10);<a name="line.48"></a>
-<span class="sourceLineNo">049</span>        // Now lets try some new math<a name="line.49"></a>
-<span class="sourceLineNo">050</span>        stats.setMeanImpl(new deepMean());<a name="line.50"></a>
-<span class="sourceLineNo">051</span>        Assert.assertEquals(42, stats.getMean(), 1E-10);<a name="line.51"></a>
-<span class="sourceLineNo">052</span>    }<a name="line.52"></a>
-<span class="sourceLineNo">053</span><a name="line.53"></a>
-<span class="sourceLineNo">054</span>    @Test<a name="line.54"></a>
-<span class="sourceLineNo">055</span>    public void testCopy() {<a name="line.55"></a>
-<span class="sourceLineNo">056</span>        DescriptiveStatistics stats = createDescriptiveStatistics();<a name="line.56"></a>
-<span class="sourceLineNo">057</span>        stats.addValue(1);<a name="line.57"></a>
-<span class="sourceLineNo">058</span>        stats.addValue(3);<a name="line.58"></a>
-<span class="sourceLineNo">059</span>        DescriptiveStatistics copy = new DescriptiveStatistics(stats);<a name="line.59"></a>
-<span class="sourceLineNo">060</span>        Assert.assertEquals(2, copy.getMean(), 1E-10);<a name="line.60"></a>
-<span class="sourceLineNo">061</span>        // Now lets try some new math<a name="line.61"></a>
-<span class="sourceLineNo">062</span>        stats.setMeanImpl(new deepMean());<a name="line.62"></a>
-<span class="sourceLineNo">063</span>        copy = stats.copy();<a name="line.63"></a>
-<span class="sourceLineNo">064</span>        Assert.assertEquals(42, copy.getMean(), 1E-10);<a name="line.64"></a>
-<span class="sourceLineNo">065</span>    }<a name="line.65"></a>
-<span class="sourceLineNo">066</span><a name="line.66"></a>
-<span class="sourceLineNo">067</span>    @Test<a name="line.67"></a>
-<span class="sourceLineNo">068</span>    public void testWindowSize() {<a name="line.68"></a>
-<span class="sourceLineNo">069</span>        DescriptiveStatistics stats = createDescriptiveStatistics();<a name="line.69"></a>
-<span class="sourceLineNo">070</span>        stats.setWindowSize(300);<a name="line.70"></a>
-<span class="sourceLineNo">071</span>        for (int i = 0; i &lt; 100; ++i) {<a name="line.71"></a>
-<span class="sourceLineNo">072</span>            stats.addValue(i + 1);<a name="line.72"></a>
-<span class="sourceLineNo">073</span>        }<a name="line.73"></a>
-<span class="sourceLineNo">074</span>        int refSum = (100 * 101) / 2;<a name="line.74"></a>
-<span class="sourceLineNo">075</span>        Assert.assertEquals(refSum / 100.0, stats.getMean(), 1E-10);<a name="line.75"></a>
-<span class="sourceLineNo">076</span>        Assert.assertEquals(300, stats.getWindowSize());<a name="line.76"></a>
-<span class="sourceLineNo">077</span>        try {<a name="line.77"></a>
-<span class="sourceLineNo">078</span>            stats.setWindowSize(-3);<a name="line.78"></a>
-<span class="sourceLineNo">079</span>            Assert.fail("an exception should have been thrown");<a name="line.79"></a>
-<span class="sourceLineNo">080</span>        } catch (IllegalArgumentException iae) {<a name="line.80"></a>
-<span class="sourceLineNo">081</span>            // expected<a name="line.81"></a>
-<span class="sourceLineNo">082</span>        }<a name="line.82"></a>
-<span class="sourceLineNo">083</span>        Assert.assertEquals(300, stats.getWindowSize());<a name="line.83"></a>
-<span class="sourceLineNo">084</span>        stats.setWindowSize(50);<a name="line.84"></a>
-<span class="sourceLineNo">085</span>        Assert.assertEquals(50, stats.getWindowSize());<a name="line.85"></a>
-<span class="sourceLineNo">086</span>        int refSum2 = refSum - (50 * 51) / 2;<a name="line.86"></a>
-<span class="sourceLineNo">087</span>        Assert.assertEquals(refSum2 / 50.0, stats.getMean(), 1E-10);<a name="line.87"></a>
-<span class="sourceLineNo">088</span>    }<a name="line.88"></a>
-<span class="sourceLineNo">089</span><a name="line.89"></a>
-<span class="sourceLineNo">090</span>    @Test<a name="line.90"></a>
-<span class="sourceLineNo">091</span>    public void testGetValues() {<a name="line.91"></a>
-<span class="sourceLineNo">092</span>        DescriptiveStatistics stats = createDescriptiveStatistics();<a name="line.92"></a>
-<span class="sourceLineNo">093</span>        for (int i = 100; i &gt; 0; --i) {<a name="line.93"></a>
-<span class="sourceLineNo">094</span>            stats.addValue(i);<a name="line.94"></a>
-<span class="sourceLineNo">095</span>        }<a name="line.95"></a>
-<span class="sourceLineNo">096</span>        int refSum = (100 * 101) / 2;<a name="line.96"></a>
-<span class="sourceLineNo">097</span>        Assert.assertEquals(refSum / 100.0, stats.getMean(), 1E-10);<a name="line.97"></a>
-<span class="sourceLineNo">098</span>        double[] v = stats.getValues();<a name="line.98"></a>
-<span class="sourceLineNo">099</span>        for (int i = 0; i &lt; v.length; ++i) {<a name="line.99"></a>
-<span class="sourceLineNo">100</span>            Assert.assertEquals(100.0 - i, v[i], 1.0e-10);<a name="line.100"></a>
-<span class="sourceLineNo">101</span>        }<a name="line.101"></a>
-<span class="sourceLineNo">102</span>        double[] s = stats.getSortedValues();<a name="line.102"></a>
-<span class="sourceLineNo">103</span>        for (int i = 0; i &lt; s.length; ++i) {<a name="line.103"></a>
-<span class="sourceLineNo">104</span>            Assert.assertEquals(i + 1.0, s[i], 1.0e-10);<a name="line.104"></a>
-<span class="sourceLineNo">105</span>        }<a name="line.105"></a>
-<span class="sourceLineNo">106</span>        Assert.assertEquals(12.0, stats.getElement(88), 1.0e-10);<a name="line.106"></a>
-<span class="sourceLineNo">107</span>    }<a name="line.107"></a>
-<span class="sourceLineNo">108</span><a name="line.108"></a>
-<span class="sourceLineNo">109</span>    @Test<a name="line.109"></a>
-<span class="sourceLineNo">110</span>    public void testToString() {<a name="line.110"></a>
-<span class="sourceLineNo">111</span>        DescriptiveStatistics stats = createDescriptiveStatistics();<a name="line.111"></a>
-<span class="sourceLineNo">112</span>        stats.addValue(1);<a name="line.112"></a>
-<span class="sourceLineNo">113</span>        stats.addValue(2);<a name="line.113"></a>
-<span class="sourceLineNo">114</span>        stats.addValue(3);<a name="line.114"></a>
-<span class="sourceLineNo">115</span>        Locale d = Locale.getDefault();<a name="line.115"></a>
-<span class="sourceLineNo">116</span>        Locale.setDefault(Locale.US);<a name="line.116"></a>
-<span class="sourceLineNo">117</span>        Assert.assertEquals("DescriptiveStatistics:\n" +<a name="line.117"></a>
-<span class="sourceLineNo">118</span>                     "n: 3\n" +<a name="line.118"></a>
-<span class="sourceLineNo">119</span>                     "min: 1.0\n" +<a name="line.119"></a>
-<span class="sourceLineNo">120</span>                     "max: 3.0\n" +<a name="line.120"></a>
-<span class="sourceLineNo">121</span>                     "mean: 2.0\n" +<a name="line.121"></a>
-<span class="sourceLineNo">122</span>                     "std dev: 1.0\n" +<a name="line.122"></a>
-<span class="sourceLineNo">123</span>                     "median: 2.0\n" +<a name="line.123"></a>
-<span class="sourceLineNo">124</span>                     "skewness: 0.0\n" +<a name="line.124"></a>
-<span class="sourceLineNo">125</span>                     "kurtosis: NaN\n",  stats.toString());<a name="line.125"></a>
-<span class="sourceLineNo">126</span>        Locale.setDefault(d);<a name="line.126"></a>
-<span class="sourceLineNo">127</span>    }<a name="line.127"></a>
-<span class="sourceLineNo">128</span><a name="line.128"></a>
-<span class="sourceLineNo">129</span>    @Test<a name="line.129"></a>
-<span class="sourceLineNo">130</span>    public void testShuffledStatistics() {<a name="line.130"></a>
-<span class="sourceLineNo">131</span>        // the purpose of this test is only to check the get/set methods<a name="line.131"></a>
-<span class="sourceLineNo">132</span>        // we are aware shuffling statistics like this is really not<a name="line.132"></a>
-<span class="sourceLineNo">133</span>        // something sensible to do in production ...<a name="line.133"></a>
-<span class="sourceLineNo">134</span>        DescriptiveStatistics reference = createDescriptiveStatistics();<a name="line.134"></a>
-<span class="sourceLineNo">135</span>        DescriptiveStatistics shuffled  = createDescriptiveStatistics();<a name="line.135"></a>
-<span class="sourceLineNo">136</span><a name="line.136"></a>
-<span class="sourceLineNo">137</span>        UnivariateStatistic tmp = shuffled.getGeometricMeanImpl();<a name="line.137"></a>
-<span class="sourceLineNo">138</span>        shuffled.setGeometricMeanImpl(shuffled.getMeanImpl());<a name="line.138"></a>
-<span class="sourceLineNo">139</span>        shuffled.setMeanImpl(shuffled.getKurtosisImpl());<a name="line.139"></a>
-<span class="sourceLineNo">140</span>        shuffled.setKurtosisImpl(shuffled.getSkewnessImpl());<a name="line.140"></a>
-<span class="sourceLineNo">141</span>        shuffled.setSkewnessImpl(shuffled.getVarianceImpl());<a name="line.141"></a>
-<span class="sourceLineNo">142</span>        shuffled.setVarianceImpl(shuffled.getMaxImpl());<a name="line.142"></a>
-<span class="sourceLineNo">143</span>        shuffled.setMaxImpl(shuffled.getMinImpl());<a name="line.143"></a>
-<span class="sourceLineNo">144</span>        shuffled.setMinImpl(shuffled.getSumImpl());<a name="line.144"></a>
-<span class="sourceLineNo">145</span>        shuffled.setSumImpl(shuffled.getSumsqImpl());<a name="line.145"></a>
-<span class="sourceLineNo">146</span>        shuffled.setSumsqImpl(tmp);<a name="line.146"></a>
-<span class="sourceLineNo">147</span><a name="line.147"></a>
-<span class="sourceLineNo">148</span>        for (int i = 100; i &gt; 0; --i) {<a name="line.148"></a>
-<span class="sourceLineNo">149</span>            reference.addValue(i);<a name="line.149"></a>
-<span class="sourceLineNo">150</span>            shuffled.addValue(i);<a name="line.150"></a>
-<span class="sourceLineNo">151</span>        }<a name="line.151"></a>
-<span class="sourceLineNo">152</span><a name="line.152"></a>
-<span class="sourceLineNo">153</span>        Assert.assertEquals(reference.getMean(),          shuffled.getGeometricMean(), 1.0e-10);<a name="line.153"></a>
-<span class="sourceLineNo">154</span>        Assert.assertEquals(reference.getKurtosis(),      shuffled.getMean(),          1.0e-10);<a name="line.154"></a>
-<span class="sourceLineNo">155</span>        Assert.assertEquals(reference.getSkewness(),      shuffled.getKurtosis(), 1.0e-10);<a name="line.155"></a>
-<span class="sourceLineNo">156</span>        Assert.assertEquals(reference.getVariance(),      shuffled.getSkewness(), 1.0e-10);<a name="line.156"></a>
-<span class="sourceLineNo">157</span>        Assert.assertEquals(reference.getMax(),           shuffled.getVariance(), 1.0e-10);<a name="line.157"></a>
-<span class="sourceLineNo">158</span>        Assert.assertEquals(reference.getMin(),           shuffled.getMax(), 1.0e-10);<a name="line.158"></a>
-<span class="sourceLineNo">159</span>        Assert.assertEquals(reference.getSum(),           shuffled.getMin(), 1.0e-10);<a name="line.159"></a>
-<span class="sourceLineNo">160</span>        Assert.assertEquals(reference.getSumsq(),         shuffled.getSum(), 1.0e-10);<a name="line.160"></a>
-<span class="sourceLineNo">161</span>        Assert.assertEquals(reference.getGeometricMean(), shuffled.getSumsq(), 1.0e-10);<a name="line.161"></a>
-<span class="sourceLineNo">162</span><a name="line.162"></a>
-<span class="sourceLineNo">163</span>    }<a name="line.163"></a>
-<span class="sourceLineNo">164</span><a name="line.164"></a>
-<span class="sourceLineNo">165</span>    @Test<a name="line.165"></a>
-<span class="sourceLineNo">166</span>    public void testPercentileSetter() {<a name="line.166"></a>
-<span class="sourceLineNo">167</span>        DescriptiveStatistics stats = createDescriptiveStatistics();<a name="line.167"></a>
-<span class="sourceLineNo">168</span>        stats.addValue(1);<a name="line.168"></a>
-<span class="sourceLineNo">169</span>        stats.addValue(2);<a name="line.169"></a>
-<span class="sourceLineNo">170</span>        stats.addValue(3);<a name="line.170"></a>
-<span class="sourceLineNo">171</span>        Assert.assertEquals(2, stats.getPercentile(50.0), 1E-10);<a name="line.171"></a>
-<span class="sourceLineNo">172</span><a name="line.172"></a>
-<span class="sourceLineNo">173</span>        // Inject wrapped Percentile impl<a name="line.173"></a>
-<span class="sourceLineNo">174</span>        stats.setPercentileImpl(new goodPercentile());<a name="line.174"></a>
-<span class="sourceLineNo">175</span>        Assert.assertEquals(2, stats.getPercentile(50.0), 1E-10);<a name="line.175"></a>
+<span class="sourceLineNo">033</span> * Test cases for the {@link DescriptiveStatistics} class.<a name="line.33"></a>
+<span class="sourceLineNo">034</span> */<a name="line.34"></a>
+<span class="sourceLineNo">035</span>public class DescriptiveStatisticsTest {<a name="line.35"></a>
+<span class="sourceLineNo">036</span><a name="line.36"></a>
+<span class="sourceLineNo">037</span>    protected DescriptiveStatistics createDescriptiveStatistics() {<a name="line.37"></a>
+<span class="sourceLineNo">038</span>        return new DescriptiveStatistics();<a name="line.38"></a>
+<span class="sourceLineNo">039</span>    }<a name="line.39"></a>
+<span class="sourceLineNo">040</span><a name="line.40"></a>
+<span class="sourceLineNo">041</span>    @Test<a name="line.41"></a>
+<span class="sourceLineNo">042</span>    public void testSetterInjection() {<a name="line.42"></a>
+<span class="sourceLineNo">043</span>        DescriptiveStatistics stats = createDescriptiveStatistics();<a name="line.43"></a>
+<span class="sourceLineNo">044</span>        stats.addValue(1);<a name="line.44"></a>
+<span class="sourceLineNo">045</span>        stats.addValue(3);<a name="line.45"></a>
+<span class="sourceLineNo">046</span>        Assert.assertEquals(2, stats.getMean(), 1E-10);<a name="line.46"></a>
+<span class="sourceLineNo">047</span>        // Now lets try some new math<a name="line.47"></a>
+<span class="sourceLineNo">048</span>        stats.setMeanImpl(new deepMean());<a name="line.48"></a>
+<span class="sourceLineNo">049</span>        Assert.assertEquals(42, stats.getMean(), 1E-10);<a name="line.49"></a>
+<span class="sourceLineNo">050</span>    }<a name="line.50"></a>
+<span class="sourceLineNo">051</span><a name="line.51"></a>
+<span class="sourceLineNo">052</span>    @Test<a name="line.52"></a>
+<span class="sourceLineNo">053</span>    public void testCopy() {<a name="line.53"></a>
+<span class="sourceLineNo">054</span>        DescriptiveStatistics stats = createDescriptiveStatistics();<a name="line.54"></a>
+<span class="sourceLineNo">055</span>        stats.addValue(1);<a name="line.55"></a>
+<span class="sourceLineNo">056</span>        stats.addValue(3);<a name="line.56"></a>
+<span class="sourceLineNo">057</span>        DescriptiveStatistics copy = new DescriptiveStatistics(stats);<a name="line.57"></a>
+<span class="sourceLineNo">058</span>        Assert.assertEquals(2, copy.getMean(), 1E-10);<a name="line.58"></a>
+<span class="sourceLineNo">059</span>        // Now lets try some new math<a name="line.59"></a>
+<span class="sourceLineNo">060</span>        stats.setMeanImpl(new deepMean());<a name="line.60"></a>
+<span class="sourceLineNo">061</span>        copy = stats.copy();<a name="line.61"></a>
+<span class="sourceLineNo">062</span>        Assert.assertEquals(42, copy.getMean(), 1E-10);<a name="line.62"></a>
+<span class="sourceLineNo">063</span>    }<a name="line.63"></a>
+<span class="sourceLineNo">064</span><a name="line.64"></a>
+<span class="sourceLineNo">065</span>    @Test<a name="line.65"></a>
+<span class="sourceLineNo">066</span>    public void testWindowSize() {<a name="line.66"></a>
+<span class="sourceLineNo">067</span>        DescriptiveStatistics stats = createDescriptiveStatistics();<a name="line.67"></a>
+<span class="sourceLineNo">068</span>        stats.setWindowSize(300);<a name="line.68"></a>
+<span class="sourceLineNo">069</span>        for (int i = 0; i &lt; 100; ++i) {<a name="line.69"></a>
+<span class="sourceLineNo">070</span>            stats.addValue(i + 1);<a name="line.70"></a>
+<span class="sourceLineNo">071</span>        }<a name="line.71"></a>
+<span class="sourceLineNo">072</span>        int refSum = (100 * 101) / 2;<a name="line.72"></a>
+<span class="sourceLineNo">073</span>        Assert.assertEquals(refSum / 100.0, stats.getMean(), 1E-10);<a name="line.73"></a>
+<span class="sourceLineNo">074</span>        Assert.assertEquals(300, stats.getWindowSize());<a name="line.74"></a>
+<span class="sourceLineNo">075</span>        try {<a name="line.75"></a>
+<span class="sourceLineNo">076</span>            stats.setWindowSize(-3);<a name="line.76"></a>
+<span class="sourceLineNo">077</span>            Assert.fail("an exception should have been thrown");<a name="line.77"></a>
+<span class="sourceLineNo">078</span>        } catch (IllegalArgumentException iae) {<a name="line.78"></a>
+<span class="sourceLineNo">079</span>            // expected<a name="line.79"></a>
+<span class="sourceLineNo">080</span>        }<a name="line.80"></a>
+<span class="sourceLineNo">081</span>        Assert.assertEquals(300, stats.getWindowSize());<a name="line.81"></a>
+<span class="sourceLineNo">082</span>        stats.setWindowSize(50);<a name="line.82"></a>
+<span class="sourceLineNo">083</span>        Assert.assertEquals(50, stats.getWindowSize());<a name="line.83"></a>
+<span class="sourceLineNo">084</span>        int refSum2 = refSum - (50 * 51) / 2;<a name="line.84"></a>
+<span class="sourceLineNo">085</span>        Assert.assertEquals(refSum2 / 50.0, stats.getMean(), 1E-10);<a name="line.85"></a>
+<span class="sourceLineNo">086</span>    }<a name="line.86"></a>
+<span class="sourceLineNo">087</span><a name="line.87"></a>
+<span class="sourceLineNo">088</span>    @Test<a name="line.88"></a>
+<span class="sourceLineNo">089</span>    public void testGetValues() {<a name="line.89"></a>
+<span class="sourceLineNo">090</span>        DescriptiveStatistics stats = createDescriptiveStatistics();<a name="line.90"></a>
+<span class="sourceLineNo">091</span>        for (int i = 100; i &gt; 0; --i) {<a name="line.91"></a>
+<span class="sourceLineNo">092</span>            stats.addValue(i);<a name="line.92"></a>
+<span class="sourceLineNo">093</span>        }<a name="line.93"></a>
+<span class="sourceLineNo">094</span>        int refSum = (100 * 101) / 2;<a name="line.94"></a>
+<span class="sourceLineNo">095</span>        Assert.assertEquals(refSum / 100.0, stats.getMean(), 1E-10);<a name="line.95"></a>
+<span class="sourceLineNo">096</span>        double[] v = stats.getValues();<a name="line.96"></a>
+<span class="sourceLineNo">097</span>        for (int i = 0; i &lt; v.length; ++i) {<a name="line.97"></a>
+<span class="sourceLineNo">098</span>            Assert.assertEquals(100.0 - i, v[i], 1.0e-10);<a name="line.98"></a>
+<span class="sourceLineNo">099</span>        }<a name="line.99"></a>
+<span class="sourceLineNo">100</span>        double[] s = stats.getSortedValues();<a name="line.100"></a>
+<span class="sourceLineNo">101</span>        for (int i = 0; i &lt; s.length; ++i) {<a name="line.101"></a>
+<span class="sourceLineNo">102</span>            Assert.assertEquals(i + 1.0, s[i], 1.0e-10);<a name="line.102"></a>
+<span class="sourceLineNo">103</span>        }<a name="line.103"></a>
+<span class="sourceLineNo">104</span>        Assert.assertEquals(12.0, stats.getElement(88), 1.0e-10);<a name="line.104"></a>
+<span class="sourceLineNo">105</span>    }<a name="line.105"></a>
+<span class="sourceLineNo">106</span><a name="line.106"></a>
+<span class="sourceLineNo">107</span>    @Test<a name="line.107"></a>
+<span class="sourceLineNo">108</span>    public void testQuadraticMean() {<a name="line.108"></a>
+<span class="sourceLineNo">109</span>        final double[] values = { 1.2, 3.4, 5.6, 7.89 };<a name="line.109"></a>
+<span class="sourceLineNo">110</span>        final DescriptiveStatistics stats = new DescriptiveStatistics(values);<a name="line.110"></a>
+<span class="sourceLineNo">111</span><a name="line.111"></a>
+<span class="sourceLineNo">112</span>        final int len = values.length;<a name="line.112"></a>
+<span class="sourceLineNo">113</span>        double expected = 0;<a name="line.113"></a>
+<span class="sourceLineNo">114</span>        for (int i = 0; i &lt; len; i++) {<a name="line.114"></a>
+<span class="sourceLineNo">115</span>            final double v = values[i];<a name="line.115"></a>
+<span class="sourceLineNo">116</span>            expected += v * v / len;<a name="line.116"></a>
+<span class="sourceLineNo">117</span>        }<a name="line.117"></a>
+<span class="sourceLineNo">118</span>        expected = Math.sqrt(expected);<a name="line.118"></a>
+<span class="sourceLineNo">119</span><a name="line.119"></a>
+<span class="sourceLineNo">120</span>        Assert.assertEquals(expected, stats.getQuadraticMean(), Math.ulp(expected));<a name="line.120"></a>
+<span class="sourceLineNo">121</span>    }<a name="line.121"></a>
+<span class="sourceLineNo">122</span><a name="line.122"></a>
+<span class="sourceLineNo">123</span>    @Test<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    public void testToString() {<a name="line.124"></a>
+<span class="sourceLineNo">125</span>        DescriptiveStatistics stats = createDescriptiveStatistics();<a name="line.125"></a>
+<span class="sourceLineNo">126</span>        stats.addValue(1);<a name="line.126"></a>
+<span class="sourceLineNo">127</span>        stats.addValue(2);<a name="line.127"></a>
+<span class="sourceLineNo">128</span>        stats.addValue(3);<a name="line.128"></a>
+<span class="sourceLineNo">129</span>        Locale d = Locale.getDefault();<a name="line.129"></a>
+<span class="sourceLineNo">130</span>        Locale.setDefault(Locale.US);<a name="line.130"></a>
+<span class="sourceLineNo">131</span>        Assert.assertEquals("DescriptiveStatistics:\n" +<a name="line.131"></a>
+<span class="sourceLineNo">132</span>                     "n: 3\n" +<a name="line.132"></a>
+<span class="sourceLineNo">133</span>                     "min: 1.0\n" +<a name="line.133"></a>
+<span class="sourceLineNo">134</span>                     "max: 3.0\n" +<a name="line.134"></a>
+<span class="sourceLineNo">135</span>                     "mean: 2.0\n" +<a name="line.135"></a>
+<span class="sourceLineNo">136</span>                     "std dev: 1.0\n" +<a name="line.136"></a>
+<span class="sourceLineNo">137</span>                     "median: 2.0\n" +<a name="line.137"></a>
+<span class="sourceLineNo">138</span>                     "skewness: 0.0\n" +<a name="line.138"></a>
+<span class="sourceLineNo">139</span>                     "kurtosis: NaN\n",  stats.toString());<a name="line.139"></a>
+<span class="sourceLineNo">140</span>        Locale.setDefault(d);<a name="line.140"></a>
+<span class="sourceLineNo">141</span>    }<a name="line.141"></a>
+<span class="sourceLineNo">142</span><a name="line.142"></a>
+<span class="sourceLineNo">143</span>    @Test<a name="line.143"></a>
+<span class="sourceLineNo">144</span>    public void testShuffledStatistics() {<a name="line.144"></a>
+<span class="sourceLineNo">145</span>        // the purpose of this test is only to check the get/set methods<a name="line.145"></a>
+<span class="sourceLineNo">146</span>        // we are aware shuffling statistics like this is really not<a name="line.146"></a>
+<span class="sourceLineNo">147</span>        // something sensible to do in production ...<a name="line.147"></a>
+<span class="sourceLineNo">148</span>        DescriptiveStatistics reference = createDescriptiveStatistics();<a name="line.148"></a>
+<span class="sourceLineNo">149</span>        DescriptiveStatistics shuffled  = createDescriptiveStatistics();<a name="line.149"></a>
+<span class="sourceLineNo">150</span><a name="line.150"></a>
+<span class="sourceLineNo">151</span>        UnivariateStatistic tmp = shuffled.getGeometricMeanImpl();<a name="line.151"></a>
+<span class="sourceLineNo">152</span>        shuffled.setGeometricMeanImpl(shuffled.getMeanImpl());<a name="line.152"></a>
+<span class="sourceLineNo">153</span>        shuffled.setMeanImpl(shuffled.getKurtosisImpl());<a name="line.153"></a>
+<span class="sourceLineNo">154</span>        shuffled.setKurtosisImpl(shuffled.getSkewnessImpl());<a name="line.154"></a>
+<span class="sourceLineNo">155</span>        shuffled.setSkewnessImpl(shuffled.getVarianceImpl());<a name="line.155"></a>
+<span class="sourceLineNo">156</span>        shuffled.setVarianceImpl(shuffled.getMaxImpl());<a name="line.156"></a>
+<span class="sourceLineNo">157</span>        shuffled.setMaxImpl(shuffled.getMinImpl());<a name="line.157"></a>
+<span class="sourceLineNo">158</span>        shuffled.setMinImpl(shuffled.getSumImpl());<a name="line.158"></a>
+<span class="sourceLineNo">159</span>        shuffled.setSumImpl(shuffled.getSumsqImpl());<a name="line.159"></a>
+<span class="sourceLineNo">160</span>        shuffled.setSumsqImpl(tmp);<a name="line.160"></a>
+<span class="sourceLineNo">161</span><a name="line.161"></a>
+<span class="sourceLineNo">162</span>        for (int i = 100; i &gt; 0; --i) {<a name="line.162"></a>
+<span class="sourceLineNo">163</span>            reference.addValue(i);<a name="line.163"></a>
+<span class="sourceLineNo">164</span>            shuffled.addValue(i);<a name="line.164"></a>
+<span class="sourceLineNo">165</span>        }<a name="line.165"></a>
+<span class="sourceLineNo">166</span><a name="line.166"></a>
+<span class="sourceLineNo">167</span>        Assert.assertEquals(reference.getMean(),          shuffled.getGeometricMean(), 1.0e-10);<a name="line.167"></a>
+<span class="sourceLineNo">168</span>        Assert.assertEquals(reference.getKurtosis(),      shuffled.getMean(),          1.0e-10);<a name="line.168"></a>
+<span class="sourceLineNo">169</span>        Assert.assertEquals(reference.getSkewness(),      shuffled.getKurtosis(), 1.0e-10);<a name="line.169"></a>
+<span class="sourceLineNo">170</span>        Assert.assertEquals(reference.getVariance(),      shuffled.getSkewness(), 1.0e-10);<a name="line.170"></a>
+<span class="sourceLineNo">171</span>        Assert.assertEquals(reference.getMax(),           shuffled.getVariance(), 1.0e-10);<a name="line.171"></a>
+<span class="sourceLineNo">172</span>        Assert.assertEquals(reference.getMin(),           shuffled.getMax(), 1.0e-10);<a name="line.172"></a>
+<span class="sourceLineNo">173</span>        Assert.assertEquals(reference.getSum(),           shuffled.getMin(), 1.0e-10);<a name="line.173"></a>
+<span class="sourceLineNo">174</span>        Assert.assertEquals(reference.getSumsq(),         shuffled.getSum(), 1.0e-10);<a name="line.174"></a>
+<span class="sourceLineNo">175</span>        Assert.assertEquals(reference.getGeometricMean(), shuffled.getSumsq(), 1.0e-10);<a name="line.175"></a>
 <span class="sourceLineNo">176</span><a name="line.176"></a>
-<span class="sourceLineNo">177</span>        // Try "new math" impl<a name="line.177"></a>
-<span class="sourceLineNo">178</span>        stats.setPercentileImpl(new subPercentile());<a name="line.178"></a>
-<span class="sourceLineNo">179</span>        Assert.assertEquals(10.0, stats.getPercentile(10.0), 1E-10);<a name="line.179"></a>
-<span class="sourceLineNo">180</span><a name="line.180"></a>
-<span class="sourceLineNo">181</span>        // Try to set bad impl<a name="line.181"></a>
-<span class="sourceLineNo">182</span>        try {<a name="line.182"></a>
-<span class="sourceLineNo">183</span>            stats.setPercentileImpl(new badPercentile());<a name="line.183"></a>
-<span class="sourceLineNo">184</span>            Assert.fail("Expecting IllegalArgumentException");<a name="line.184"></a>
-<span class="sourceLineNo">185</span>        } catch (IllegalArgumentException ex) {<a name="line.185"></a>
-<span class="sourceLineNo">186</span>            // expected<a name="line.186"></a>
-<span class="sourceLineNo">187</span>        }<a name="line.187"></a>
-<span class="sourceLineNo">188</span>    }<a name="line.188"></a>
-<span class="sourceLineNo">189</span><a name="line.189"></a>
-<span class="sourceLineNo">190</span>    @Test<a name="line.190"></a>
-<span class="sourceLineNo">191</span>    public void test20090720() {<a name="line.191"></a>
-<span class="sourceLineNo">192</span>        DescriptiveStatistics descriptiveStatistics = new DescriptiveStatistics(100);<a name="line.192"></a>
-<span class="sourceLineNo">193</span>        for (int i = 0; i &lt; 161; i++) {<a name="line.193"></a>
-<span class="sourceLineNo">194</span>            descriptiveStatistics.addValue(1.2);<a name="line.194"></a>
-<span class="sourceLineNo">195</span>        }<a name="line.195"></a>
-<span class="sourceLineNo">196</span>        descriptiveStatistics.clear();<a name="line.196"></a>
-<span class="sourceLineNo">197</span>        descriptiveStatistics.addValue(1.2);<a name="line.197"></a>
-<span class="sourceLineNo">198</span>        Assert.assertEquals(1, descriptiveStatistics.getN());<a name="line.198"></a>
-<span class="sourceLineNo">199</span>    }<a name="line.199"></a>
-<span class="sourceLineNo">200</span><a name="line.200"></a>
-<span class="sourceLineNo">201</span>    @Test<a name="line.201"></a>
-<span class="sourceLineNo">202</span>    public void testRemoval() {<a name="line.202"></a>
+<span class="sourceLineNo">177</span>    }<a name="line.177"></a>
+<span class="sourceLineNo">178</span><a name="line.178"></a>
+<span class="sourceLineNo">179</span>    @Test<a name="line.179"></a>
+<span class="sourceLineNo">180</span>    public void testPercentileSetter() {<a name="line.180"></a>
+<span class="sourceLineNo">181</span>        DescriptiveStatistics stats = createDescriptiveStatistics();<a name="line.181"></a>
+<span class="sourceLineNo">182</span>        stats.addValue(1);<a name="line.182"></a>
+<span class="sourceLineNo">183</span>        stats.addValue(2);<a name="line.183"></a>
+<span class="sourceLineNo">184</span>        stats.addValue(3);<a name="line.184"></a>
+<span class="sourceLineNo">185</span>        Assert.assertEquals(2, stats.getPercentile(50.0), 1E-10);<a name="line.185"></a>
+<span class="sourceLineNo">186</span><a name="line.186"></a>
+<span class="sourceLineNo">187</span>        // Inject wrapped Percentile impl<a name="line.187"></a>
+<span class="sourceLineNo">188</span>        stats.setPercentileImpl(new goodPercentile());<a name="line.188"></a>
+<span class="sourceLineNo">189</span>        Assert.assertEquals(2, stats.getPercentile(50.0), 1E-10);<a name="line.189"></a>
+<span class="sourceLineNo">190</span><a name="line.190"></a>
+<span class="sourceLineNo">191</span>        // Try "new math" impl<a name="line.191"></a>
+<span class="sourceLineNo">192</span>        stats.setPercentileImpl(new subPercentile());<a name="line.192"></a>
+<span class="sourceLineNo">193</span>        Assert.assertEquals(10.0, stats.getPercentile(10.0), 1E-10);<a name="line.193"></a>
+<span class="sourceLineNo">194</span><a name="line.194"></a>
+<span class="sourceLineNo">195</span>        // Try to set bad impl<a name="line.195"></a>
+<span class="sourceLineNo">196</span>        try {<a name="line.196"></a>
+<span class="sourceLineNo">197</span>            stats.setPercentileImpl(new badPercentile());<a name="line.197"></a>
+<span class="sourceLineNo">198</span>            Assert.fail("Expecting IllegalArgumentException");<a name="line.198"></a>
+<span class="sourceLineNo">199</span>        } catch (IllegalArgumentException ex) {<a name="line.199"></a>
+<span class="sourceLineNo">200</span>            // expected<a name="line.200"></a>
+<span class="sourceLineNo">201</span>        }<a name="line.201"></a>
+<span class="sourceLineNo">202</span>    }<a name="line.202"></a>
 <span class="sourceLineNo">203</span><a name="line.203"></a>
-<span class="sourceLineNo">204</span>        final DescriptiveStatistics dstat = createDescriptiveStatistics();<a name="line.204"></a>
-<span class="sourceLineNo">205</span><a name="line.205"></a>
-<span class="sourceLineNo">206</span>        checkremoval(dstat, 1, 6.0, 0.0, Double.NaN);<a name="line.206"></a>
-<span class="sourceLineNo">207</span>        checkremoval(dstat, 3, 5.0, 3.0, 4.5);<a name="line.207"></a>
-<span class="sourceLineNo">208</span>        checkremoval(dstat, 6, 3.5, 2.5, 3.0);<a name="line.208"></a>
-<span class="sourceLineNo">209</span>        checkremoval(dstat, 9, 3.5, 2.5, 3.0);<a name="line.209"></a>
-<span class="sourceLineNo">210</span>        checkremoval(dstat, DescriptiveStatistics.INFINITE_WINDOW, 3.5, 2.5, 3.0);<a name="line.210"></a>
-<span class="sourceLineNo">211</span><a name="line.211"></a>
-<span class="sourceLineNo">212</span>    }<a name="line.212"></a>
-<span class="sourceLineNo">213</span>    <a name="line.213"></a>
-<span class="sourceLineNo">214</span>    @Test<a name="line.214"></a>
-<span class="sourceLineNo">215</span>    public void testSummaryConsistency() {<a name="line.215"></a>
-<span class="sourceLineNo">216</span>        final DescriptiveStatistics dstats = new DescriptiveStatistics();<a name="line.216"></a>
-<span class="sourceLineNo">217</span>        final SummaryStatistics sstats = new SummaryStatistics();<a name="line.217"></a>
-<span class="sourceLineNo">218</span>        final int windowSize = 5;<a name="line.218"></a>
-<span class="sourceLineNo">219</span>        dstats.setWindowSize(windowSize);<a name="line.219"></a>
-<span class="sourceLineNo">220</span>        final double tol = 1E-12;<a name="line.220"></a>
-<span class="sourceLineNo">221</span>        for (int i = 0; i &lt; 20; i++) {<a name="line.221"></a>
-<span class="sourceLineNo">222</span>            dstats.addValue(i);<a name="line.222"></a>
-<span class="sourceLineNo">223</span>            sstats.clear();<a name="line.223"></a>
-<span class="sourceLineNo">224</span>            double[] values = dstats.getValues();<a name="line.224"></a>
-<span class="sourceLineNo">225</span>            for (int j = 0; j &lt; values.length; j++) {<a name="line.225"></a>
-<span class="sourceLineNo">226</span>                sstats.addValue(values[j]);<a name="line.226"></a>
-<span class="sourceLineNo">227</span>            }<a name="line.227"></a>
-<span class="sourceLineNo">228</span>            TestUtils.assertEquals(dstats.getMean(), sstats.getMean(), tol);<a name="line.228"></a>
-<span class="sourceLineNo">229</span>            TestUtils.assertEquals(new Mean().evaluate(values), dstats.getMean(), tol);<a name="line.229"></a>
-<span class="sourceLineNo">230</span>            TestUtils.assertEquals(dstats.getMax(), sstats.getMax(), tol);<a name="line.230"></a>
-<span class="sourceLineNo">231</span>            TestUtils.assertEquals(new Max().evaluate(values), dstats.getMax(), tol);<a name="line.231"></a>
-<span class="sourceLineNo">232</span>            TestUtils.assertEquals(dstats.getGeometricMean(), sstats.getGeometricMean(), tol);<a name="line.232"></a>
-<span class="sourceLineNo">233</span>            TestUtils.assertEquals(new GeometricMean().evaluate(values), dstats.getGeometricMean(), tol);<a name="line.233"></a>
-<span class="sourceLineNo">234</span>            TestUtils.assertEquals(dstats.getMin(), sstats.getMin(), tol);<a name="line.234"></a>
-<span class="sourceLineNo">235</span>            TestUtils.assertEquals(new Min().evaluate(values), dstats.getMin(), tol);<a name="line.235"></a>
-<span class="sourceLineNo">236</span>            TestUtils.assertEquals(dstats.getStandardDeviation(), sstats.getStandardDeviation(), tol);<a name="line.236"></a>
-<span class="sourceLineNo">237</span>            TestUtils.assertEquals(dstats.getVariance(), sstats.getVariance(), tol);<a name="line.237"></a>
-<span class="sourceLineNo">238</span>            TestUtils.assertEquals(new Variance().evaluate(values), dstats.getVariance(), tol);<a name="line.238"></a>
-<span class="sourceLineNo">239</span>            TestUtils.assertEquals(dstats.getSum(), sstats.getSum(), tol);<a name="line.239"></a>
-<span class="sourceLineNo">240</span>            TestUtils.assertEquals(new Sum().evaluate(values), dstats.getSum(), tol);<a name="line.240"></a>
-<span class="sourceLineNo">241</span>            TestUtils.assertEquals(dstats.getSumsq(), sstats.getSumsq(), tol);<a name="line.241"></a>
-<span class="sourceLineNo">242</span>            TestUtils.assertEquals(new SumOfSquares().evaluate(values), dstats.getSumsq(), tol);<a name="line.242"></a>
-<span class="sourceLineNo">243</span>            TestUtils.assertEquals(dstats.getPopulationVariance(), sstats.getPopulationVariance(), tol);<a name="line.243"></a>
-<span class="sourceLineNo">244</span>            TestUtils.assertEquals(new Variance(false).evaluate(values), dstats.getPopulationVariance(), tol);<a name="line.244"></a>
-<span class="sourceLineNo">245</span>        }<a name="line.245"></a>
-<span class="sourceLineNo">246</span>    }<a name="line.246"></a>
-<span class="sourceLineNo">247</span><a name="line.247"></a>
-<span class="sourceLineNo">248</span>    @Test<a name="line.248"></a>
-<span class="sourceLineNo">249</span>    public void testMath1129(){<a name="line.249"></a>
-<span class="sourceLineNo">250</span>        final double[] data = new double[] {<a name="line.250"></a>
-<span class="sourceLineNo">251</span>            -0.012086732064244697,<a name="line.251"></a>
-<span class="sourceLineNo">252</span>            -0.24975668704012527,<a name="line.252"></a>
-<span class="sourceLineNo">253</span>            0.5706168483164684,<a name="line.253"></a>
-<span class="sourceLineNo">254</span>            -0.322111769955327,<a name="line.254"></a>
-<span class="sourceLineNo">255</span>            0.24166759508327315,<a name="line.255"></a>
-<span class="sourceLineNo">256</span>            Double.NaN,<a name="line.256"></a>
-<span class="sourceLineNo">257</span>            0.16698443218942854,<a name="line.257"></a>
-<span class="sourceLineNo">258</span>            -0.10427763937565114,<a name="line.258"></a>
-<span class="sourceLineNo">259</span>            -0.15595963093172435,<a name="line.259"></a>
-<span class="sourceLineNo">260</span>            -0.028075857595882995,<a name="line.260"></a>
-<span class="sourceLineNo">261</span>            -0.24137994506058857,<a name="line.261"></a>
-<span class="sourceLineNo">262</span>            0.47543170476574426,<a name="line.262"></a>
-<span class="sourceLineNo">263</span>            -0.07495595384947631,<a name="line.263"></a>
-<span class="sourceLineNo">264</span>            0.37445697625436497,<a name="line.264"></a>
-<span class="sourceLineNo">265</span>            -0.09944199541668033<a name="line.265"></a>
-<span class="sourceLineNo">266</span>        };<a name="line.266"></a>
-<span class="sourceLineNo">267</span><a name="line.267"></a>
-<span class="sourceLineNo">268</span>        final DescriptiveStatistics ds = new DescriptiveStatistics(data);<a name="line.268"></a>
-<span class="sourceLineNo">269</span><a name="line.269"></a>
-<span class="sourceLineNo">270</span>        final double t = ds.getPercentile(75);<a name="line.270"></a>
-<span class="sourceLineNo">271</span>        final double o = ds.getPercentile(25);<a name="line.271"></a>
-<span class="sourceLineNo">272</span><a name="line.272"></a>
-<span class="sourceLineNo">273</span>        final double iqr = t - o;<a name="line.273"></a>
-<span class="sourceLineNo">274</span>        // System.out.println(String.format("25th percentile %s 75th percentile %s", o, t));<a name="line.274"></a>
-<span class="sourceLineNo">275</span>        Assert.assertTrue(iqr &gt;= 0);<a name="line.275"></a>
-<span class="sourceLineNo">276</span>    }<a name="line.276"></a>
-<span class="sourceLineNo">277</span><a name="line.277"></a>
-<span class="sourceLineNo">278</span>    public void checkremoval(DescriptiveStatistics dstat, int wsize,<a name="line.278"></a>
-<span class="sourceLineNo">279</span>                             double mean1, double mean2, double mean3) {<a name="line.279"></a>
-<span class="sourceLineNo">280</span><a name="line.280"></a>
-<span class="sourceLineNo">281</span>        dstat.setWindowSize(wsize);<a name="line.281"></a>
-<span class="sourceLineNo">282</span>        dstat.clear();<a name="line.282"></a>
+<span class="sourceLineNo">204</span>    @Test<a name="line.204"></a>
+<span class="sourceLineNo">205</span>    public void test20090720() {<a name="line.205"></a>
+<span class="sourceLineNo">206</span>        DescriptiveStatistics descriptiveStatistics = new DescriptiveStatistics(100);<a name="line.206"></a>
+<span class="sourceLineNo">207</span>        for (int i = 0; i &lt; 161; i++) {<a name="line.207"></a>
+<span class="sourceLineNo">208</span>            descriptiveStatistics.addValue(1.2);<a name="line.208"></a>
+<span class="sourceLineNo">209</span>        }<a name="line.209"></a>
+<span class="sourceLineNo">210</span>        descriptiveStatistics.clear();<a name="line.210"></a>
+<span class="sourceLineNo">211</span>        descriptiveStatistics.addValue(1.2);<a name="line.211"></a>
+<span class="sourceLineNo">212</span>        Assert.assertEquals(1, descriptiveStatistics.getN());<a name="line.212"></a>
+<span class="sourceLineNo">213</span>    }<a name="line.213"></a>
+<span class="sourceLineNo">214</span><a name="line.214"></a>
+<span class="sourceLineNo">215</span>    @Test<a name="line.215"></a>
+<span class="sourceLineNo">216</span>    public void testRemoval() {<a name="line.216"></a>
+<span class="sourceLineNo">217</span><a name="line.217"></a>
+<span class="sourceLineNo">218</span>        final DescriptiveStatistics dstat = createDescriptiveStatistics();<a name="line.218"></a>
+<span class="sourceLineNo">219</span><a name="line.219"></a>
+<span class="sourceLineNo">220</span>        checkremoval(dstat, 1, 6.0, 0.0, Double.NaN);<a name="line.220"></a>
+<span class="sourceLineNo">221</span>        checkremoval(dstat, 3, 5.0, 3.0, 4.5);<a name="line.221"></a>
+<span class="sourceLineNo">222</span>        checkremoval(dstat, 6, 3.5, 2.5, 3.0);<a name="line.222"></a>
+<span class="sourceLineNo">223</span>        checkremoval(dstat, 9, 3.5, 2.5, 3.0);<a name="line.223"></a>
+<span class="sourceLineNo">224</span>        checkremoval(dstat, DescriptiveStatistics.INFINITE_WINDOW, 3.5, 2.5, 3.0);<a name="line.224"></a>
+<span class="sourceLineNo">225</span><a name="line.225"></a>
+<span class="sourceLineNo">226</span>    }<a name="line.226"></a>
+<span class="sourceLineNo">227</span>    <a name="line.227"></a>
+<span class="sourceLineNo">228</span>    @Test<a name="line.228"></a>
+<span class="sourceLineNo">229</span>    public void testSummaryConsistency() {<a name="line.229"></a>
+<span class="sourceLineNo">230</span>        final DescriptiveStatistics dstats = new DescriptiveStatistics();<a name="line.230"></a>
+<span class="sourceLineNo">231</span>        final SummaryStatistics sstats = new SummaryStatistics();<a name="line.231"></a>
+<span class="sourceLineNo">232</span>        final int windowSize = 5;<a name="line.232"></a>
+<span class="sourceLineNo">233</span>        dstats.setWindowSize(windowSize);<a name="line.233"></a>
+<span class="sourceLineNo">234</span>        final double tol = 1E-12;<a name="line.234"></a>
+<span class="sourceLineNo">235</span>        for (int i = 0; i &lt; 20; i++) {<a name="line.235"></a>
+<span class="sourceLineNo">236</span>            dstats.addValue(i);<a name="line.236"></a>
+<span class="sourceLineNo">237</span>            sstats.clear();<a name="line.237"></a>
+<span class="sourceLineNo">238</span>            double[] values = dstats.getValues();<a name="line.238"></a>
+<span class="sourceLineNo">239</span>            for (int j = 0; j &lt; values.length; j++) {<a name="line.239"></a>
+<span class="sourceLineNo">240</span>                sstats.addValue(values[j]);<a name="line.240"></a>
+<span class="sourceLineNo">241</span>            }<a name="line.241"></a>
+<span class="sourceLineNo">242</span>            TestUtils.assertEquals(dstats.getMean(), sstats.getMean(), tol);<a name="line.242"></a>
+<span class="sourceLineNo">243</span>            TestUtils.assertEquals(new Mean().evaluate(values), dstats.getMean(), tol);<a name="line.243"></a>
+<span class="sourceLineNo">244</span>            TestUtils.assertEquals(dstats.getMax(), sstats.getMax(), tol);<a name="line.244"></a>
+<span class="sourceLineNo">245</span>            TestUtils.assertEquals(new Max().evaluate(values), dstats.getMax(), tol);<a name="line.245"></a>
+<span class="sourceLineNo">246</span>            TestUtils.assertEquals(dstats.getGeometricMean(), sstats.getGeometricMean(), tol);<a name="line.246"></a>
+<span class="sourceLineNo">247</span>            TestUtils.assertEquals(new GeometricMean().evaluate(values), dstats.getGeometricMean(), tol);<a name="line.247"></a>
+<span class="sourceLineNo">248</span>            TestUtils.assertEquals(dstats.getMin(), sstats.getMin(), tol);<a name="line.248"></a>
+<span class="sourceLineNo">249</span>            TestUtils.assertEquals(new Min().evaluate(values), dstats.getMin(), tol);<a name="line.249"></a>
+<span class="sourceLineNo">250</span>            TestUtils.assertEquals(dstats.getStandardDeviation(), sstats.getStandardDeviation(), tol);<a name="line.250"></a>
+<span class="sourceLineNo">251</span>            TestUtils.assertEquals(dstats.getVariance(), sstats.getVariance(), tol);<a name="line.251"></a>
+<span class="sourceLineNo">252</span>            TestUtils.assertEquals(new Variance().evaluate(values), dstats.getVariance(), tol);<a name="line.252"></a>
+<span class="sourceLineNo">253</span>            TestUtils.assertEquals(dstats.getSum(), sstats.getSum(), tol);<a name="line.253"></a>
+<span class="sourceLineNo">254</span>            TestUtils.assertEquals(new Sum().evaluate(values), dstats.getSum(), tol);<a name="line.254"></a>
+<span class="sourceLineNo">255</span>            TestUtils.assertEquals(dstats.getSumsq(), sstats.getSumsq(), tol);<a name="line.255"></a>
+<span class="sourceLineNo">256</span>            TestUtils.assertEquals(new SumOfSquares().evaluate(values), dstats.getSumsq(), tol);<a name="line.256"></a>
+<span class="sourceLineNo">257</span>            TestUtils.assertEquals(dstats.getPopulationVariance(), sstats.getPopulationVariance(), tol);<a name="line.257"></a>
+<span class="sourceLineNo">258</span>            TestUtils.assertEquals(new Variance(false).evaluate(values), dstats.getPopulationVariance(), tol);<a name="line.258"></a>
+<span class="sourceLineNo">259</span>        }<a name="line.259"></a>
+<span class="sourceLineNo">260</span>    }<a name="line.260"></a>
+<span class="sourceLineNo">261</span><a name="line.261"></a>
+<span class="sourceLineNo">262</span>    @Test<a name="line.262"></a>
+<span class="sourceLineNo">263</span>    public void testMath1129(){<a name="line.263"></a>
+<span class="sourceLineNo">264</span>        final double[] data = new double[] {<a name="line.264"></a>
+<span class="sourceLineNo">265</span>            -0.012086732064244697,<a name="line.265"></a>
+<span class="sourceLineNo">266</span>            -0.24975668704012527,<a name="line.266"></a>
+<span class="sourceLineNo">267</span>            0.5706168483164684,<a name="line.267"></a>
+<span class="sourceLineNo">268</span>            -0.322111769955327,<a name="line.268"></a>
+<span class="sourceLineNo">269</span>            0.24166759508327315,<a name="line.269"></a>
+<span class="sourceLineNo">270</span>            Double.NaN,<a name="line.270"></a>
+<span class="sourceLineNo">271</span>            0.16698443218942854,<a name="line.271"></a>
+<span class="sourceLineNo">272</span>            -0.10427763937565114,<a name="line.272"></a>
+<span class="sourceLineNo">273</span>            -0.15595963093172435,<a name="line.273"></a>
+<span class="sourceLineNo">274</span>            -0.028075857595882995,<a name="line.274"></a>
+<span class="sourceLineNo">275</span>            -0.24137994506058857,<a name="line.275"></a>
+<span class="sourceLineNo">276</span>            0.47543170476574426,<a name="line.276"></a>
+<span class="sourceLineNo">277</span>            -0.07495595384947631,<a name="line.277"></a>
+<span class="sourceLineNo">278</span>            0.37445697625436497,<a name="line.278"></a>
+<span class="sourceLineNo">279</span>            -0.09944199541668033<a name="line.279"></a>
+<span class="sourceLineNo">280</span>        };<a name="line.280"></a>
+<span class="sourceLineNo">281</span><a name="line.281"></a>
+<span class="sourceLineNo">282</span>        final DescriptiveStatistics ds = new DescriptiveStatistics(data);<a name="line.282"></a>
 <span class="sourceLineNo">283</span><a name="line.283"></a>
-<span class="sourceLineNo">284</span>        for (int i = 1 ; i &lt;= 6 ; ++i) {<a name="line.284"></a>
-<span class="sourceLineNo">285</span>            dstat.addValue(i);<a name="line.285"></a>
-<span class="sourceLineNo">286</span>        }<a name="line.286"></a>
-<span class="sourceLineNo">287</span><a name="line.287"></a>
-<span class="sourceLineNo">288</span>        Assert.assertTrue(Precision.equalsIncludingNaN(mean1, dstat.getMean()));<a name="line.288"></a>
-<span class="sourceLineNo">289</span>        dstat.replaceMostRecentValue(0);<a name="line.289"></a>
-<span class="sourceLineNo">290</span>        Assert.assertTrue(Precision.equalsIncludingNaN(mean2, dstat.getMean()));<a name="line.290"></a>
-<span class="sourceLineNo">291</span>        dstat.removeMostRecentValue();<a name="line.291"></a>
-<span class="sourceLineNo">292</span>        Assert.assertTrue(Precision.equalsIncludingNaN(mean3, dstat.getMean()));<a name="line.292"></a>
-<span class="sourceLineNo">293</span><a name="line.293"></a>
-<span class="sourceLineNo">294</span>    }<a name="line.294"></a>
-<span class="sourceLineNo">295</span><a name="line.295"></a>
-<span class="sourceLineNo">296</span>    // Test UnivariateStatistics impls for setter injection tests<a name="line.296"></a>
+<span class="sourceLineNo">284</span>        final double t = ds.getPercentile(75);<a name="line.284"></a>
+<span class="sourceLineNo">285</span>        final double o = ds.getPercentile(25);<a name="line.285"></a>
+<span class="sourceLineNo">286</span><a name="line.286"></a>
+<span class="sourceLineNo">287</span>        final double iqr = t - o;<a name="line.287"></a>
+<span class="sourceLineNo">288</span>        // System.out.println(String.format("25th percentile %s 75th percentile %s", o, t));<a name="line.288"></a>
+<span class="sourceLineNo">289</span>        Assert.assertTrue(iqr &gt;= 0);<a name="line.289"></a>
+<span class="sourceLineNo">290</span>    }<a name="line.290"></a>
+<span class="sourceLineNo">291</span><a name="line.291"></a>
+<span class="sourceLineNo">292</span>    public void checkremoval(DescriptiveStatistics dstat, int wsize,<a name="line.292"></a>
+<span class="sourceLineNo">293</span>                             double mean1, double mean2, double mean3) {<a name="line.293"></a>
+<span class="sourceLineNo">294</span><a name="line.294"></a>
+<span class="sourceLineNo">295</span>        dstat.setWindowSize(wsize);<a name="line.295"></a>
+<span class="sourceLineNo">296</span>        dstat.clear();<a name="line.296"></a>
 <span class="sourceLineNo">297</span><a name="line.297"></a>
-<span class="sourceLineNo">298</span>    /**<a name="line.298"></a>
-<span class="sourceLineNo">299</span>     * A new way to compute the mean<a name="line.299"></a>
-<span class="sourceLineNo">300</span>     */<a name="line.300"></a>
-<span class="sourceLineNo">301</span>    static class deepMean implements UnivariateStatistic {<a name="line.301"></a>
-<span class="sourceLineNo">302</span><a name="line.302"></a>
-<span class="sourceLineNo">303</span>        public double evaluate(double[] values, int begin, int length) {<a name="line.303"></a>
-<span class="sourceLineNo">304</span>            return 42;<a name="line.304"></a>
-<span class="sourceLineNo">305</span>        }<a name="line.305"></a>
-<span class="sourceLineNo">306</span><a name="line.306"></a>
-<span class="sourceLineNo">307</span>        public double evaluate(double[] values) {<a name="line.307"></a>
-<span class="sourceLineNo">308</span>            return 42;<a name="line.308"></a>
-<span class="sourceLineNo">309</span>        }<a name="line.309"></a>
-<span class="sourceLineNo">310</span>        public UnivariateStatistic copy() {<a name="line.310"></a>
-<span class="sourceLineNo">311</span>            return new deepMean();<a name="line.311"></a>
-<span class="sourceLineNo">312</span>        }<a name="line.312"></a>
-<span class="sourceLineNo">313</span>    }<a name="line.313"></a>
-<span class="sourceLineNo">314</span><a name="line.314"></a>
-<span class="sourceLineNo">315</span>    /**<a name="line.315"></a>
-<span class="sourceLineNo">316</span>     * Test percentile implementation - wraps a Percentile<a name="line.316"></a>
-<span class="sourceLineNo">317</span>     */<a name="line.317"></a>
-<span class="sourceLineNo">318</span>    static class goodPercentile implements UnivariateStatistic {<a name="line.318"></a>
-<span class="sourceLineNo">319</span>        private Percentile percentile = new Percentile();<a name="line.319"></a>
-<span class="sourceLineNo">320</span>        public void setQuantile(double quantile) {<a name="line.320"></a>
-<span class="sourceLineNo">321</span>            percentile.setQuantile(quantile);<a name="line.321"></a>
-<span class="sourceLineNo">322</span>        }<a name="line.322"></a>
-<span class="sourceLineNo">323</span>        public double evaluate(double[] values, int begin, int length) {<a name="line.323"></a>
-<span class="sourceLineNo">324</span>            return percentile.evaluate(values, begin, length);<a name="line.324"></a>
-<span class="sourceLineNo">325</span>        }<a name="line.325"></a>
-<span class="sourceLineNo">326</span>        public double evaluate(double[] values) {<a name="line.326"></a>
-<span class="sourceLineNo">327</span>            return percentile.evaluate(values);<a name="line.327"></a>
-<span class="sourceLineNo">328</span>        }<a name="line.328"></a>
-<span class="sourceLineNo">329</span>        public UnivariateStatistic copy() {<a name="line.329"></a>
-<span class="sourceLineNo">330</span>            goodPercentile result = new goodPercentile();<a name="line.330"></a>
-<span class="sourceLineNo">331</span>            result.setQuantile(percentile.getQuantile());<a name="line.331"></a>
-<span class="sourceLineNo">332</span>            return result;<a name="line.332"></a>
-<span class="sourceLineNo">333</span>        }<a name="line.333"></a>
-<span class="sourceLineNo">334</span>    }<a name="line.334"></a>
-<span class="sourceLineNo">335</span><a name="line.335"></a>
-<span class="sourceLineNo">336</span>    /**<a name="line.336"></a>
-<span class="sourceLineNo">337</span>     * Test percentile subclass - another "new math" impl<a name="line.337"></a>
-<span class="sourceLineNo">338</span>     * Always returns currently set quantile<a name="line.338"></a>
-<span class="sourceLineNo">339</span>     */<a name="line.339"></a>
-<span class="sourceLineNo">340</span>    static class subPercentile extends Percentile {<a name="line.340"></a>
-<span class="sourceLineNo">341</span>        @Override<a name="line.341"></a>
-<span class="sourceLineNo">342</span>        public double evaluate(double[] values, int begin, int length) {<a name="line.342"></a>
-<span class="sourceLineNo">343</span>            return getQuantile();<a name="line.343"></a>
-<span class="sourceLineNo">344</span>        }<a name="line.344"></a>
-<span class="sourceLineNo">345</span>        @Override<a name="line.345"></a>
-<span class="sourceLineNo">346</span>        public double evaluate(double[] values) {<a name="line.346"></a>
-<span class="sourceLineNo">347</span>            return getQuantile();<a name="line.347"></a>
-<span class="sourceLineNo">348</span>        }<a name="line.348"></a>
-<span class="sourceLineNo">349</span>        private static final long serialVersionUID = 8040701391045914979L;<a name="line.349"></a>
-<span class="sourceLineNo">350</span>        @Override<a name="line.350"></a>
-<span class="sourceLineNo">351</span>        public Percentile copy() {<a name="line.351"></a>
-<span class="sourceLineNo">352</span>            subPercentile result = new subPercentile();<a name="line.352"></a>
-<span class="sourceLineNo">353</span>            return result;<a name="line.353"></a>
-<span class="sourceLineNo">354</span>        }<a name="line.354"></a>
-<span class="sourceLineNo">355</span>    }<a name="line.355"></a>
-<span class="sourceLineNo">356</span><a name="line.356"></a>
-<span class="sourceLineNo">357</span>    /**<a name="line.357"></a>
-<span class="sourceLineNo">358</span>     * "Bad" test percentile implementation - no setQuantile<a name="line.358"></a>
-<span class="sourceLineNo">359</span>     */<a name="line.359"></a>
-<span class="sourceLineNo">360</span>    static class badPercentile implements UnivariateStatistic {<a name="line.360"></a>
-<span class="sourceLineNo">361</span>        private Percentile percentile = new Percentile();<a name="line.361"></a>
-<span class="sourceLineNo">362</span>        public double evaluate(double[] values, int begin, int length) {<a name="line.362"></a>
-<span class="sourceLineNo">363</span>            return percentile.evaluate(values, begin, length);<a name="line.363"></a>
-<span class="sourceLineNo">364</span>        }<a name="line.364"></a>
-<span class="sourceLineNo">365</span>        public double evaluate(double[] values) {<a name="line.365"></a>
-<span class="sourceLineNo">366</span>            return percentile.evaluate(values);<a name="line.366"></a>
-<span class="sourceLineNo">367</span>        }<a name="line.367"></a>
-<span class="sourceLineNo">368</span>        public UnivariateStatistic copy() {<a name="line.368"></a>
-<span class="sourceLineNo">369</span>            return new badPercentile();<a name="line.369"></a>
-<span class="sourceLineNo">370</span>        }<a name="line.370"></a>
-<span class="sourceLineNo">371</span>    }<a name="line.371"></a>
-<span class="sourceLineNo">372</span><a name="line.372"></a>
-<span class="sourceLineNo">373</span>}<a name="line.373"></a>
+<span class="sourceLineNo">298</span>        for (int i = 1 ; i &lt;= 6 ; ++i) {<a name="line.298"></a>
+<span class="sourceLineNo">299</span>            dstat.addValue(i);<a name="line.299"></a>
+<span class="sourceLineNo">300</span>        }<a name="line.300"></a>
+<span class="sourceLineNo">301</span><a name="line.301"></a>
+<span class="sourceLineNo">302</span>        Assert.assertTrue(Precision.equalsIncludingNaN(mean1, dstat.getMean()));<a name="line.302"></a>
+<span class="sourceLineNo">303</span>        dstat.replaceMostRecentValue(0);<a name="line.303"></a>
+<span class="sourceLineNo">304</span>        Assert.assertTrue(Precision.equalsIncludingNaN(mean2, dstat.getMean()));<a name="line.304"></a>
+<span class="sourceLineNo">305</span>        dstat.removeMostRecentValue();<a name="line.305"></a>
+<span class="sourceLineNo">306</span>        Assert.assertTrue(Precision.equalsIncludingNaN(mean3, dstat.getMean()));<a name="line.306"></a>
+<span class="sourceLineNo">307</span><a name="line.307"></a>
+<span class="sourceLineNo">308</span>    }<a name="line.308"></a>
+<span class="sourceLineNo">309</span><a name="line.309"></a>
+<span class="sourceLineNo">310</span>    // Test UnivariateStatistics impls for setter injection tests<a name="line.310"></a>
+<span class="sourceLineNo">311</span><a name="line.311"></a>
+<span class="sourceLineNo">312</span>    /**<a name="line.312"></a>
+<span class="sourceLineNo">313</span>     * A new way to compute the mean<a name="line.313"></a>
+<span class="sourceLineNo">314</span>     */<a name="line.314"></a>
+<span class="sourceLineNo">315</span>    static class deepMean implements UnivariateStatistic {<a name="line.315"></a>
+<span class="sourceLineNo">316</span><a name="line.316"></a>
+<span class="sourceLineNo">317</span>        public double evaluate(double[] values, int begin, int length) {<a name="line.317"></a>
+<span class="sourceLineNo">318</span>            return 42;<a name="line.318"></a>
+<span class="sourceLineNo">319</span>        }<a name="line.319"></a>
+<span class="sourceLineNo">320</span><a name="line.320"></a>
+<span class="sourceLineNo">321</span>        public double evaluate(double[] values) {<a name="line.321"></a>
+<span class="sourceLineNo">322</span>            return 42;<a name="line.322"></a>
+<span class="sourceLineNo">323</span>        }<a name="line.323"></a>
+<span class="sourceLineNo">324</span>        public UnivariateStatistic copy() {<a name="line.324"></a>
+<span class="sourceLineNo">325</span>            return new deepMean();<a name="line.325"></a>
+<span class="sourceLineNo">326</span>        }<a name="line.326"></a>
+<span class="sourceLineNo">327</span>    }<a name="line.327"></a>
+<span class="sourceLineNo">328</span><a name="line.328"></a>
+<span class="sourceLineNo">329</span>    /**<a name="line.329"></a>
+<span class="sourceLineNo">330</span>     * Test percentile implementation - wraps a Percentile<a name="line.330"></a>
+<span class="sourceLineNo">331</span>     */<a name="line.331"></a>
+<span class="sourceLineNo">332</span>    static class goodPercentile implements UnivariateStatistic {<a name="line.332"></a>
+<span class="sourceLineNo">333</span>        private Percentile percentile = new Percentile();<a name="line.333"></a>
+<span class="sourceLineNo">334</span>        public void setQuantile(double quantile) {<a name="line.334"></a>
+<span class="sourceLineNo">335</span>            percentile.setQuantile(quantile);<a name="line.335"></a>
+<span class="sourceLineNo">336</span>        }<a name="line.336"></a>
+<span class="sourceLineNo">337</span>        public double evaluate(double[] values, int begin, int length) {<a name="line.337"></a>
+<span class="sourceLineNo">338</span>            return percentile.evaluate(values, begin, length);<a name="line.338"></a>
+<span class="sourceLineNo">339</span>        }<a name="line.339"></a>
+<span class="sourceLineNo">340</span>        public double evaluate(double[] values) {<a name="line.340"></a>
+<span class="sourceLineNo">341</span>            return percentile.evaluate(values);<a name="line.341"></a>
+<span class="sourceLineNo">342</span>        }<a name="line.342"></a>
+<span class="sourceLineNo">343</span>        public UnivariateStatistic copy() {<a name="line.343"></a>
+<span class="sourceLineNo">344</span>            goodPercentile result = new goodPercentile();<a name="line.344"></a>
+<span class="sourceLineNo">345</span>            result.setQuantile(percentile.getQuantile());<a name="line.345"></a>
+<span class="sourceLineNo">346</span>            return result;<a name="line.346"></a>
+<span class="sourceLineNo">347</span>        }<a name="line.347"></a>
+<span class="sourceLineNo">348</span>    }<a name="line.348"></a>
+<span class="sourceLineNo">349</span><a name="line.349"></a>
+<span class="sourceLineNo">350</span>    /**<a name="line.350"></a>
+<span class="sourceLineNo">351</span>     * Test percentile subclass - another "new math" impl<a name="line.351"></a>
+<span class="sourceLineNo">352</span>     * Always returns currently set quantile<a name="line.352"></a>
+<span class="sourceLineNo">353</span>     */<a name="line.353"></a>
+<span class="sourceLineNo">354</span>    static class subPercentile extends Percentile {<a name="line.354"></a>
+<span class="sourceLineNo">355</span>        @Override<a name="line.355"></a>
+<span class="sourceLineNo">356</span>        public double evaluate(double[] values, int begin, int length) {<a name="line.356"></a>
+<span class="sourceLineNo">357</span>            return getQuantile();<a name="line.357"></a>
+<span class="sourceLineNo">358</span>        }<a name="line.358"></a>
+<span class="sourceLineNo">359</span>        @Override<a name="line.359"></a>
+<span class="sourceLineNo">360</span>        public double evaluate(double[] values) {<a name="line.360"></a>
+<span class="sourceLineNo">361</span>            return getQuantile();<a name="line.361"></a>
+<span class="sourceLineNo">362</span>        }<a name="line.362"></a>
+<span class="sourceLineNo">363</span>        private static final long serialVersionUID = 8040701391045914979L;<a name="line.363"></a>
+<span class="sourceLineNo">364</span>        @Override<a name="line.364"></a>
+<span class="sourceLineNo">365</span>        public Percentile copy() {<a name="line.365"></a>
+<span class="sourceLineNo">366</span>            subPercentile result = new subPercentile();<a name="line.366"></a>
+<span class="sourceLineNo">367</span>            return result;<a name="line.367"></a>
+<span class="sourceLineNo">368</span>        }<a name="line.368"></a>
+<span class="sourceLineNo">369</span>    }<a name="line.369"></a>
+<span class="sourceLineNo">370</span><a name="line.370"></a>
+<span class="sourceLineNo">371</span>    /**<a name="line.371"></a>
+<span class="sourceLineNo">372</span>     * "Bad" test percentile implementation - no setQuantile<a name="line.372"></a>
+<span class="sourceLineNo">373</span>     */<a name="line.373"></a>
+<span class="sourceLineNo">374</span>    static class badPercentile implements UnivariateStatistic {<a name="line.374"></a>
+<span class="sourceLineNo">375</span>        private Percentile percentile = new Percentile();<a name="line.375"></a>
+<span class="sourceLineNo">376</span>        public double evaluate(double[] values, int begin, int length) {<a name="line.376"></a>
+<span class="sourceLineNo">377</span>            return percentile.evaluate(values, begin, length);<a name="line.377"></a>
+<span class="sourceLineNo">378</span>        }<a name="line.378"></a>
+<span class="sourceLineNo">379</span>        public double evaluate(double[] values) {<a name="line.379"></a>
+<span class="sourceLineNo">380</span>            return percentile.evaluate(values);<a name="line.380"></a>
+<span class="sourceLineNo">381</span>        }<a name="line.381"></a>
+<span class="sourceLineNo">382</span>        public UnivariateStatistic copy() {<a name="line.382"></a>
+<span class="sourceLineNo">383</span>            return new badPercentile();<a name="line.383"></a>
+<span class="sourceLineNo">384</span>        }<a name="line.384"></a>
+<span class="sourceLineNo">385</span>    }<a name="line.385"></a>
+<span class="sourceLineNo">386</span><a name="line.386"></a>
+<span class="sourceLineNo">387</span>}<a name="line.387"></a>
 
 
 



Mime
View raw message