You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2020/06/23 17:00:45 UTC
[commons-statistics] 18/35: Increase GumbelDistribution test
coverage.
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-statistics.git
commit a1bd094c10cfd2adde352b7dc1131aaa05c8ba36
Author: aherbert <ah...@apache.org>
AuthorDate: Tue Jun 23 14:56:52 2020 +0100
Increase GumbelDistribution test coverage.
---
.../distribution/GumbelDistributionTest.java | 28 ++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/GumbelDistributionTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/GumbelDistributionTest.java
index f0bcf73..fb49112 100644
--- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/GumbelDistributionTest.java
+++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/GumbelDistributionTest.java
@@ -67,4 +67,32 @@ public class GumbelDistributionTest extends ContinuousDistributionAbstractTest {
4.589561e-01, 6.235249e-01, 7.508835e-01, 8.404869e-01, 8.999652e-01
};
}
+
+ // ----------------- Additional test cases ---------------------------------
+
+ @Test
+ public void testInverseCumulativeProbabilityExtremes() {
+ setInverseCumulativeTestPoints(new double[] {0.0, 1.0});
+ setInverseCumulativeTestValues(new double[] {Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY});
+ verifyInverseCumulativeProbabilities();
+ }
+
+ @Test
+ public void testConstructorPrecondition1() {
+ Assertions.assertThrows(IllegalArgumentException.class, () -> new GumbelDistribution(10, -0.1));
+ }
+
+ @Test
+ public void testMoments() {
+ final double tol = 1e-9;
+ GumbelDistribution dist;
+
+ dist = new GumbelDistribution(10, 0.5);
+ Assertions.assertEquals(10 + (Math.PI / (2 * Math.E)) * 0.5, dist.getMean(), tol);
+ Assertions.assertEquals((Math.PI * Math.PI / 6) * 0.5 * 0.5, dist.getVariance(), tol);
+
+ dist = new GumbelDistribution(30, 0.3);
+ Assertions.assertEquals(30 + (Math.PI / (2 * Math.E)) * 0.3, dist.getMean(), tol);
+ Assertions.assertEquals((Math.PI * Math.PI / 6) * 0.3 * 0.3, dist.getVariance(), tol);
+ }
}