From 345643883e519af3088501916b3b22242693eef6 Mon Sep 17 00:00:00 2001 From: stepan <stepan.sindelar@oracle.com> Date: Mon, 2 Jan 2017 16:25:21 +0100 Subject: [PATCH] Stats: port weibull distribution --- .../truffle/r/library/stats/RWeibull.java | 27 -- .../truffle/r/library/stats/Weibull.java | 103 ++++++ .../foreign/CallAndExternalFunctions.java | 11 +- .../truffle/r/test/ExpectedTestOutput.test | 329 ++++++++++++++++++ .../test/library/stats/TestDistributions.java | 7 +- mx.fastr/copyrights/overrides | 2 +- testScript.R | 2 - 7 files changed, 449 insertions(+), 32 deletions(-) delete mode 100644 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RWeibull.java create mode 100644 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Weibull.java delete mode 100644 testScript.R diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RWeibull.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RWeibull.java deleted file mode 100644 index 78d9e38318..0000000000 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RWeibull.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This material is distributed under the GNU General Public License - * Version 2. You may review the terms of this license at - * http://www.gnu.org/licenses/gpl-2.0.html - * - * Copyright (C) 1998 Ross Ihaka - * Copyright (c) 1998--2008, The R Core Team - * Copyright (c) 2016, 2016, Oracle and/or its affiliates - * - * All rights reserved. - */ -package com.oracle.truffle.r.library.stats; - -import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandFunction2_Double; -import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandomNumberProvider; - -public final class RWeibull extends RandFunction2_Double { - @Override - public double execute(double shape, double scale, RandomNumberProvider rand) { - if (!Double.isFinite(shape) || !Double.isFinite(scale) || shape <= 0. || scale <= 0.) { - return scale == 0. ? 0. : RMathError.defaultError(); - } - - return scale * Math.pow(-Math.log(rand.unifRand()), 1.0 / shape); - - } -} diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Weibull.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Weibull.java new file mode 100644 index 0000000000..2f40d28f57 --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Weibull.java @@ -0,0 +1,103 @@ +/* + * This material is distributed under the GNU General Public License + * Version 2. You may review the terms of this license at + * http://www.gnu.org/licenses/gpl-2.0.html + * + * Copyright (C) 1998 Ross Ihaka + * Copyright (c) 1998--2008, The R Core Team + * Copyright (c) 2016, 2017, Oracle and/or its affiliates + * + * All rights reserved. + */ +package com.oracle.truffle.r.library.stats; + +import com.oracle.truffle.r.library.stats.DPQ.EarlyReturn; +import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandFunction2_Double; +import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandomNumberProvider; +import com.oracle.truffle.r.library.stats.StatsFunctions.Function3_1; +import com.oracle.truffle.r.library.stats.StatsFunctions.Function3_2; + +public final class Weibull { + private Weibull() { + // only static members + } + + public static final class QWeibull implements Function3_2 { + @Override + public double evaluate(double p, double shape, double scale, boolean lowerTail, boolean logP) { + if (Double.isNaN(p) || Double.isNaN(shape) || Double.isNaN(scale)) { + return p + shape + scale; + } + + if (shape <= 0 || scale <= 0) { + return RMathError.defaultError(); + } + + try { + DPQ.rqp01boundaries(p, 0, Double.POSITIVE_INFINITY, lowerTail, logP); + } catch (EarlyReturn e) { + return e.result; + } + + return scale * Math.pow(-DPQ.rdtclog(p, lowerTail, logP), 1. / shape); + } + } + + public static final class PWeibull implements Function3_2 { + @Override + public double evaluate(double x, double shape, double scale, boolean lowerTail, boolean logP) { + if (Double.isNaN(x) || Double.isNaN(shape) || Double.isNaN(scale)) { + return x + shape + scale; + } + + if (shape <= 0 || scale <= 0) { + return RMathError.defaultError(); + } + + if (x <= 0) { + return DPQ.rdt0(lowerTail, logP); + } + double result = -Math.pow(x / scale, shape); + return lowerTail ? (logP ? DPQ.rlog1exp(result) : -RMath.expm1(result)) : DPQ.rdexp(result, logP); + } + } + + public static final class DWeibull implements Function3_1 { + @Override + public double evaluate(double x, double shape, double scale, boolean giveLog) { + if (Double.isNaN(x) || Double.isNaN(shape) || Double.isNaN(scale)) { + return x + shape + scale; + } + if (shape <= 0 || scale <= 0) { + return RMathError.defaultError(); + } + + if (x < 0) { + return DPQ.rd0(giveLog); + } + if (!Double.isFinite(x)) { + return DPQ.rd0(giveLog); + } + /* need to handle x == 0 separately */ + if (x == 0 && shape < 1) { + return Double.POSITIVE_INFINITY; + } + double tmp1 = Math.pow(x / scale, shape - 1); + double tmp2 = tmp1 * (x / scale); + /* These are incorrect if tmp1 == 0 */ + return giveLog ? -tmp2 + Math.log(shape * tmp1 / scale) : shape * tmp1 * Math.exp(-tmp2) / scale; + } + } + + public static final class RWeibull extends RandFunction2_Double { + @Override + public double execute(double shape, double scale, RandomNumberProvider rand) { + if (!Double.isFinite(shape) || !Double.isFinite(scale) || shape <= 0. || scale <= 0.) { + return scale == 0. ? 0. : RMathError.defaultError(); + } + + return scale * Math.pow(-Math.log(rand.unifRand()), 1.0 / shape); + + } + } +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/CallAndExternalFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/CallAndExternalFunctions.java index cac8a6973e..179a8b5a97 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/CallAndExternalFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/CallAndExternalFunctions.java @@ -112,7 +112,6 @@ import com.oracle.truffle.r.library.stats.RNBinom.RNBinomFunc; import com.oracle.truffle.r.library.stats.RNBinom.RNBinomMu; import com.oracle.truffle.r.library.stats.RNchisq; import com.oracle.truffle.r.library.stats.RPois; -import com.oracle.truffle.r.library.stats.RWeibull; import com.oracle.truffle.r.library.stats.RandGenerationFunctions; import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandFunction1Node; import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandFunction2Node; @@ -130,6 +129,10 @@ import com.oracle.truffle.r.library.stats.Unif.DUnif; import com.oracle.truffle.r.library.stats.Unif.PUnif; import com.oracle.truffle.r.library.stats.Unif.QUnif; import com.oracle.truffle.r.library.stats.Unif.Runif; +import com.oracle.truffle.r.library.stats.Weibull.DWeibull; +import com.oracle.truffle.r.library.stats.Weibull.PWeibull; +import com.oracle.truffle.r.library.stats.Weibull.QWeibull; +import com.oracle.truffle.r.library.stats.Weibull.RWeibull; import com.oracle.truffle.r.library.stats.Wilcox.RWilcox; import com.oracle.truffle.r.library.tools.C_ParseRdNodeGen; import com.oracle.truffle.r.library.tools.DirChmodNodeGen; @@ -353,6 +356,12 @@ public class CallAndExternalFunctions { return StatsFunctionsFactory.Function2_2NodeGen.create(new PPois()); case "qpois": return StatsFunctionsFactory.Function2_2NodeGen.create(new QPois()); + case "qweibull": + return StatsFunctionsFactory.Function3_2NodeGen.create(new QWeibull()); + case "pweibull": + return StatsFunctionsFactory.Function3_2NodeGen.create(new PWeibull()); + case "dweibull": + return StatsFunctionsFactory.Function3_1NodeGen.create(new DWeibull()); case "rbinom": return RandFunction2Node.createInt(new Rbinom()); case "pbinom": diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index c996358e21..ec9282c2c4 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -112688,6 +112688,90 @@ In dunif(0, Inf, 3.3) : NaNs produced [1] -1.84055 -1.84055 -1.84055 -Inf -1.84055 -1.84055 -1.84055 -Inf [9] NaN +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(0, -3.3, 0.5) +[1] NaN +Warning message: +In dweibull(0, -3.3, 0.5) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(0, -Inf, 0.5) +[1] NaN +Warning message: +In dweibull(0, -Inf, 0.5) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(0, 0, 0.5) +[1] NaN +Warning message: +In dweibull(0, 0, 0.5) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(0, 1, -3.3) +[1] NaN +Warning message: +In dweibull(0, 1, -3.3) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(0, 1, -Inf) +[1] NaN +Warning message: +In dweibull(0, 1, -Inf) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(0, 1, 0) +[1] NaN +Warning message: +In dweibull(0, 1, 0) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(0, 1, Inf) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(0, 1, NaN) +[1] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(0, Inf, 0.5) +[1] NaN +Warning message: +In dweibull(0, Inf, 0.5) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(0, NaN, 0.5) +[1] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(c(0.9, 0.99999999999999999, 1-1e-30, 1), 1e100, 1, log=F) +[1] 0.000000e+00 3.678794e+99 3.678794e+99 3.678794e+99 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(c(0.9, 0.99999999999999999, 1-1e-30, 1), 1e100, 1, log=T) +[1] -Inf 229.2585 229.2585 229.2585 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(c(1, 2, 3.3, 4, 5, 6, 6.1, 10), 0.5, 10, log=F) +[1] 0.11524817 0.07148791 0.04900381 0.04200182 0.03486522 0.02975030 0.02931637 +[8] 0.01839397 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(c(1, 2, 3.3, 4, 5, 6, 6.1, 10), 0.5, 10, log=T) +[1] -2.160667 -2.638227 -3.015857 -3.170042 -3.356265 -3.514916 -3.529609 +[8] -3.995732 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(c(1, 2, 3.3, 4, 5, 6, 6.1, 10, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 1, 0.5, log=F) + [1] 2.706706e-01 3.663128e-02 2.720736e-03 6.709253e-04 9.079986e-05 + [6] 1.228842e-05 1.006091e-05 4.122307e-09 0.000000e+00 0.000000e+00 +[11] 2.000000e+00 2.000000e+00 0.000000e+00 NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dweibull(c(1, 2, 3.3, 4, 5, 6, 6.1, 10, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 1, 0.5, log=T) + [1] -1.3068528 -3.3068528 -5.9068528 -7.3068528 -9.3068528 -11.3068528 + [7] -11.5068528 -19.3068528 -Inf -Inf 0.6931472 0.6931472 +[13] -Inf NaN + ##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# #pbeta(0, -1, 0.5) [1] NaN @@ -114243,6 +114327,117 @@ In punif(0, Inf, 3.3) : NaNs produced [1] -Inf -0.2311117 0.0000000 -Inf -0.7419373 -0.7419373 -0.7419373 [8] 0.0000000 NaN +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(0, -3.3, 0.5) +[1] NaN +Warning message: +In pweibull(0, -3.3, 0.5) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(0, -Inf, 0.5) +[1] NaN +Warning message: +In pweibull(0, -Inf, 0.5) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(0, 0, 0.5) +[1] NaN +Warning message: +In pweibull(0, 0, 0.5) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(0, 1, -3.3) +[1] NaN +Warning message: +In pweibull(0, 1, -3.3) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(0, 1, -Inf) +[1] NaN +Warning message: +In pweibull(0, 1, -Inf) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(0, 1, 0) +[1] NaN +Warning message: +In pweibull(0, 1, 0) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(0, 1, Inf) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(0, 1, NaN) +[1] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(0, Inf, 0.5) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(0, NaN, 0.5) +[1] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(c(0.9, 0.99999999999999999, 1-1e-30, 1), 1e100, 1, lower.tail=F, log.p=F) +[1] 1.0000000 0.3678794 0.3678794 0.3678794 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(c(0.9, 0.99999999999999999, 1-1e-30, 1), 1e100, 1, lower.tail=F, log.p=T) +[1] 0 -1 -1 -1 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(c(0.9, 0.99999999999999999, 1-1e-30, 1), 1e100, 1, lower.tail=T, log.p=F) +[1] 0.0000000 0.6321206 0.6321206 0.6321206 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(c(0.9, 0.99999999999999999, 1-1e-30, 1), 1e100, 1, lower.tail=T, log.p=T) +[1] -Inf -0.4586751 -0.4586751 -0.4586751 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(c(1, 2, 3.3, 4, 5, 6, 6.1, 10), 0.5, 10, lower.tail=F, log.p=F) +[1] 0.7288934 0.6394073 0.5630109 0.5312856 0.4930687 0.4608896 0.4579364 +[8] 0.3678794 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(c(1, 2, 3.3, 4, 5, 6, 6.1, 10), 0.5, 10, lower.tail=F, log.p=T) +[1] -0.3162278 -0.4472136 -0.5744563 -0.6324555 -0.7071068 -0.7745967 -0.7810250 +[8] -1.0000000 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(c(1, 2, 3.3, 4, 5, 6, 6.1, 10), 0.5, 10, lower.tail=T, log.p=F) +[1] 0.2711066 0.3605927 0.4369891 0.4687144 0.5069313 0.5391104 0.5420636 +[8] 0.6321206 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(c(1, 2, 3.3, 4, 5, 6, 6.1, 10), 0.5, 10, lower.tail=T, log.p=T) +[1] -1.3052432 -1.0200063 -0.8278471 -0.7577617 -0.6793798 -0.6178350 -0.6123719 +[8] -0.4586751 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(c(1, 2, 3.3, 4, 5, 6, 6.1, 10, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 1, 0.5, lower.tail=F, log.p=F) + [1] 1.353353e-01 1.831564e-02 1.360368e-03 3.354626e-04 4.539993e-05 + [6] 6.144212e-06 5.030456e-06 2.061154e-09 1.000000e+00 1.000000e+00 +[11] 1.000000e+00 1.000000e+00 0.000000e+00 NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(c(1, 2, 3.3, 4, 5, 6, 6.1, 10, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 1, 0.5, lower.tail=F, log.p=T) + [1] -2.00e+00 -4.00e+00 -6.60e+00 -8.00e+00 -1.00e+01 -1.20e+01 -1.22e+01 + [8] -2.00e+01 0.00e+00 0.00e+00 0.00e+00 -8.40e-31 -Inf NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(c(1, 2, 3.3, 4, 5, 6, 6.1, 10, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 1, 0.5, lower.tail=T, log.p=F) + [1] 8.646647e-01 9.816844e-01 9.986396e-01 9.996645e-01 9.999546e-01 + [6] 9.999939e-01 9.999950e-01 1.000000e+00 0.000000e+00 0.000000e+00 +[11] 0.000000e+00 8.400000e-31 1.000000e+00 NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pweibull(c(1, 2, 3.3, 4, 5, 6, 6.1, 10, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 1, 0.5, lower.tail=T, log.p=T) + [1] -1.454135e-01 -1.848545e-02 -1.361294e-03 -3.355189e-04 -4.540096e-05 + [6] -6.144231e-06 -5.030468e-06 -2.061154e-09 -Inf -Inf +[11] -Inf -6.925191e+01 0.000000e+00 NaN + ##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# #qbeta(-0.42e-38, 0.5, 0.5) [1] NaN @@ -116201,6 +116396,140 @@ In qunif(Inf, -3, 3.3) : NaNs produced #qunif(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), -3, 3.3, lower.tail=T, log.p=T) [1] -3.00 -3.00 -2.37 0.15 1.41 3.30 3.30 +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(-0.42e-38, 1, 0.5) +[1] NaN +Warning message: +In qweibull(-4.2e-39, 1, 0.5) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(-42, 1, 0.5) +[1] NaN +Warning message: +In qweibull(-42, 1, 0.5) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(-Inf, 1, 0.5) +[1] NaN +Warning message: +In qweibull(-Inf, 1, 0.5) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(0, -3.3, 0.5) +[1] NaN +Warning message: +In qweibull(0, -3.3, 0.5) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(0, -Inf, 0.5) +[1] NaN +Warning message: +In qweibull(0, -Inf, 0.5) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(0, 0, 0.5) +[1] NaN +Warning message: +In qweibull(0, 0, 0.5) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(0, 1, -3.3) +[1] NaN +Warning message: +In qweibull(0, 1, -3.3) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(0, 1, -Inf) +[1] NaN +Warning message: +In qweibull(0, 1, -Inf) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(0, 1, 0) +[1] NaN +Warning message: +In qweibull(0, 1, 0) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(0, 1, Inf) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(0, 1, NaN) +[1] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(0, Inf, 0.5) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(0, NaN, 0.5) +[1] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(Inf, 1, 0.5) +[1] NaN +Warning message: +In qweibull(Inf, 1, 0.5) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(NaN, 1, 0.5) +[1] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 0.5, 10, lower.tail=F, log.p=F) +[1] Inf 325691.09706 53.01898 4.80453 1.27217 +[6] 0.00000 0.00000 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 0.5, 10, lower.tail=T, log.p=F) +[1] 0.000000e+00 1.764000e-156 1.110084e-01 4.804530e+00 1.449551e+01 +[6] Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 1, 0.5, lower.tail=F, log.p=F) +[1] Inf 90.2345689 1.1512925 0.3465736 0.1783375 0.0000000 0.0000000 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 1, 0.5, lower.tail=T, log.p=F) +[1] 0.000000e+00 2.100000e-79 5.268026e-02 3.465736e-01 6.019864e-01 +[6] Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 1e100, 1, lower.tail=F, log.p=F) +[1] Inf 1 1 1 1 0 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 1e100, 1, lower.tail=T, log.p=F) +[1] 0 1 1 1 1 Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 0.5, 10, lower.tail=F, log.p=T) +[1] Inf 325691.09706 53.01898 4.80453 1.27217 +[6] 0.00000 0.00000 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 0.5, 10, lower.tail=T, log.p=T) +[1] 0.000000e+00 1.764000e-156 1.110084e-01 4.804530e+00 1.449551e+01 +[6] Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 1, 0.5, lower.tail=F, log.p=T) +[1] Inf 90.2345689 1.1512925 0.3465736 0.1783375 0.0000000 0.0000000 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 1, 0.5, lower.tail=T, log.p=T) +[1] 0.000000e+00 2.100000e-79 5.268026e-02 3.465736e-01 6.019864e-01 +[6] Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 1e100, 1, lower.tail=F, log.p=T) +[1] Inf 1 1 1 1 0 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qweibull(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 1e100, 1, lower.tail=T, log.p=T) +[1] 0 1 1 1 1 Inf Inf + ##com.oracle.truffle.r.test.library.stats.TestExternal_covcor.testCovcor# #.Call(stats:::C_cov, 1:5, 1:5, 4, FALSE) [1] 2.5 diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestDistributions.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestDistributions.java index 75b3c9db33..3013893dbe 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestDistributions.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestDistributions.java @@ -138,7 +138,12 @@ public class TestDistributions extends TestBase { test("10, mu=60", withQuantiles("3", "5", "6", "10", "11", "20", "100")). // non-probability value is error for the second parameter test("10, -0.1", withQuantiles("2")). - test("10, 5", withQuantiles("2")) + test("10, 5", withQuantiles("2")), + distr("weibull"). + addErrorParamValues("-3.3", "0"). + test("1, 0.5", withDefaultQ("1", "2", "3.3", "4", "5", "6", "6.1", "10")). + test("0.5, 10", withQuantiles("1", "2", "3.3", "4", "5", "6", "6.1", "10")). + test("1e100, 1", withQuantiles("0.9", "0.99999999999999999", "1-1e-30", "1")) }; // @formatter:on diff --git a/mx.fastr/copyrights/overrides b/mx.fastr/copyrights/overrides index eaa67587a1..2253a4e635 100644 --- a/mx.fastr/copyrights/overrides +++ b/mx.fastr/copyrights/overrides @@ -103,7 +103,7 @@ com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/DBeta.java,g com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/DPois.java,gnu_r.core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNchisq.java,gnu_r.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Wilcox.java,gnu_r.core.copyright -com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RWeibull.java,gnu_r_ihaka_core.copyright +com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Weibull.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/tools/DirChmod.java,gnu_r.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/tools/ToolsText.java,gnu_r.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/utils/CountFields.java,gnu_r.copyright diff --git a/testScript.R b/testScript.R deleted file mode 100644 index 7237eba327..0000000000 --- a/testScript.R +++ /dev/null @@ -1,2 +0,0 @@ -x<-c(1) -cat(x) -- GitLab