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 f6cb74082f594396f15a5c8613e44cc674d8e309 Author: Alex Herbert <[email protected]> AuthorDate: Fri Oct 22 14:16:30 2021 +0100 STATISTICS-37: Update Levy distribution test Commons Numbers 1.1 improved the implementation of erfc and its inverse. Update the levy distribution unit tests to verify the increased precision. --- .../statistics/distribution/LevyDistributionTest.java | 3 +-- .../statistics/distribution/test.levy.1.properties | 16 +++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/LevyDistributionTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/LevyDistributionTest.java index b82d576..f712b1d 100644 --- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/LevyDistributionTest.java +++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/LevyDistributionTest.java @@ -30,8 +30,7 @@ class LevyDistributionTest extends BaseContinuousDistributionTest { @Override protected double getRelativeTolerance() { - // Limited by the inverse CDF which uses InverseErfc. - return 1e-9; + return 1e-14; } @Override diff --git a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.levy.1.properties b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.levy.1.properties index 5ea3d3b..0410f7e 100644 --- a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.levy.1.properties +++ b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.levy.1.properties @@ -14,20 +14,22 @@ # limitations under the License. parameters = 1.2 0.4 -# Required to pass the CDF value test for x=1.21 -tolerance.relative = 1e-7 mean = Inf variance = Inf lower = 1.2 cdf.points = 1.2, 1.2001, 1.21, 1.225, 1.25, 1.3, 1.9, 3.4, 5.6 -# Computed with R and function plevy from rmutil package. +# Computed with matlab using and function plevy from rmutil package. # 0 has been supplemented as R raises an error for x=mu; # 'scipy.stats import levy' returns 0. # Mathematica returns 0. +# +# Points 1.21, 1.225, 1.25 evaluate with low precision using R or scipy. +# They have been corrected using e.g. +# matlab = erfc(sqrt(0.4/(2*(1.21-1.2)))) = 2.5396285894709011e-10 cdf.values = \ 0, 0,\ - 2.5396285074918978353e-10, 6.3342483666239957074e-05,\ - 4.6777349810471768876e-03, 4.5500263896358417171e-02,\ + 2.5396285894709011e-10, 6.3342483666242627e-05,\ + 0.0046777349810472836, 4.5500263896358417171e-02,\ 4.4969179796889102718e-01, 6.6981535759941657204e-01,\ 7.6302460055299503594e-01 pdf.values = \ @@ -50,8 +52,8 @@ sf.hp.values = 1.5957691216057308e-20, 2.4623252122982907e-20 # As cdf.values above but with the redundant 0 removed icdf.points = \ 0,\ - 2.5396285074918978353e-10, 6.3342483666239957074e-05,\ - 4.6777349810471768876e-03, 4.5500263896358417171e-02,\ + 2.5396285894709011e-10, 6.3342483666242627e-05,\ + 0.0046777349810472836, 4.5500263896358417171e-02,\ 4.4969179796889102718e-01, 6.6981535759941657204e-01,\ 7.6302460055299503594e-01 icdf.values = 1.2, 1.21, 1.225, 1.25, 1.3, 1.9, 3.4, 5.6
