1 16 17 package org.apache.commons.math.distribution; 18 19 26 public class WeibullDistributionTest extends ContinuousDistributionAbstractTest { 27 28 32 public WeibullDistributionTest(String arg0) { 33 super(arg0); 34 } 35 36 38 39 public ContinuousDistribution makeDistribution() { 40 return DistributionFactory.newInstance().createWeibullDistribution(1.2, 2.1); 41 } 42 43 44 public double[] makeCumulativeTestPoints() { 45 return new double[] {0.00664355181d, 0.04543282833d, 0.09811627374d, 47 0.1767135246d, 0.3219468654d, 4.207902826d, 5.23968437d, 48 6.232056007d, 7.497630467d, 10.51154969d}; 49 } 50 51 52 public double[] makeCumulativeTestValues() { 53 return new double[] {0.001d, 0.01d, 0.025d, 0.05d, 0.1d, 0.900d, 0.950d, 54 0.975d, 0.990d, 0.999d}; 55 } 56 57 59 public void testInverseCumulativeProbabilityExtremes() throws Exception { 60 setInverseCumulativeTestPoints(new double[] {0.0, 1.0}); 61 setInverseCumulativeTestValues( 62 new double[] {0.0, Double.POSITIVE_INFINITY}); 63 verifyInverseCumulativeProbabilities(); 64 } 65 66 public void testAlpha() { 67 WeibullDistribution distribution = (WeibullDistribution) getDistribution(); 68 double expected = Math.random(); 69 distribution.setShape(expected); 70 assertEquals(expected, distribution.getShape(), 0.0); 71 } 72 73 public void testBeta() { 74 WeibullDistribution distribution = (WeibullDistribution) getDistribution(); 75 double expected = Math.random(); 76 distribution.setScale(expected); 77 assertEquals(expected, distribution.getScale(), 0.0); 78 } 79 80 public void testSetAlpha() { 81 WeibullDistribution distribution = (WeibullDistribution) getDistribution(); 82 try { 83 distribution.setShape(0.0); 84 fail("Can not have 0.0 alpha."); 85 } catch (IllegalArgumentException ex) { 86 } 88 89 try { 90 distribution.setShape(-1.0); 91 fail("Can not have negative alpha."); 92 } catch (IllegalArgumentException ex) { 93 } 95 } 96 97 public void testSetBeta() { 98 WeibullDistribution distribution = (WeibullDistribution) getDistribution(); 99 try { 100 distribution.setScale(0.0); 101 fail("Can not have 0.0 beta."); 102 } catch (IllegalArgumentException ex) { 103 } 105 106 try { 107 distribution.setScale(-1.0); 108 fail("Can not have negative beta."); 109 } catch (IllegalArgumentException ex) { 110 } 112 } 113 } 114 | Popular Tags |