Java Code Examples for org.apache.commons.math.stat.descriptive.SummaryStatistics#getStandardDeviation()
The following examples show how to use
org.apache.commons.math.stat.descriptive.SummaryStatistics#getStandardDeviation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RandomDataTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** test failure modes and distribution of nextGaussian() */ @Test public void testNextGaussian() { try { randomData.nextGaussian(0, 0); Assert.fail("zero sigma -- MathIllegalArgumentException expected"); } catch (MathIllegalArgumentException ex) { // ignored } SummaryStatistics u = new SummaryStatistics(); for (int i = 0; i < largeSampleSize; i++) { u.addValue(randomData.nextGaussian(0, 1)); } double xbar = u.getMean(); double s = u.getStandardDeviation(); double n = u.getN(); /* * t-test at .001-level TODO: replace with externalized t-test, with * test statistic defined in TestStatistic */ Assert.assertTrue(FastMath.abs(xbar) / (s / FastMath.sqrt(n)) < 3.29); }
Example 2
Source File: EmpiricalDistributionImpl.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Generates a random value from this distribution. * * @return the random value. * @throws IllegalStateException if the distribution has not been loaded */ public double getNextValue() throws IllegalStateException { if (!loaded) { throw MathRuntimeException.createIllegalStateException("distribution not loaded"); } // Start with a uniformly distributed random number in (0,1) double x = Math.random(); // Use this to select the bin and generate a Gaussian within the bin for (int i = 0; i < binCount; i++) { if (x <= upperBounds[i]) { SummaryStatistics stats = binStats.get(i); if (stats.getN() > 0) { if (stats.getStandardDeviation() > 0) { // more than one obs return randomData.nextGaussian (stats.getMean(),stats.getStandardDeviation()); } else { return stats.getMean(); // only one obs in bin } } } } throw new MathRuntimeException("no bin selected"); }
Example 3
Source File: RandomDataTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** test failure modes and distribution of nextGaussian() */ public void testNextGaussian() { try { randomData.nextGaussian(0, 0); fail("zero sigma -- IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { // ignored } SummaryStatistics u = new SummaryStatistics(); for (int i = 0; i < largeSampleSize; i++) { u.addValue(randomData.nextGaussian(0, 1)); } double xbar = u.getMean(); double s = u.getStandardDeviation(); double n = u.getN(); /* * t-test at .001-level TODO: replace with externalized t-test, with * test statistic defined in TestStatistic */ assertTrue(Math.abs(xbar) / (s / Math.sqrt(n)) < 3.29); }
Example 4
Source File: EmpiricalDistributionImpl.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Generates a random value from this distribution. * * @return the random value. * @throws IllegalStateException if the distribution has not been loaded */ public double getNextValue() throws IllegalStateException { if (!loaded) { throw MathRuntimeException.createIllegalStateException("distribution not loaded"); } // Start with a uniformly distributed random number in (0,1) double x = Math.random(); // Use this to select the bin and generate a Gaussian within the bin for (int i = 0; i < binCount; i++) { if (x <= upperBounds[i]) { SummaryStatistics stats = binStats.get(i); if (stats.getN() > 0) { if (stats.getStandardDeviation() > 0) { // more than one obs return randomData.nextGaussian (stats.getMean(),stats.getStandardDeviation()); } else { return stats.getMean(); // only one obs in bin } } } } throw new MathRuntimeException("no bin selected"); }
Example 5
Source File: RandomDataTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** test failure modes and distribution of nextGaussian() */ @Test public void testNextGaussian() { try { randomData.nextGaussian(0, 0); Assert.fail("zero sigma -- MathIllegalArgumentException expected"); } catch (MathIllegalArgumentException ex) { // ignored } SummaryStatistics u = new SummaryStatistics(); for (int i = 0; i < largeSampleSize; i++) { u.addValue(randomData.nextGaussian(0, 1)); } double xbar = u.getMean(); double s = u.getStandardDeviation(); double n = u.getN(); /* * t-test at .001-level TODO: replace with externalized t-test, with * test statistic defined in TestStatistic */ Assert.assertTrue(FastMath.abs(xbar) / (s / FastMath.sqrt(n)) < 3.29); }
Example 6
Source File: EmpiricalDistributionImpl.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Generates a random value from this distribution. * * @return the random value. * @throws IllegalStateException if the distribution has not been loaded */ public double getNextValue() throws IllegalStateException { if (!loaded) { throw MathRuntimeException.createIllegalStateException("distribution not loaded"); } // Start with a uniformly distributed random number in (0,1) double x = Math.random(); // Use this to select the bin and generate a Gaussian within the bin for (int i = 0; i < binCount; i++) { if (x <= upperBounds[i]) { SummaryStatistics stats = binStats.get(i); if (stats.getN() > 0) { if (stats.getStandardDeviation() > 0) { // more than one obs return randomData.nextGaussian (stats.getMean(),stats.getStandardDeviation()); } else { return stats.getMean(); // only one obs in bin } } } } throw new MathRuntimeException("no bin selected"); }
Example 7
Source File: RandomDataTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** test failure modes and distribution of nextGaussian() */ public void testNextGaussian() { try { double x = randomData.nextGaussian(0,0); fail("zero sigma -- IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { ; } SummaryStatistics u = SummaryStatistics.newInstance(); for (int i = 0; i<largeSampleSize; i++) { u.addValue(randomData.nextGaussian(0,1)); } double xbar = u.getMean(); double s = u.getStandardDeviation(); double n = (double) u.getN(); /* t-test at .001-level TODO: replace with externalized t-test, with * test statistic defined in TestStatistic */ assertTrue(Math.abs(xbar)/(s/Math.sqrt(n))< 3.29); }
Example 8
Source File: EmpiricalDistributionImpl.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Generates a random value from this distribution. * * @return the random value. * @throws IllegalStateException if the distribution has not been loaded */ public double getNextValue() throws IllegalStateException { if (!loaded) { throw MathRuntimeException.createIllegalStateException("distribution not loaded"); } // Start with a uniformly distributed random number in (0,1) double x = Math.random(); // Use this to select the bin and generate a Gaussian within the bin for (int i = 0; i < binCount; i++) { if (x <= upperBounds[i]) { SummaryStatistics stats = binStats.get(i); if (stats.getN() > 0) { if (stats.getStandardDeviation() > 0) { // more than one obs return randomData.nextGaussian (stats.getMean(),stats.getStandardDeviation()); } else { return stats.getMean(); // only one obs in bin } } } } throw new MathRuntimeException("no bin selected"); }
Example 9
Source File: RandomDataTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** test failure modes and distribution of nextGaussian() */ public void testNextGaussian() { try { randomData.nextGaussian(0, 0); fail("zero sigma -- IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { // ignored } SummaryStatistics u = new SummaryStatistics(); for (int i = 0; i < largeSampleSize; i++) { u.addValue(randomData.nextGaussian(0, 1)); } double xbar = u.getMean(); double s = u.getStandardDeviation(); double n = u.getN(); /* * t-test at .001-level TODO: replace with externalized t-test, with * test statistic defined in TestStatistic */ assertTrue(Math.abs(xbar) / (s / Math.sqrt(n)) < 3.29); }
Example 10
Source File: EmpiricalDistributionImpl.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Generates a random value from this distribution. * * @return the random value. * @throws IllegalStateException if the distribution has not been loaded */ public double getNextValue() throws IllegalStateException { if (!loaded) { throw MathRuntimeException.createIllegalStateException("distribution not loaded"); } // Start with a uniformly distributed random number in (0,1) double x = Math.random(); // Use this to select the bin and generate a Gaussian within the bin for (int i = 0; i < binCount; i++) { if (x <= upperBounds[i]) { SummaryStatistics stats = binStats.get(i); if (stats.getN() > 0) { if (stats.getStandardDeviation() > 0) { // more than one obs return randomData.nextGaussian (stats.getMean(),stats.getStandardDeviation()); } else { return stats.getMean(); // only one obs in bin } } } } throw new MathRuntimeException("no bin selected"); }
Example 11
Source File: EmpiricalDistributionImpl.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * Generates a random value from this distribution. * * @return the random value. * @throws IllegalStateException if the distribution has not been loaded */ public double getNextValue() throws IllegalStateException { if (!loaded) { throw new IllegalStateException("distribution not loaded"); } // Start with a uniformly distributed random number in (0,1) double x = Math.random(); // Use this to select the bin and generate a Gaussian within the bin for (int i = 0; i < binCount; i++) { if (x <= upperBounds[i]) { SummaryStatistics stats = (SummaryStatistics)binStats.get(i); if (stats.getN() > 0) { if (stats.getStandardDeviation() > 0) { // more than one obs return randomData.nextGaussian (stats.getMean(),stats.getStandardDeviation()); } else { return stats.getMean(); // only one obs in bin } } } } throw new RuntimeException("No bin selected"); }
Example 12
Source File: RandomDataTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** test failure modes and distribution of nextGaussian() */ public void testNextGaussian() { try { randomData.nextGaussian(0, 0); fail("zero sigma -- IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { // ignored } SummaryStatistics u = new SummaryStatistics(); for (int i = 0; i < largeSampleSize; i++) { u.addValue(randomData.nextGaussian(0, 1)); } double xbar = u.getMean(); double s = u.getStandardDeviation(); double n = u.getN(); /* * t-test at .001-level TODO: replace with externalized t-test, with * test statistic defined in TestStatistic */ assertTrue(Math.abs(xbar) / (s / Math.sqrt(n)) < 3.29); }
Example 13
Source File: RandomDataTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** test failure modes and distribution of nextGaussian() */ public void testNextGaussian() { try { randomData.nextGaussian(0, 0); fail("zero sigma -- IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { // ignored } SummaryStatistics u = new SummaryStatistics(); for (int i = 0; i < largeSampleSize; i++) { u.addValue(randomData.nextGaussian(0, 1)); } double xbar = u.getMean(); double s = u.getStandardDeviation(); double n = u.getN(); /* * t-test at .001-level TODO: replace with externalized t-test, with * test statistic defined in TestStatistic */ assertTrue(FastMath.abs(xbar) / (s / FastMath.sqrt(n)) < 3.29); }
Example 14
Source File: EmpiricalDistributionImpl.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Generates a random value from this distribution. * * @return the random value. * @throws IllegalStateException if the distribution has not been loaded */ public double getNextValue() throws IllegalStateException { if (!loaded) { throw MathRuntimeException.createIllegalStateException(LocalizedFormats.DISTRIBUTION_NOT_LOADED); } // Start with a uniformly distributed random number in (0,1) double x = randomData.nextUniform(0,1); // Use this to select the bin and generate a Gaussian within the bin for (int i = 0; i < binCount; i++) { if (x <= upperBounds[i]) { SummaryStatistics stats = binStats.get(i); if (stats.getN() > 0) { if (stats.getStandardDeviation() > 0) { // more than one obs return randomData.nextGaussian (stats.getMean(),stats.getStandardDeviation()); } else { return stats.getMean(); // only one obs in bin } } } } throw new MathRuntimeException(LocalizedFormats.NO_BIN_SELECTED); }
Example 15
Source File: EmpiricalDistributionImpl.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Generates a random value from this distribution. * * @return the random value. * @throws IllegalStateException if the distribution has not been loaded */ public double getNextValue() throws IllegalStateException { if (!loaded) { throw MathRuntimeException.createIllegalStateException("distribution not loaded"); } // Start with a uniformly distributed random number in (0,1) double x = Math.random(); // Use this to select the bin and generate a Gaussian within the bin for (int i = 0; i < binCount; i++) { if (x <= upperBounds[i]) { SummaryStatistics stats = binStats.get(i); if (stats.getN() > 0) { if (stats.getStandardDeviation() > 0) { // more than one obs return randomData.nextGaussian (stats.getMean(),stats.getStandardDeviation()); } else { return stats.getMean(); // only one obs in bin } } } } throw new MathRuntimeException("no bin selected"); }
Example 16
Source File: EmpiricalDistributionImpl.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Generates a random value from this distribution. * * @return the random value. * @throws IllegalStateException if the distribution has not been loaded */ public double getNextValue() throws IllegalStateException { if (!loaded) { throw MathRuntimeException.createIllegalStateException(LocalizedFormats.DISTRIBUTION_NOT_LOADED); } // Start with a uniformly distributed random number in (0,1) double x = FastMath.random(); // Use this to select the bin and generate a Gaussian within the bin for (int i = 0; i < binCount; i++) { if (x <= upperBounds[i]) { SummaryStatistics stats = binStats.get(i); if (stats.getN() > 0) { if (stats.getStandardDeviation() > 0) { // more than one obs return randomData.nextGaussian (stats.getMean(),stats.getStandardDeviation()); } else { return stats.getMean(); // only one obs in bin } } } } throw new MathRuntimeException(LocalizedFormats.NO_BIN_SELECTED); }
Example 17
Source File: RandomDataTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** test failure modes and distribution of nextGaussian() */ public void testNextGaussian() { try { randomData.nextGaussian(0, 0); fail("zero sigma -- IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { // ignored } SummaryStatistics u = new SummaryStatistics(); for (int i = 0; i < largeSampleSize; i++) { u.addValue(randomData.nextGaussian(0, 1)); } double xbar = u.getMean(); double s = u.getStandardDeviation(); double n = u.getN(); /* * t-test at .001-level TODO: replace with externalized t-test, with * test statistic defined in TestStatistic */ assertTrue(Math.abs(xbar) / (s / Math.sqrt(n)) < 3.29); }
Example 18
Source File: RandomDataTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** test failure modes and distribution of nextGaussian() */ public void testNextGaussian() { try { randomData.nextGaussian(0, 0); fail("zero sigma -- IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { // ignored } SummaryStatistics u = new SummaryStatistics(); for (int i = 0; i < largeSampleSize; i++) { u.addValue(randomData.nextGaussian(0, 1)); } double xbar = u.getMean(); double s = u.getStandardDeviation(); double n = u.getN(); /* * t-test at .001-level TODO: replace with externalized t-test, with * test statistic defined in TestStatistic */ assertTrue(Math.abs(xbar) / (s / Math.sqrt(n)) < 3.29); }
Example 19
Source File: EmpiricalDistributionImpl.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Generates a random value from this distribution. * * @return the random value. * @throws IllegalStateException if the distribution has not been loaded */ public double getNextValue() throws IllegalStateException { if (!loaded) { throw MathRuntimeException.createIllegalStateException("distribution not loaded"); } // Start with a uniformly distributed random number in (0,1) double x = Math.random(); // Use this to select the bin and generate a Gaussian within the bin for (int i = 0; i < binCount; i++) { if (x <= upperBounds[i]) { SummaryStatistics stats = binStats.get(i); if (stats.getN() > 0) { if (stats.getStandardDeviation() > 0) { // more than one obs return randomData.nextGaussian (stats.getMean(),stats.getStandardDeviation()); } else { return stats.getMean(); // only one obs in bin } } } } throw new MathRuntimeException("no bin selected"); }
Example 20
Source File: RandomDataTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
/** test failure modes and distribution of nextGaussian() */ public void testNextGaussian() { try { randomData.nextGaussian(0,0); fail("zero sigma -- IllegalArgumentException expected"); } catch (IllegalArgumentException ex) { ; } SummaryStatistics u = new SummaryStatistics(); for (int i = 0; i<largeSampleSize; i++) { u.addValue(randomData.nextGaussian(0,1)); } double xbar = u.getMean(); double s = u.getStandardDeviation(); double n = (double) u.getN(); /* t-test at .001-level TODO: replace with externalized t-test, with * test statistic defined in TestStatistic */ assertTrue(Math.abs(xbar)/(s/Math.sqrt(n))< 3.29); }