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 bf13f6969a26efe61d7fb2d5d7ea82a551d2d101 Author: aherbert <aherb...@apache.org> AuthorDate: Fri Nov 25 18:51:50 2022 +0000 Support per-test properties (tolerance, disable) Use an enum to define the standard test names. This is the key in the test resource file used to look-up the test tolerance and disable flag. --- .../BaseContinuousDistributionTest.java | 146 ++++----- .../distribution/BaseDiscreteDistributionTest.java | 171 ++++++----- .../distribution/BaseDistributionTest.java | 327 +++------------------ .../distribution/DistributionTestData.java | 277 +++++++---------- .../HypergeometricDistributionTest.java | 4 +- .../distribution/NormalDistributionTest.java | 10 - .../distribution/ParetoDistributionTest.java | 4 +- .../distribution/PoissonDistributionTest.java | 2 +- .../commons/statistics/distribution/TestName.java | 82 ++++++ .../distribution/test.binomial.2.properties | 1 + .../distribution/test.binomial.3.properties | 1 + .../statistics/distribution/test.levy.1.properties | 1 + .../distribution/test.normal.1.properties | 2 + .../distribution/test.pareto.10.properties | 2 +- .../distribution/test.pareto.11.properties | 2 +- .../distribution/test.pareto.5.properties | 2 +- .../distribution/test.pareto.6.properties | 2 +- .../distribution/test.pareto.7.properties | 2 +- .../distribution/test.pareto.9.properties | 2 +- 19 files changed, 399 insertions(+), 641 deletions(-) diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BaseContinuousDistributionTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BaseContinuousDistributionTest.java index 2510156..a9831d4 100644 --- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BaseContinuousDistributionTest.java +++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BaseContinuousDistributionTest.java @@ -89,13 +89,11 @@ import org.junit.jupiter.params.provider.MethodSource; * <li>Points for the PDF (and log PDF) can be specified. The default will use the CDF points. * Note: It is not expected that evaluation of the PDF will require different points to the CDF. * <li>Points and expected values for the inverse CDF can be specified. These are used in - * addition to test the inverse mapping of the CDF values to the CDF test points. The - * inverse mapping test can be disabled. + * addition to test the inverse mapping of the CDF values to the CDF test points. * <li>Expected values for the log PDF can be specified. The default will use * {@link Math#log(double)} on the PDF values. * <li>Points and expected values for the survival function can be specified. These are used in - * addition to test the inverse mapping of the SF values to the SF test points. The - * inverse mapping test can be disabled. + * addition to test the inverse mapping of the SF values to the SF test points. * The default will use the expected CDF values (SF = 1 - CDF). * <li>A tolerance for equality assertions. The default is set by {@link #getAbsoluteTolerance()} * and {@link #getRelativeTolerance()}. @@ -103,9 +101,19 @@ import org.junit.jupiter.params.provider.MethodSource; * * <p>If the distribution provides higher precision implementations of * cumulative probability and/or survival probability as the values approach zero, then test - * points and expected values can be provided with a tolerance for equality assertions of - * high-precision computations. The default is set by {@link #getHighPrecisionAbsoluteTolerance()} - * and {@link #getHighPrecisionRelativeTolerance()}. + * points and expected values can be provided for high-precision computations. If the default + * absolute tolerance has been set to non-zero, then very small p-values will require the + * high-precision absolute tolerance is configured for the test to a suitable magnitude (see below). + * + * <p>Per-test configuration + * + * <p>Each test is identified with a {@link TestName} key in the properties file. This key + * can be used to set a per-test tolerance, or disable the test: + * <pre> + * cdf.hp.relative = 1e-14 + * cdf.hp.absolute = 1e-50 + * sampling.disable + * </pre> * * <p>Note: All properties files are read during test initialization. Any errors in a single * property file will throw an exception, invalidating the initialization and no tests @@ -138,7 +146,7 @@ import org.junit.jupiter.params.provider.MethodSource; * * <p>The properties file uses {@code key=value} pairs loaded using a * {@link java.util.Properties} object. Values will be read as String and then parsed to - * numeric data, and data arrays. Multi-line values can use a {@code \} character. + * numeric data, and data arrays. Multi-line values can use a {@code \} character to join lines. * Data in the properties file will be converted to numbers using standard parsing * functions appropriate to the primitive type, e.g. {@link Double#parseDouble(String)}. * Special double values should use NaN, Infinity and -Infinity. As a convenience @@ -159,10 +167,6 @@ import org.junit.jupiter.params.provider.MethodSource; * tolerance.relative = 1e-9 * # optional (default 0.0 or over-ridden in getAbsoluteTolerance()) * tolerance.absolute = 0.0 - * # optional (default 1e-12 or over-ridden in getHighPrecisionRelativeTolerance()) - * tolerance.relative.hp = 1e-10 - * # optional (default 0.0 or over-ridden in getHighPrecisionAbsoluteTolerance()) - * tolerance.absolute.hp = 1e-30 * cdf.points = 0, 0.2 * cdf.values = 0.0, 0.5 * # optional (default uses cdf.points) @@ -186,20 +190,10 @@ import org.junit.jupiter.params.provider.MethodSource; * # optional inverse CDF test (defaults to ignore) * isf.points = 1.0, 0.5 * isf.values = 0.0, 0.2 - * # CDF inverse mapping test (default false) - * disable.cdf.inverse = false - * # SF inverse mapping test (default false) - * disable.sf.inverse = false - * # Sampling test (default false) - * disable.sample = false - * # PDF values test (default false) - * disable.pdf = false - * # Log PDF values test (default false) - * disable.logpdf = false - * # CDF values test (default false) - * disable.cdf = false - * # Survival function values test (default false) - * disable.sf = false + * # Optional per-test tolerance and disable + * cdf.hp.relative = 1e-14 + * cdf.hp.absolute = 1e-50 + * sampling.disable = true * </pre> * * <p>See {@link NakagamiDistributionTest} for an example and the resource file {@code test.nakagami.1.properties}. @@ -224,17 +218,6 @@ abstract class BaseContinuousDistributionTest // as the @ParameterizedTest method. These can be overridden by child classes to // stream different arguments to the test case. - /** - * Create a stream of arguments containing the distribution to test, the CDF - * test points and the test tolerance. - * - * @return the stream - */ - Stream<Arguments> streamCdfTestPoints() { - return streamPoints(ContinuousDistributionTestData::getCdfPoints, - this::createTestTolerance, "cdf test points"); - } - /** * Create a stream of arguments containing the distribution to test, the PDF test points * and values, and the test tolerance. @@ -242,10 +225,9 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testDensity() { - return stream(ContinuousDistributionTestData::isDisablePdf, + return stream(TestName.PDF, ContinuousDistributionTestData::getPdfPoints, - ContinuousDistributionTestData::getPdfValues, - this::createTestTolerance, "pdf"); + ContinuousDistributionTestData::getPdfValues); } /** @@ -255,10 +237,9 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testLogDensity() { - return stream(ContinuousDistributionTestData::isDisableLogPdf, + return stream(TestName.LOGPDF, ContinuousDistributionTestData::getPdfPoints, - ContinuousDistributionTestData::getLogPdfValues, - this::createTestTolerance, "logpdf"); + ContinuousDistributionTestData::getLogPdfValues); } /** @@ -268,10 +249,9 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testCumulativeProbability() { - return stream(ContinuousDistributionTestData::isDisableCdf, + return stream(TestName.CDF, ContinuousDistributionTestData::getCdfPoints, - ContinuousDistributionTestData::getCdfValues, - this::createTestTolerance, "cdf"); + ContinuousDistributionTestData::getCdfValues); } /** @@ -283,10 +263,9 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testSurvivalProbability() { - return stream(ContinuousDistributionTestData::isDisableSf, + return stream(TestName.SF, ContinuousDistributionTestData::getSfPoints, - ContinuousDistributionTestData::getSfValues, - this::createTestTolerance, "sf"); + ContinuousDistributionTestData::getSfValues); } /** @@ -296,9 +275,9 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testCumulativeProbabilityHighPrecision() { - return stream(ContinuousDistributionTestData::getCdfHpPoints, - ContinuousDistributionTestData::getCdfHpValues, - this::createTestHighPrecisionTolerance, "cdf.hp"); + return stream(TestName.CDF_HP, + ContinuousDistributionTestData::getCdfHpPoints, + ContinuousDistributionTestData::getCdfHpValues); } /** @@ -308,9 +287,9 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testSurvivalProbabilityHighPrecision() { - return stream(ContinuousDistributionTestData::getSfHpPoints, - ContinuousDistributionTestData::getSfHpValues, - this::createTestHighPrecisionTolerance, "sf.hp"); + return stream(TestName.SF_HP, + ContinuousDistributionTestData::getSfHpPoints, + ContinuousDistributionTestData::getSfHpValues); } /** @@ -320,9 +299,9 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testInverseCumulativeProbability() { - return stream(ContinuousDistributionTestData::getIcdfPoints, - ContinuousDistributionTestData::getIcdfValues, - this::createTestTolerance, "icdf"); + return stream(TestName.ICDF, + ContinuousDistributionTestData::getIcdfPoints, + ContinuousDistributionTestData::getIcdfValues); } /** @@ -332,9 +311,9 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testInverseSurvivalProbability() { - return stream(ContinuousDistributionTestData::getIsfPoints, - ContinuousDistributionTestData::getIsfValues, - this::createTestTolerance, "isf"); + return stream(TestName.ISF, + ContinuousDistributionTestData::getIsfPoints, + ContinuousDistributionTestData::getIsfValues); } /** @@ -345,9 +324,8 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testCumulativeProbabilityInverseMapping() { - return streamPoints(ContinuousDistributionTestData::isDisableCdfInverse, - ContinuousDistributionTestData::getCdfPoints, - this::createTestTolerance, "cdf test points"); + return stream(TestName.CDF_MAPPING, + ContinuousDistributionTestData::getCdfPoints); } /** @@ -358,9 +336,8 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testSurvivalProbabilityInverseMapping() { - return streamPoints(ContinuousDistributionTestData::isDisableSfInverse, - ContinuousDistributionTestData::getSfPoints, - this::createTestTolerance, "sf test points"); + return stream(TestName.SF_MAPPING, + ContinuousDistributionTestData::getSfPoints); } /** @@ -370,9 +347,10 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testSurvivalAndCumulativeProbabilityComplement() { - // This is not disabled based on isDisableCdf && isDisableSf. + // This is not disabled based on cdf.disable && sf.disable. // Those flags are intended to ignore tests against reference values. - return streamCdfTestPoints(); + return stream(TestName.COMPLEMENT, + ContinuousDistributionTestData::getCdfPoints); } /** @@ -383,9 +361,10 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testConsistency() { - // This is not disabled based on isDisableCdf. - // That flags is intended to ignore tests against reference values. - return streamCdfTestPoints(); + // This is not disabled based on cdf.disable. + // That flag is intended to ignore tests against reference values. + return stream(TestName.CONSISTENCY, + ContinuousDistributionTestData::getCdfPoints); } /** @@ -394,7 +373,7 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testSampling() { - return streamDistributionWithFilter(ContinuousDistributionTestData::isDisableSample, "sampling"); + return stream(TestName.SAMPLING); } /** @@ -404,20 +383,17 @@ abstract class BaseContinuousDistributionTest * the underlying integrator (abs=1e-10, rel=1e-12). * Override this method to change the tolerance. * - * <p>This is disabled by {@link ContinuousDistributionTestData#isDisablePdf()}. If - * the distribution cannot compute the density to match reference values then it - * is assumed an integral of the PDF will fail to match reference CDF values. - * * @return the stream */ Stream<Arguments> testDensityIntegrals() { // Create a tolerance suitable for the same thresholds used by the integrator. final Function<ContinuousDistributionTestData, DoubleTolerance> tolerance = d -> createAbsOrRelTolerance(INTEGRATOR_ABS_ACCURACY * 10, INTEGRATOR_REL_ACCURACY * 10); - return stream(ContinuousDistributionTestData::isDisablePdf, + final TestName name = TestName.INTEGRALS; + return stream(d -> d.isDisabled(name), ContinuousDistributionTestData::getCdfPoints, ContinuousDistributionTestData::getCdfValues, - tolerance, "pdf integrals"); + tolerance, name.toString()); } /** @@ -427,7 +403,8 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testSupport() { - return data.stream().map(d -> Arguments.of(namedDistribution(d.getParameters()), d.getLower(), d.getUpper())); + return streamArguments(TestName.SUPPORT, + d -> Arguments.of(namedDistribution(d.getParameters()), d.getLower(), d.getUpper())); } /** @@ -437,7 +414,10 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testMoments() { - return data.stream().map(d -> Arguments.of(namedDistribution(d.getParameters()), d.getMean(), d.getVariance(), createTestTolerance(d))); + final TestName name = TestName.MOMENTS; + return streamArguments(name, + d -> Arguments.of(namedDistribution(d.getParameters()), d.getMean(), d.getVariance(), + createTestTolerance(d, name))); } /** @@ -446,7 +426,9 @@ abstract class BaseContinuousDistributionTest * @return the stream */ Stream<Arguments> testMedian() { - return data.stream().map(d -> Arguments.of(namedDistribution(d.getParameters()), createTestTolerance(d))); + final TestName name = TestName.MEDIAN; + return streamArguments(name, + d -> Arguments.of(namedDistribution(d.getParameters()), createTestTolerance(d, name))); } //------------------------ Tests ----------------------------- diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BaseDiscreteDistributionTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BaseDiscreteDistributionTest.java index 6253e56..c38483a 100644 --- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BaseDiscreteDistributionTest.java +++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BaseDiscreteDistributionTest.java @@ -65,7 +65,7 @@ import org.junit.jupiter.params.provider.MethodSource; * The parameters are parsed from String values to the appropriate parameter object. Currently * this supports Double and Integer; numbers can be unboxed and used to create the distribution. * - * <p>Illegal arguments for the distribution are tested from parametersprovided by + * <p>Illegal arguments for the distribution are tested from parameters provided by * {@link #makeInvalidParameters()}. If there are no illegal arguments this method may return * null to skip the test. Primitive parameters are boxed to objects so ensure the canonical form * is used, e.g. {@code 1.0} not {@code 1} for a {@code double} argument. @@ -87,13 +87,11 @@ import org.junit.jupiter.params.provider.MethodSource; * <li>Points for the PMF (and log PMF) can be specified. The default will use the CDF points. * Note: It is not expected that evaluation of the PMF will require different points to the CDF. * <li>Points and expected values for the inverse CDF can be specified. These are used in - * addition to test the inverse mapping of the CDF values to the CDF test points. The - * inverse mapping test can be disabled. + * addition to test the inverse mapping of the CDF values to the CDF test points. * <li>Expected values for the log PMF can be specified. The default will use * {@link Math#log(double)} on the PMF values. * <li>Points and expected values for the survival function can be specified. These are used in - * addition to test the inverse mapping of the SF values to the SF test points. The - * inverse mapping test can be disabled. + * addition to test the inverse mapping of the SF values to the SF test points. * The default will use the expected CDF values (SF = 1 - CDF). * <li>A tolerance for equality assertions. The default is set by {@link #getAbsoluteTolerance()} * and {@link #getRelativeTolerance()}. @@ -101,9 +99,19 @@ import org.junit.jupiter.params.provider.MethodSource; * * <p>If the distribution provides higher precision implementations of * cumulative probability and/or survival probability as the values approach zero, then test - * points and expected values can be provided with a tolerance for equality assertions of - * high-precision computations. The default is set by {@link #getHighPrecisionAbsoluteTolerance()} - * and {@link #getHighPrecisionRelativeTolerance()}. + * points and expected values can be provided for high-precision computations. If the default + * absolute tolerance has been set to non-zero, then very small p-values will require the + * high-precision absolute tolerance is configured for the test to a suitable magnitude (see below). + * + * <p>Per-test configuration + * + * <p>Each test is identified with a {@link TestName} key in the properties file. This key + * can be used to set a per-test tolerance, or disable the test: + * <pre> + * cdf.hp.relative = 1e-14 + * cdf.hp.absolute = 1e-50 + * sampling.disable + * </pre> * * <p>Note: All properties files are read during test initialization. Any errors in a single * property file will throw an exception, invalidating the initialization and no tests @@ -136,7 +144,7 @@ import org.junit.jupiter.params.provider.MethodSource; * * <p>The properties file uses {@code key=value} pairs loaded using a * {@link java.util.Properties} object. Values will be read as String and then parsed to - * numeric data, and data arrays. Multi-line values can use a {@code \} character. + * numeric data, and data arrays. Multi-line values can use a {@code \} character to join lines. * Data in the properties file will be converted to numbers using standard parsing * functions appropriate to the primitive type, e.g. {@link Double#parseDouble(String)}. * Special double values should use NaN, Infinity and -Infinity. As a convenience @@ -158,10 +166,6 @@ import org.junit.jupiter.params.provider.MethodSource; * tolerance.relative = 1e-9 * # optional (default 0.0 or over-ridden in getAbsoluteTolerance()) * tolerance.absolute = 0.0 - * # optional (default 1e-12 or over-ridden in getHighPrecisionRelativeTolerance()) - * tolerance.relative.hp = 1e-10 - * # optional (default 0.0 or over-ridden in getHighPrecisionAbsoluteTolerance()) - * tolerance.absolute.hp = 1e-30 * cdf.points = 0, 2 * cdf.values = 0.0, 0.5 * # optional (default uses cdf.points) @@ -185,22 +189,10 @@ import org.junit.jupiter.params.provider.MethodSource; * # optional inverse CDF test (defaults to ignore) * isf.points = 1.0, 0.5 * isf.values = 3, 4 - * # CDF inverse mapping test (default false) - * disable.cdf.inverse = false - * # SF inverse mapping test (default false) - * disable.sf.inverse = false - * # Sampling test (default false) - * disable.sample = false - * # PMF values test (default false) - * disable.pmf = false - * # Log PMF values test (default false) - * disable.logpmf = false - * # CDF values test (default false) - * disable.cdf = false - * # Survival function values test (default false) - * disable.sf = false - * # Sampling PMF summation verses CDF test (default false) - * disable.pmf.sum = false + * # Optional per-test tolerance and disable + * cdf.hp.relative = 1e-14 + * cdf.hp.absolute = 1e-50 + * sampling.disable = true * </pre> * * <p>See {@link BinomialDistributionTest} for an example and the resource file {@code test.binomial.1.properties}. @@ -224,14 +216,15 @@ abstract class BaseDiscreteDistributionTest // stream different arguments to the test case. /** - * Create a stream of arguments containing the distribution to test, the CDF test points and - * the test tolerance. + * Create a stream of arguments containing the distribution to test, the CDF test + * points and the test tolerance. * + * @param name Name of the function under test * @return the stream */ - Stream<Arguments> streamCdfTestPoints() { - return streamPoints(DiscreteDistributionTestData::getCdfPoints, - this::createTestTolerance, "cdf test points"); + Stream<Arguments> streamCdfTestPoints(TestName name) { + return stream(name, + DiscreteDistributionTestData::getCdfPoints); } /** @@ -241,10 +234,9 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testProbability() { - return stream(DiscreteDistributionTestData::isDisablePmf, + return stream(TestName.PMF, DiscreteDistributionTestData::getPmfPoints, - DiscreteDistributionTestData::getPmfValues, - this::createTestTolerance, "pmf"); + DiscreteDistributionTestData::getPmfValues); } /** @@ -254,10 +246,9 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testLogProbability() { - return stream(DiscreteDistributionTestData::isDisableLogPmf, + return stream(TestName.LOGPMF, DiscreteDistributionTestData::getPmfPoints, - DiscreteDistributionTestData::getLogPmfValues, - this::createTestTolerance, "logpmf"); + DiscreteDistributionTestData::getLogPmfValues); } /** @@ -267,10 +258,9 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testCumulativeProbability() { - return stream(DiscreteDistributionTestData::isDisableCdf, + return stream(TestName.CDF, DiscreteDistributionTestData::getCdfPoints, - DiscreteDistributionTestData::getCdfValues, - this::createTestTolerance, "cdf"); + DiscreteDistributionTestData::getCdfValues); } /** @@ -282,10 +272,9 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testSurvivalProbability() { - return stream(DiscreteDistributionTestData::isDisableSf, + return stream(TestName.SF, DiscreteDistributionTestData::getSfPoints, - DiscreteDistributionTestData::getSfValues, - this::createTestTolerance, "sf"); + DiscreteDistributionTestData::getSfValues); } /** @@ -295,9 +284,9 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testCumulativeProbabilityHighPrecision() { - return stream(DiscreteDistributionTestData::getCdfHpPoints, - DiscreteDistributionTestData::getCdfHpValues, - this::createTestHighPrecisionTolerance, "cdf.hp"); + return stream(TestName.CDF_HP, + DiscreteDistributionTestData::getCdfHpPoints, + DiscreteDistributionTestData::getCdfHpValues); } /** @@ -307,9 +296,9 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testSurvivalProbabilityHighPrecision() { - return stream(DiscreteDistributionTestData::getSfHpPoints, - DiscreteDistributionTestData::getSfHpValues, - this::createTestHighPrecisionTolerance, "sf.hp"); + return stream(TestName.SF_HP, + DiscreteDistributionTestData::getSfHpPoints, + DiscreteDistributionTestData::getSfHpValues); } /** @@ -319,8 +308,9 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testInverseCumulativeProbability() { - return stream(DiscreteDistributionTestData::getIcdfPoints, - DiscreteDistributionTestData::getIcdfValues, "icdf"); + return stream(TestName.ICDF, + DiscreteDistributionTestData::getIcdfPoints, + DiscreteDistributionTestData::getIcdfValues); } /** @@ -330,8 +320,9 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testInverseSurvivalProbability() { - return stream(DiscreteDistributionTestData::getIsfPoints, - DiscreteDistributionTestData::getIsfValues, "isf"); + return stream(TestName.ISF, + DiscreteDistributionTestData::getIsfPoints, + DiscreteDistributionTestData::getIsfValues); } /** @@ -340,9 +331,8 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testCumulativeProbabilityInverseMapping() { - return stream(DiscreteDistributionTestData::isDisableCdfInverse, - DiscreteDistributionTestData::getCdfPoints, - "cdf test points"); + return stream(TestName.CDF_MAPPING, + DiscreteDistributionTestData::getCdfPoints); } /** @@ -351,9 +341,8 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testSurvivalProbabilityInverseMapping() { - return stream(DiscreteDistributionTestData::isDisableSfInverse, - DiscreteDistributionTestData::getSfPoints, - "sf test points"); + return stream(TestName.SF_MAPPING, + DiscreteDistributionTestData::getSfPoints); } /** @@ -363,9 +352,9 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testSurvivalAndCumulativeProbabilityComplement() { - // This is not disabled based on isDisableCdf && isDisableSf. + // This is not disabled based on cdf.disable && sf.disable. // Those flags are intended to ignore tests against reference values. - return streamCdfTestPoints(); + return streamCdfTestPoints(TestName.COMPLEMENT); } /** @@ -376,9 +365,9 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testConsistency() { - // This is not disabled based on isDisableCdf. - // That flags is intended to ignore tests against reference values. - return streamCdfTestPoints(); + // This is not disabled based on cdf.disable. + // That flag is intended to ignore tests against reference values. + return streamCdfTestPoints(TestName.CONSISTENCY); } /** @@ -387,7 +376,7 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testOutsideSupport() { - return data.stream().map(d -> Arguments.of(namedDistribution(d.getParameters()), createTestTolerance(d))); + return stream(TestName.OUTSIDE_SUPPORT); } /** @@ -396,10 +385,10 @@ abstract class BaseDiscreteDistributionTest * * @return the stream */ - Stream<Arguments> testSampling() { - return stream(DiscreteDistributionTestData::isDisableSample, + Stream<Arguments> testSamplingPMF() { + return stream(TestName.SAMPLING_PMF, DiscreteDistributionTestData::getPmfPoints, - DiscreteDistributionTestData::getPmfValues, "pmf sampling"); + DiscreteDistributionTestData::getPmfValues); } /** @@ -410,8 +399,8 @@ abstract class BaseDiscreteDistributionTest * * @return the stream */ - Stream<Arguments> testSamplingQuartiles() { - return streamDistributionWithFilter(DiscreteDistributionTestData::isDisableSample, "sampling quartiles"); + Stream<Arguments> testSampling() { + return stream(TestName.SAMPLING); } /** @@ -421,22 +410,21 @@ abstract class BaseDiscreteDistributionTest * of single points of the CDF. * Override this method to change the tolerance. * - * <p>This is disabled by {@link DiscreteDistributionTestData#isDisablePmf()}. If - * the distribution cannot compute the PMF to match reference values then it - * is assumed a sum of the PMF will fail to match reference CDF values. - * * @return the stream */ Stream<Arguments> testProbabilitySums() { // Assume the the test tolerance for single CDF values can be relaxed slightly // when summing values. final double scale = 10; + final TestName cdf = TestName.CDF; final Function<DiscreteDistributionTestData, DoubleTolerance> tolerance = - d -> createAbsOrRelTolerance(d.getAbsoluteTolerance() * scale, d.getRelativeTolerance() * scale); - return stream(d -> d.isDisablePmf() || d.isDisablePmfSum(), + d -> createAbsOrRelTolerance(d.getAbsoluteTolerance(cdf) * scale, + d.getRelativeTolerance(cdf) * scale); + final TestName name = TestName.PMF_SUM; + return stream(d -> d.isDisabled(name), DiscreteDistributionTestData::getCdfPoints, DiscreteDistributionTestData::getCdfValues, - tolerance, "pmf sums"); + tolerance, name.toString()); } /** @@ -446,7 +434,8 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testSupport() { - return data.stream().map(d -> Arguments.of(namedDistribution(d.getParameters()), d.getLower(), d.getUpper())); + return streamArguments(TestName.SUPPORT, + d -> Arguments.of(namedDistribution(d.getParameters()), d.getLower(), d.getUpper())); } /** @@ -456,7 +445,10 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testMoments() { - return data.stream().map(d -> Arguments.of(namedDistribution(d.getParameters()), d.getMean(), d.getVariance(), createTestTolerance(d))); + final TestName name = TestName.MOMENTS; + return streamArguments(name, + d -> Arguments.of(namedDistribution(d.getParameters()), d.getMean(), d.getVariance(), + createTestTolerance(d, name))); } /** @@ -465,7 +457,8 @@ abstract class BaseDiscreteDistributionTest * @return the stream */ Stream<Arguments> testMedian() { - return data.stream().map(d -> Arguments.of(namedDistribution(d.getParameters()))); + return streamArguments(TestName.MEDIAN, + d -> Arguments.of(namedDistribution(d.getParameters()))); } //------------------------ Tests ----------------------------- @@ -942,12 +935,14 @@ abstract class BaseDiscreteDistributionTest /** * Test sampling from the distribution. + * This test uses the points that are used to test the distribution PMF. + * The test is skipped if the sum of the PMF values is less than 0.5. */ @ParameterizedTest @MethodSource - final void testSampling(DiscreteDistribution dist, - int[] points, - double[] values) { + final void testSamplingPMF(DiscreteDistribution dist, + int[] points, + double[] values) { // This test uses the points that are used to test the distribution PMF. // The sum of the probability values does not have to be 1 (or very close to 1). // Any value generated by the sampler that is not an expected point will @@ -1002,12 +997,12 @@ abstract class BaseDiscreteDistributionTest * Test sampling from the distribution using quartiles. * This test is ignored if the range for the distribution PMF is small * and the quartiles do not map to approximately 0.25. When the range of - * the distribution is small then the {@link #testSampling(DiscreteDistribution, int[], double[])} + * the distribution is small then the {@link #testSamplingPMF(DiscreteDistribution, int[], double[])} * method should be used with points that covers at least 50% of the PMF. */ @ParameterizedTest @MethodSource - final void testSamplingQuartiles(DiscreteDistribution dist) { + final void testSampling(DiscreteDistribution dist) { final int[] quartiles = TestUtils.getDistributionQuartiles(dist); // The distribution quartiles are created using the inverse CDF. // This may not be accurate for extreme parameterizations of the distribution. diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BaseDistributionTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BaseDistributionTest.java index aa7da83..e669a3a 100644 --- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BaseDistributionTest.java +++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/BaseDistributionTest.java @@ -27,7 +27,6 @@ import java.util.Locale; import java.util.Properties; import java.util.function.Function; import java.util.function.Predicate; -import java.util.function.ToDoubleFunction; import java.util.stream.Stream; import java.util.stream.Stream.Builder; import org.junit.jupiter.api.Assertions; @@ -55,7 +54,7 @@ import org.junit.jupiter.params.provider.MethodSource; * <p>The class has two specializations for testing {@link ContinuousDistribution} and * {@link DiscreteDistribution}. It is not intended to extend this class when creating * a test for a new distribution. This class exists for the sole purpose of containing - * commons functionality to search for and load properties files containing the distribution + * common functionality to search for and load properties files containing the distribution * data. * * <p>To test a new distribution extend the specialized classes: @@ -105,8 +104,6 @@ abstract class BaseDistributionTest<T, D extends DistributionTestData> { final Properties defaults = new Properties(); defaults.setProperty(DistributionTestData.KEY_TOLERANCE_ABSOLUTE, String.valueOf(getAbsoluteTolerance())); defaults.setProperty(DistributionTestData.KEY_TOLERANCE_RELATIVE, String.valueOf(getRelativeTolerance())); - defaults.setProperty(DistributionTestData.KEY_TOLERANCE_ABSOLUTE_HP, String.valueOf(getHighPrecisionAbsoluteTolerance())); - defaults.setProperty(DistributionTestData.KEY_TOLERANCE_RELATIVE_HP, String.valueOf(getHighPrecisionRelativeTolerance())); for (int i = 1; ; i++) { final String filename = String.format("test.%s.%d.properties", key, i); try (InputStream resource = this.getClass().getResourceAsStream( @@ -161,42 +158,6 @@ abstract class BaseDistributionTest<T, D extends DistributionTestData> { return 1e-12; } - /** - * Gets the default absolute tolerance used in comparing expected and returned values in high precision tests. - * - * <p>The initial value is 0.0 (disabled). - * - * <p>Override this method to set the <strong>default</strong> high-precision absolute tolerance for all test - * cases defined by a properties file. Any properties file with a high-precision absolute tolerance entry - * ignores this value. - * - * <p>Notes: Floating-point values are considered equal using the absolute or the relative tolerance. - * See {@link #createHighPrecisionTolerance()}. - * - * @return the high precision absolute tolerance - */ - protected double getHighPrecisionAbsoluteTolerance() { - return 0.0; - } - - /** - * Gets the default relative tolerance used in comparing expected and returned values in high precision tests. - * - * <p>The initial value is 1e-12. - * - * <p>Override this method to set the <strong>default</strong> high-precision relative tolerance for all test - * cases defined by a properties file. Any properties file with a high-precision relative tolerance entry - * ignores this value. - * - * <p>Notes: Floating-point values are considered equal using the absolute or the relative tolerance. - * See {@link #createHighPrecisionTolerance()}. - * - * @return the high precision relative tolerance - */ - protected double getHighPrecisionRelativeTolerance() { - return 1e-12; - } - /** * Gets the distribution name. This is used to search for test case resource files. * @@ -296,27 +257,8 @@ abstract class BaseDistributionTest<T, D extends DistributionTestData> { } /** - * Creates the tolerance using an {@code Or} combination of absolute and relative error. - * - * <p>If the absolute tolerance is zero it is ignored and a tolerance of numerical equality - * is used. - * - * <p>If the relative tolerance is zero it is ignored. - * - * @param testData Test data - * @param absTolerance Function to create the absolute tolerance - * @param relTolerance Function to create the relative tolerance - * @return the tolerance - */ - DoubleTolerance createTestAbsOrRelTolerance( - D testData, ToDoubleFunction<D> absTolerance, ToDoubleFunction<D> relTolerance) { - final double abs = absTolerance == null ? 0 : absTolerance.applyAsDouble(testData); - final double rel = relTolerance == null ? 0 : relTolerance.applyAsDouble(testData); - return createAbsOrRelTolerance(abs, rel); - } - - /** - * Creates the default tolerance for the test data. + * Creates the tolerance using an {@code Or} combination of absolute and relative error + * defined in the test data. * * <p>If the absolute tolerance is zero it is ignored and a tolerance of numerical equality * is used. @@ -327,13 +269,15 @@ abstract class BaseDistributionTest<T, D extends DistributionTestData> { * @return the tolerance */ DoubleTolerance createTestTolerance(D testData) { - return createTestAbsOrRelTolerance(testData, - DistributionTestData::getAbsoluteTolerance, - DistributionTestData::getRelativeTolerance); + final double abs = testData.getAbsoluteTolerance(); + final double rel = testData.getRelativeTolerance(); + return createAbsOrRelTolerance(abs, rel); } /** - * Creates the default high-precision tolerance for the test data. + * Creates the tolerance for the named test using an {@code Or} combination of absolute + * and relative error defined in the test data. If the named test tolerance is not defined + * then this uses the default tolerance. * * <p>If the absolute tolerance is zero it is ignored and a tolerance of numerical equality * is used. @@ -341,12 +285,13 @@ abstract class BaseDistributionTest<T, D extends DistributionTestData> { * <p>If the relative tolerance is zero it is ignored. * * @param testData Test data + * @param name Name of the function under test * @return the tolerance */ - DoubleTolerance createTestHighPrecisionTolerance(D testData) { - return createTestAbsOrRelTolerance(testData, - DistributionTestData::getHighPrecisionAbsoluteTolerance, - DistributionTestData::getHighPrecisionRelativeTolerance); + DoubleTolerance createTestTolerance(D testData, TestName name) { + final double abs = testData.getAbsoluteTolerance(name); + final double rel = testData.getRelativeTolerance(name); + return createAbsOrRelTolerance(abs, rel); } /** @@ -364,21 +309,6 @@ abstract class BaseDistributionTest<T, D extends DistributionTestData> { getRelativeTolerance()); } - /** - * Creates the default high-precision tolerance. - * - * <p>If the absolute tolerance is zero it is ignored and a tolerance of numerical equality - * is used. - * - * <p>If the relative tolerance is zero it is ignored. - * - * @return the tolerance - */ - DoubleTolerance createHighPrecisionTolerance() { - return createAbsOrRelTolerance(getHighPrecisionAbsoluteTolerance(), - getHighPrecisionRelativeTolerance()); - } - //------------------------ Methods to stream the test data ----------------------------- // The @MethodSource annotation will default to a no arguments method of the same name @@ -475,17 +405,6 @@ abstract class BaseDistributionTest<T, D extends DistributionTestData> { return Named.of(sb.toString(), array); } - /** - * Create a predicate that returns false. This can be used to signal do not ignore - * for test data. - * - * @param <D> Type of object - * @return the predicate - */ - private static <D> Predicate<D> doNotIgnore() { - return d -> false; - } - /** * Create a stream of arguments containing the distribution to test. * @@ -496,81 +415,23 @@ abstract class BaseDistributionTest<T, D extends DistributionTestData> { } /** - * Create a stream of arguments containing the distribution to test. + * Create a stream of arguments containing the distribution to test and the test tolerance. + * The tolerance is identified using functions on the test instance data. + * The test data will be skipped if disabled. * - * @param filter Filter applied on the test data. If true the data is ignored. - * @param name Name of the function under test - * @return the stream - */ - Stream<Arguments> streamDistributionWithFilter(Predicate<D> filter, - String name) { - final Builder<Arguments> b = Stream.builder(); - final int[] size = {0}; - data.forEach(d -> { - if (filter.test(d)) { - return; - } - size[0]++; - b.accept(Arguments.of(namedDistribution(d.getParameters()))); - }); - Assumptions.assumeTrue(size[0] != 0, () -> "Distribution has no data for " + name); - return b.build(); - } - - /** - * Create a stream of arguments containing the distribution to test, the test - * points, test values and the test tolerance. The points, values and tolerance - * are identified using functions on the test instance data. - * - * <p>If the length of the points or values is zero then a - * {@link org.opentest4j.TestAbortedException TestAbortedException} is raised. - * - * @param points Function to create the points - * @param values Function to create the values - * @param tolerance Function to create the tolerance - * @param name Name of the function under test - * @return the stream - */ - <P, V> Stream<Arguments> stream(Function<D, P> points, - Function<D, V> values, - ToDoubleFunction<D> tolerance, - String name) { - return stream(doNotIgnore(), points, values, tolerance, name); - } - - /** - * Create a stream of arguments containing the distribution to test, the test - * points, test values and the test tolerance. The points, values and tolerance - * are identified using functions on the test instance data. - * - * <p>If the length of the points or values is zero then a - * {@link org.opentest4j.TestAbortedException TestAbortedException} is raised. - * - * @param filter Filter applied on the test data. If true the data is ignored. - * @param points Function to create the points - * @param values Function to create the values - * @param tolerance Function to create the tolerance * @param name Name of the function under test * @return the stream */ - <P, V> Stream<Arguments> stream(Predicate<D> filter, - Function<D, P> points, - Function<D, V> values, - ToDoubleFunction<D> tolerance, - String name) { + Stream<Arguments> stream(TestName name) { final Builder<Arguments> b = Stream.builder(); final int[] size = {0}; data.forEach(d -> { - final P p = points.apply(d); - final V v = values.apply(d); - if (filter.test(d) || TestUtils.getLength(p) == 0 || TestUtils.getLength(v) == 0) { + if (d.isDisabled(name)) { return; } size[0]++; b.accept(Arguments.of(namedDistribution(d.getParameters()), - namedArray("points", p), - namedArray("values", v), - tolerance.applyAsDouble(d))); + createTestTolerance(d, name))); }); Assumptions.assumeTrue(size[0] != 0, () -> "Distribution has no data for " + name); return b.build(); @@ -580,50 +441,28 @@ abstract class BaseDistributionTest<T, D extends DistributionTestData> { * Create a stream of arguments containing the distribution to test, the test * points, and the test tolerance. The points and tolerance * are identified using functions on the test instance data. + * The test data will be skipped if disabled or the length of the points is zero. * - * <p>If the length of the points is zero then a + * <p>If all test data is skipped then a * {@link org.opentest4j.TestAbortedException TestAbortedException} is raised. * - * @param points Function to create the points - * @param tolerance Function to create the tolerance * @param name Name of the function under test - * @return the stream - */ - <P, V> Stream<Arguments> streamPoints(Function<D, P> points, - Function<D, DoubleTolerance> tolerance, - String name) { - return streamPoints(doNotIgnore(), points, tolerance, name); - } - - /** - * Create a stream of arguments containing the distribution to test, the test - * points, and the test tolerance. The points and tolerance - * are identified using functions on the test instance data. - * - * <p>If the length of the points is zero then a - * {@link org.opentest4j.TestAbortedException TestAbortedException} is raised. - * - * @param filter Filter applied on the test data. If true the data is ignored. * @param points Function to create the points - * @param tolerance Function to create the tolerance - * @param name Name of the function under test * @return the stream */ - <P, V> Stream<Arguments> streamPoints(Predicate<D> filter, - Function<D, P> points, - Function<D, DoubleTolerance> tolerance, - String name) { + <P> Stream<Arguments> stream(TestName name, + Function<D, P> points) { final Builder<Arguments> b = Stream.builder(); final int[] size = {0}; data.forEach(d -> { final P p = points.apply(d); - if (filter.test(d) || TestUtils.getLength(p) == 0) { + if (d.isDisabled(name) || TestUtils.getLength(p) == 0) { return; } size[0]++; b.accept(Arguments.of(namedDistribution(d.getParameters()), namedArray("points", p), - tolerance.apply(d))); + createTestTolerance(d, name))); }); Assumptions.assumeTrue(size[0] != 0, () -> "Distribution has no data for " + name); return b.build(); @@ -633,29 +472,34 @@ abstract class BaseDistributionTest<T, D extends DistributionTestData> { * Create a stream of arguments containing the distribution to test, the test * points, test values and the test tolerance. The points, values and tolerance * are identified using functions on the test instance data. + * The test data will be skipped if disabled or the length of the points or values is zero. * - * <p>If the length of the points or values is zero then a + * <p>If all test data is skipped then a * {@link org.opentest4j.TestAbortedException TestAbortedException} is raised. * + * @param name Name of the function under test * @param points Function to create the points * @param values Function to create the values - * @param tolerance Function to create the tolerance - * @param name Name of the function under test * @return the stream */ - <P, V> Stream<Arguments> stream(Function<D, P> points, - Function<D, V> values, - Function<D, DoubleTolerance> tolerance, - String name) { - return stream(doNotIgnore(), points, values, tolerance, name); + <P, V> Stream<Arguments> stream(TestName name, + Function<D, P> points, + Function<D, V> values) { + // Delegate + return stream(d -> d.isDisabled(name), + points, + values, + d -> createTestTolerance(d, name), + name.toString()); } /** * Create a stream of arguments containing the distribution to test, the test * points, test values and the test tolerance. The points, values and tolerance * are identified using functions on the test instance data. + * The test data will be skipped if disabled or the length of the points or values is zero. * - * <p>If the length of the points or values is zero then a + * <p>If all test data is skipped then a * {@link org.opentest4j.TestAbortedException TestAbortedException} is raised. * * @param filter Filter applied on the test data. If true the data is ignored. @@ -689,101 +533,26 @@ abstract class BaseDistributionTest<T, D extends DistributionTestData> { } /** - * Create a stream of arguments containing the distribution to test, the test - * points, and test values. The points and values - * are identified using functions on the test instance data. - * - * <p>If the length of the points or values is zero then a - * {@link org.opentest4j.TestAbortedException TestAbortedException} is raised. - * - * @param points Function to create the points - * @param values Function to create the values - * @param name Name of the function under test - * @return the stream - */ - <P, V> Stream<Arguments> stream(Function<D, P> points, - Function<D, V> values, - String name) { - return stream(doNotIgnore(), points, values, name); - } - - /** - * Create a stream of arguments containing the distribution to test, the test - * points, and test values. The points and values - * are identified using functions on the test instance data. - * - * <p>If the length of the points or values is zero then a - * {@link org.opentest4j.TestAbortedException TestAbortedException} is raised. - * - * @param filter Filter applied on the test data. If true the data is ignored. - * @param points Function to create the points - * @param values Function to create the values - * @param name Name of the function under test - * @return the stream - */ - <P, V> Stream<Arguments> stream(Predicate<D> filter, - Function<D, P> points, - Function<D, V> values, - String name) { - final Builder<Arguments> b = Stream.builder(); - final int[] size = {0}; - data.forEach(d -> { - final P p = points.apply(d); - final V v = values.apply(d); - if (filter.test(d) || TestUtils.getLength(p) == 0 || TestUtils.getLength(v) == 0) { - return; - } - size[0]++; - b.accept(Arguments.of(namedDistribution(d.getParameters()), - namedArray("points", p), - namedArray("values", v))); - }); - Assumptions.assumeTrue(size[0] != 0, () -> "Distribution has no data for " + name); - return b.build(); - } - - - /** - * Create a stream of arguments containing the distribution to test and the test - * points. The points are identified using functions on the test instance data. - * - * <p>If the length of the points or values is zero then a - * {@link org.opentest4j.TestAbortedException TestAbortedException} is raised. - * - * @param points Function to create the points - * @param name Name of the function under test - * @return the stream - */ - <P> Stream<Arguments> stream(Function<D, P> points, - String name) { - return stream(doNotIgnore(), points, name); - } - - /** - * Create a stream of arguments containing the distribution to test and the test - * points. The points are identified using functions on the test instance data. + * Create a stream of arguments built using the provided mapping function. + * The test data will be skipped if disabled. * - * <p>If the length of the points or values is zero then a + * <p>If all test data is skipped then a * {@link org.opentest4j.TestAbortedException TestAbortedException} is raised. * - * @param filter Filter applied on the test data. If true the data is ignored. - * @param points Function to create the points * @param name Name of the function under test + * @param mappingFunction Function to create the arguments for the test data * @return the stream */ - <P> Stream<Arguments> stream(Predicate<D> filter, - Function<D, P> points, - String name) { + Stream<Arguments> streamArguments(TestName name, + Function<D, Arguments> mappingFunction) { final Builder<Arguments> b = Stream.builder(); final int[] size = {0}; data.forEach(d -> { - final P p = points.apply(d); - if (filter.test(d) || TestUtils.getLength(p) == 0) { + if (d.isDisabled(name)) { return; } size[0]++; - b.accept(Arguments.of(namedDistribution(d.getParameters()), - namedArray("points", p))); + b.accept(mappingFunction.apply(d)); }); Assumptions.assumeTrue(size[0] != 0, () -> "Distribution has no data for " + name); return b.build(); diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/DistributionTestData.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/DistributionTestData.java index 747192b..c05ae93 100644 --- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/DistributionTestData.java +++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/DistributionTestData.java @@ -17,8 +17,13 @@ package org.apache.commons.statistics.distribution; import java.util.Arrays; +import java.util.Collections; +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.Map; import java.util.Objects; import java.util.Properties; +import java.util.Set; import java.util.regex.Pattern; /** @@ -35,10 +40,21 @@ abstract class DistributionTestData { static final String KEY_TOLERANCE_ABSOLUTE = "tolerance.absolute"; /** The key for the relative tolerance value. */ static final String KEY_TOLERANCE_RELATIVE = "tolerance.relative"; - /** The key for the high-precision absolute tolerance value. */ - static final String KEY_TOLERANCE_ABSOLUTE_HP = "tolerance.absolute.hp"; - /** The key for the high-precision relative tolerance value. */ - static final String KEY_TOLERANCE_RELATIVE_HP = "tolerance.relative.hp"; + + /** The key suffix to disable a test. */ + private static final String SUFFIX_DISABLE = ".disable"; + /** The key suffix for the absolute tolerance value. */ + private static final String SUFFIX_TOLERANCE_ABSOLUTE = ".absolute"; + /** The key suffix for the relative tolerance value. */ + private static final String SUFFIX_TOLERANCE_RELATIVE = ".relative"; + /** The index for the absolute tolerance value in the array of tolerances. */ + private static final int INDEX_ABSOLUTE = 0; + /** The index for the relative tolerance value in the array of tolerances. */ + private static final int INDEX_RELATIVE = 1; + /** The unset (default) value for the tolerance. */ + private static final double UNSET_TOLERANCE = -1; + /** The unset (default) values for the array of tolerances. */ + private static final double[] UNSET_TOLERANCES = {UNSET_TOLERANCE, UNSET_TOLERANCE}; /** Regex to split delimited text data (e.g. arrays of numbers). */ private static final Pattern PATTERN = Pattern.compile("[ ,]+"); @@ -47,10 +63,6 @@ abstract class DistributionTestData { protected final double[] pfValues; /** Expected log probability function values. */ protected final double[] logPfValues; - /** Disable tests of the probability function method. */ - protected final boolean disablePf; - /** Disable tests of the log probability function method. */ - protected final boolean disableLogPf; /** Distribution parameters. */ private final Object[] parameters; @@ -58,14 +70,15 @@ abstract class DistributionTestData { private final double mean; /** Variance. */ private final double variance; + /** Test tolerances. */ + private final Map<TestName, double[]> tolerance; + /** Disabled tests. */ + private final Set<TestName> disabled; + /** Test absolute tolerance for calculations. */ private final double absoluteTolerance; /** Test relative tolerance for calculations. */ private final double relativeTolerance; - /** Test absolute tolerance for high-precision calculations.. */ - private final double absoluteToleranceHp; - /** Test relative tolerance for high-precision calculations.. */ - private final double relativeToleranceHp; /** Expected CDF values. */ private final double[] cdfValues; /** Expected SF values for the survival function test points. */ @@ -75,19 +88,6 @@ abstract class DistributionTestData { /** Expected CDF values for the high-precision survival function test points. */ private final double[] sfHpValues; - // Flags to ignore required tests - - /** Disable a {@code x = icdf(cdf(x))} mapping test. */ - private final boolean disableCdfInverse; - /** Disable a {@code x = isf(sf(x))} mapping test. */ - private final boolean disableSfInverse; - /** Disable tests of the sample method. */ - private final boolean disableSample; - /** Disable tests of the cumulative probability function method. */ - private final boolean disableCdf; - /** Disable tests of the survival probability function method. */ - private final boolean disableSf; - /** * Contains the data for the continuous distribution parameters, the expected properties * of the distribution (moments and support bounds) and test points to evaluate @@ -264,26 +264,6 @@ abstract class DistributionTestData { double[] getIsfValues() { return isfValues; } - - /** - * Checks if a test of the PDF method is disabled. - * - * @return true if a PDF test is disabled. - * @see #getPdfValues() - */ - boolean isDisablePdf() { - return disablePf; - } - - /** - * Checks if a test of the log PDF method is disabled. - * - * @return true if a log PDF test is disabled. - * @see #getLogPdfValues() - */ - boolean isDisableLogPdf() { - return disableLogPf; - } } /** @@ -314,8 +294,6 @@ abstract class DistributionTestData { private final double[] isfPoints; /** Expected inverse SF values. */ private final int[] isfValues; - /** Disable tests of the summation of the PMF verses the CDF. */ - private final boolean disablePmfSum; /** * @param props Properties containing the test data @@ -338,7 +316,6 @@ abstract class DistributionTestData { icdfValues = getAsIntArray(props, "icdf.values", null); isfPoints = getAsDoubleArray(props, "isf.points", null); isfValues = getAsIntArray(props, "isf.values", null); - disablePmfSum = getAsBoolean(props, "disable.pmf.sum", false); // Validation validatePair(cdfPoints, getCdfValues(), "cdf"); validatePair(pmfPoints, getPmfValues(), "pmf"); @@ -465,36 +442,6 @@ abstract class DistributionTestData { int[] getIsfValues() { return isfValues; } - - /** - * Checks if a test of the PMF method is disabled. - * - * @return true if a PMF test is disabled. - * @see #getPmfValues() - */ - boolean isDisablePmf() { - return disablePf; - } - - /** - * Checks if a test of the log PMF method is disabled. - * - * @return true if a log PMF test is disabled. - * @see #getLogPmfValues() - */ - boolean isDisableLogPmf() { - return disableLogPf; - } - - /** - * Checks if a test of the sum of the PMF verses the PDF is disabled. - * - * @return true the PMF sum test is disabled. - * @see #getSfValues() - */ - boolean isDisablePmfSum() { - return disablePmfSum; - } } /** @@ -507,9 +454,7 @@ abstract class DistributionTestData { mean = getAsDouble(props, "mean"); variance = getAsDouble(props, "variance"); absoluteTolerance = getAsDouble(props, KEY_TOLERANCE_ABSOLUTE); - absoluteToleranceHp = getAsDouble(props, KEY_TOLERANCE_ABSOLUTE_HP); relativeTolerance = getAsDouble(props, KEY_TOLERANCE_RELATIVE); - relativeToleranceHp = getAsDouble(props, KEY_TOLERANCE_RELATIVE_HP); // Required cdfValues = getAsDoubleArray(props, "cdf.values"); final String pf = getProbabilityFunctionName(); @@ -527,13 +472,37 @@ abstract class DistributionTestData { sfValues = tmp; cdfHpValues = getAsDoubleArray(props, "cdf.hp.values", null); sfHpValues = getAsDoubleArray(props, "sf.hp.values", null); - disableCdfInverse = getAsBoolean(props, "disable.cdf.inverse", false); - disableSfInverse = getAsBoolean(props, "disable.sf.inverse", false); - disableSample = getAsBoolean(props, "disable.sample", false); - disablePf = getAsBoolean(props, "disable." + pf, false); - disableLogPf = getAsBoolean(props, "disable." + pf, false); - disableCdf = getAsBoolean(props, "disable.cdf", false); - disableSf = getAsBoolean(props, "disable.sf", false); + + // Remove keys to prevent detection in when searching for test tolerances + props.remove(KEY_TOLERANCE_ABSOLUTE); + props.remove(KEY_TOLERANCE_RELATIVE); + + // Store custom tolerances and disabled tests + EnumMap<TestName, double[]> map = new EnumMap<>(TestName.class); + EnumSet<TestName> set = EnumSet.noneOf(TestName.class); + props.stringPropertyNames().forEach(key -> { + if (key.endsWith(SUFFIX_DISABLE) && getAsBoolean(props, key, false)) { + final TestName name = TestName.fromString(key.substring(0, key.length() - SUFFIX_DISABLE.length())); + if (name != null) { + set.add(name); + } + } else if (key.endsWith(SUFFIX_TOLERANCE_ABSOLUTE)) { + final TestName name = TestName.fromString(key.substring(0, key.length() - SUFFIX_TOLERANCE_ABSOLUTE.length())); + if (name != null) { + final double[] tolerances = map.computeIfAbsent(name, k -> UNSET_TOLERANCES.clone()); + tolerances[INDEX_ABSOLUTE] = getAsDouble(props, key); + } + } else if (key.endsWith(SUFFIX_TOLERANCE_RELATIVE)) { + final TestName name = TestName.fromString(key.substring(0, key.length() - SUFFIX_TOLERANCE_RELATIVE.length())); + if (name != null) { + final double[] tolerances = map.computeIfAbsent(name, k -> UNSET_TOLERANCES.clone()); + tolerances[INDEX_RELATIVE] = getAsDouble(props, key); + } + } + }); + + this.tolerance = map.isEmpty() ? Collections.emptyMap() : map; + this.disabled = set.isEmpty() ? Collections.emptySet() : set; } /** @@ -681,22 +650,6 @@ abstract class DistributionTestData { } } - /** - * Gets the property as a boolean, or a default value if the property is missing. - * - * @param props Properties - * @param key Key - * @return the value - * @throws IllegalArgumentException if the parameter is not a boolean. - */ - private static boolean getAsBoolean(Properties props, String key) { - try { - return Boolean.parseBoolean(props.getProperty(key)); - } catch (NumberFormatException ex) { - throw new IllegalArgumentException("Invalid boolean: " + key, ex); - } - } - /** * Gets the property as a boolean, or a default value if the property is missing. * @@ -863,6 +816,45 @@ abstract class DistributionTestData { /** * Gets the absolute tolerance used when comparing expected and actual results. + * If no tolerance exists for the named test then the default is returned. + * + * @param name Name of the test. + * @return the absolute tolerance + */ + double getAbsoluteTolerance(TestName name) { + return getTolerance(name, INDEX_ABSOLUTE, absoluteTolerance); + } + + /** + * Gets the relative tolerance used when comparing expected and actual results. + * If no tolerance exists for the named test then the default is returned. + * + * @param name Name of the test. + * @return the relative tolerance + */ + double getRelativeTolerance(TestName name) { + return getTolerance(name, INDEX_RELATIVE, relativeTolerance); + } + + /** + * Gets the specified tolerance for the named test. + * If no tolerance exists for the named test then the default is returned. + * + * @param name Name of the test. + * @param index Index of the tolerance. + * @param defaultValue Default value is the tolerance is unset. + * @return the relative tolerance + */ + private double getTolerance(TestName name, int index, double defaultValue) { + final double[] tol = tolerance.get(name); + if (tol != null && tol[index] != UNSET_TOLERANCE) { + return tol[index]; + } + return defaultValue; + } + + /** + * Gets the default absolute tolerance used when comparing expected and actual results. * * @return the absolute tolerance */ @@ -871,7 +863,7 @@ abstract class DistributionTestData { } /** - * Gets the relative tolerance used when comparing expected and actual results. + * Gets the default relative tolerance used when comparing expected and actual results. * * @return the relative tolerance */ @@ -880,23 +872,23 @@ abstract class DistributionTestData { } /** - * Gets the absolute tolerance used when comparing expected and actual results - * of high-precision computations. + * Checks if the named test is disabled. * - * @return the high-precision absolute tolerance + * @param name Name of the test. + * @return true if test is disabled. */ - double getHighPrecisionAbsoluteTolerance() { - return absoluteToleranceHp; + boolean isDisabled(TestName name) { + return disabled.contains(name); } /** - * Gets the relative tolerance used when comparing expected and actual results - * of high-precision computations. + * Checks if the named test is enabled. * - * @return the high-precision relative tolerance + * @param name Name of the test. + * @return true if test is enabled. */ - double getHighPrecisionRelativeTolerance() { - return relativeToleranceHp; + boolean isEnabled(TestName name) { + return !isDisabled(name); } /** @@ -948,62 +940,5 @@ abstract class DistributionTestData { * @return the inverse SF points */ abstract double[] getIsfPoints(); - - /** - * Checks if a {@code x = icdf(cdf(x))} mapping test is disabled. - * - * <p>Note that this property disables a round-trip test of the points used to test - * the cumulative probability. The inverse cumulative probability can also be tested - * separately using the {@link #getIcdfPoints()} allowing the forward and reverse - * functions to target different data. - * - * @return true if a CDF inverse mapping test is disabled. - */ - boolean isDisableCdfInverse() { - return disableCdfInverse; - } - - /** - * Checks if a {@code x = isf(sf(x))} mapping test is disabled. - * - * <p>Note that this property disables a round-trip test of the points used to test - * the survival probability. The inverse survival probability can also be tested - * separately using the {@link #getIsfPoints()} allowing the forward and reverse - * functions to target different data. - * - * @return true if a SF inverse mapping test is disabled. - */ - boolean isDisableSfInverse() { - return disableSfInverse; - } - - /** - * Checks if a test of the sample method is disabled. - * - * @return true if a sample test is disabled. - */ - boolean isDisableSample() { - return disableSample; - } - - /** - * Checks if a test of the CDF method is disabled. - * - * @return true if a CDF test is disabled. - * @see #getCdfValues() - */ - boolean isDisableCdf() { - return disableCdf; - } - - /** - * Checks if a test of the survival function method is disabled. - * - * @return true if a survival function test is disabled. - * @see #getSfValues() - */ - boolean isDisableSf() { - return disableSf; - } } diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/HypergeometricDistributionTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/HypergeometricDistributionTest.java index b5c72c7..64c4ea8 100644 --- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/HypergeometricDistributionTest.java +++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/HypergeometricDistributionTest.java @@ -227,7 +227,7 @@ class HypergeometricDistributionTest extends BaseDiscreteDistributionTest { HypergeometricDistribution.of(500, 70, 300), new int[] {10, 8}, new double[] {2.4055720603264525e-17, 1.2848174992266236e-19}, - createHighPrecisionTolerance()); + DoubleTolerances.relative(5e-14)); } @Test @@ -237,6 +237,6 @@ class HypergeometricDistributionTest extends BaseDiscreteDistributionTest { HypergeometricDistribution.of(500, 70, 300), new int[] {68, 69}, new double[] {4.570379934029859e-16, 7.4187180434325268e-18}, - createHighPrecisionTolerance()); + DoubleTolerances.relative(5e-14)); } } diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/NormalDistributionTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/NormalDistributionTest.java index bbfba7f..da769f4 100644 --- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/NormalDistributionTest.java +++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/NormalDistributionTest.java @@ -59,16 +59,6 @@ class NormalDistributionTest extends BaseContinuousDistributionTest { return 20 * RELATIVE_EPS; } - @Override - protected double getHighPrecisionRelativeTolerance() { - // Tests are limited by the survival probability. - // Tolerance is 1.6653345369377348E-14. - // This is the lowest achieved with various implementations of the - // survival function against high precision reference data. - // It requires computing the factor sqrt(2 * sd * sd) exactly. - return 75 * RELATIVE_EPS; - } - //-------------------- Additional test cases ------------------------------- @Test diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/ParetoDistributionTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/ParetoDistributionTest.java index f719f40..0988410 100644 --- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/ParetoDistributionTest.java +++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/ParetoDistributionTest.java @@ -84,7 +84,7 @@ class ParetoDistributionTest extends BaseContinuousDistributionTest { dist, new double[] {2.100000000000001, 2.100000000000005}, new double[] {6.217248937900875e-16, 3.2640556923979585e-15}, - createHighPrecisionTolerance()); + DoubleTolerances.relative(5e-14)); } @Test @@ -94,7 +94,7 @@ class ParetoDistributionTest extends BaseContinuousDistributionTest { dist, new double[] {42e11, 64e11}, new double[] {6.005622169907148e-18, 3.330082930386111e-18}, - createHighPrecisionTolerance()); + DoubleTolerances.relative(5e-14)); } @Test diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/PoissonDistributionTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/PoissonDistributionTest.java index 095de50..ed548b0 100644 --- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/PoissonDistributionTest.java +++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/PoissonDistributionTest.java @@ -130,7 +130,7 @@ class PoissonDistributionTest extends BaseDiscreteDistributionTest { PoissonDistribution.of(100), new int[] {28, 25}, new double[] {1.6858675763053070496e-17, 3.184075559619425735e-19}, - createHighPrecisionTolerance()); + DoubleTolerances.relative(5e-14)); } /** diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/TestName.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/TestName.java new file mode 100644 index 0000000..7d71a8f --- /dev/null +++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/TestName.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.statistics.distribution; + +import java.util.Locale; + +/** + * Contains the names for the standard tests. + * These names are used as keys in the test resource properties files. + */ +enum TestName { + PDF, + LOGPDF, + PMF, + LOGPMF, + CDF, + SF, + CDF_HP, + SF_HP, + ICDF, + ISF, + CDF_MAPPING, + SF_MAPPING, + COMPLEMENT, + CONSISTENCY, + OUTSIDE_SUPPORT, + SAMPLING, + SAMPLING_PMF, + INTEGRALS, + SUPPORT, + MOMENTS, + MEDIAN, + PMF_SUM; + + /** Cache the values for use in string conversion. */ + private static final TestName[] VALUES = values(); + + /** The test name as a String. */ + private final String name; + + /** + * Create an instance. + */ + TestName() { + name = this.name().toLowerCase(Locale.ROOT).replace('_', '.'); + } + + @Override + public String toString() { + return name; + } + + /** + * Get the instance from the the String representation. + * + * @param key String representation. + * @return the instance (or null) + */ + static TestName fromString(String key) { + for (final TestName v : VALUES) { + if (v.name.equals(key)) { + return v; + } + } + return null; + } +} + diff --git a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.binomial.2.properties b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.binomial.2.properties index 92bac80..af855fb 100644 --- a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.binomial.2.properties +++ b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.binomial.2.properties @@ -30,3 +30,4 @@ pmf.values = 1.000000000000088817841970016428095E-200 # computed using R version 3.4.4 cdf.hp.points = 82, 81 cdf.hp.values = 1.4061271955993513664e-17, 6.1128083336354843707e-19 +cdf.hp.relative = 1e-14 diff --git a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.binomial.3.properties b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.binomial.3.properties index 09cb32c..663d065 100644 --- a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.binomial.3.properties +++ b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.binomial.3.properties @@ -28,3 +28,4 @@ pmf.values = 1.000000000000002081668171172170658E-200 # computed using R version 3.4.4 sf.hp.points = 18, 19 sf.hp.values = 6.1128083336353977038e-19, 2.4944165604029235392e-20 +sf.hp.relative = 1e-14 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 0410f7e..2f7d37c 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 @@ -47,6 +47,7 @@ logpdf.values = \ # Computed using WolframAlpha cdf.hp.points = 1.205, 1.2049 cdf.hp.values = 3.7440973842063723e-19, 1.6388396909072308e-19 +cdf.hp.relative = 5e-14 sf.hp.points = 1e39, 42e37 sf.hp.values = 1.5957691216057308e-20, 2.4623252122982907e-20 # As cdf.values above but with the redundant 0 removed diff --git a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.normal.1.properties b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.normal.1.properties index 39424da..a16a2c9 100644 --- a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.normal.1.properties +++ b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.normal.1.properties @@ -64,6 +64,7 @@ sf.values = \ # scipy: 2.7412226346110703e-18 4.1045652533918685e-19 cdf.hp.points = -10, -10.3 cdf.hp.values = 2.74122263461107252124815886312e-18, 4.10456525339188007632261800065e-19 +cdf.hp.relative = 1e-14 # E.g. # x = sym(14.5) @@ -76,3 +77,4 @@ cdf.hp.values = 2.74122263461107252124815886312e-18, 4.1045652533918800763226180 # scipy: 4.1045652533918685e-19 1.7495528006975224e-17 sf.hp.points = 14.5, 13.9 sf.hp.values = 4.10456525339190342717686865166e-19, 1.74955280069751640746342569694e-17 +sf.hp.relative = 1e-14 diff --git a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.10.properties b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.10.properties index 7882d53..333c239 100644 --- a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.10.properties +++ b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.10.properties @@ -27,4 +27,4 @@ logpdf.values = -744.4400719213812 -744.5353821011855 -744.6223934781751 -Inf # The sampling test is not applicable as there are no quartiles. # As shape -> infinity then sampling will return the scale parameter. -disable.sample = true +sampling.disable = true diff --git a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.11.properties b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.11.properties index f22b078..c1b51e0 100644 --- a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.11.properties +++ b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.11.properties @@ -27,4 +27,4 @@ logpdf.values = -742.1374868283872 -742.8306340089471 -743.2360991170552 -Inf # The sampling test is not applicable as there are no quartiles. # As shape -> infinity then sampling will return the scale parameter. -disable.sample = true +sampling.disable = true diff --git a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.5.properties b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.5.properties index f23e9b1..39fa152 100644 --- a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.5.properties +++ b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.5.properties @@ -24,4 +24,4 @@ pdf.values = Inf 0 0 # The sampling test is not applicable as there are no quartiles. # As shape -> infinity then sampling will return the scale parameter. -disable.sample = true +sampling.disable = true diff --git a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.6.properties b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.6.properties index 9f89f68..241e2ae 100644 --- a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.6.properties +++ b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.6.properties @@ -24,4 +24,4 @@ pdf.values = Inf 0 0 0 # The sampling test is not applicable as there are no quartiles. # As shape -> infinity then sampling will return the scale parameter. -disable.sample = true +sampling.disable = true diff --git a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.7.properties b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.7.properties index 24871e6..a0f0d7a 100644 --- a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.7.properties +++ b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.7.properties @@ -24,4 +24,4 @@ pdf.values = Inf 0 0 # The sampling test is not applicable as there are no quartiles. # As shape -> infinity then sampling will return the scale parameter. -disable.sample = true +sampling.disable = true diff --git a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.9.properties b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.9.properties index eb18228..d7bc7ca 100644 --- a/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.9.properties +++ b/commons-statistics-distribution/src/test/resources/org/apache/commons/statistics/distribution/test.pareto.9.properties @@ -27,4 +27,4 @@ logpdf.values = -746.7426570143753 -746.7526073452284 -746.7624596416714 -Inf # The sampling test is not applicable as there are no quartiles. # As 1 / shape -> infinity then sampling will return infinity. -disable.sample = true +sampling.disable = true