From 81f65cbbf103c322b54e197a12b9585e6492c890 Mon Sep 17 00:00:00 2001 From: stepan <stepan.sindelar@oracle.com> Date: Fri, 30 Dec 2016 19:34:27 +0100 Subject: [PATCH] Stats: port nbinom distribution Externals implemented: {p/q/d/r}nbinom, and {p/q/d}nbinom_mu --- .../truffle/r/library/stats/DNBinom.java | 127 ++++ .../truffle/r/library/stats/PNBinom.java | 96 ++++ .../truffle/r/library/stats/QNBinom.java | 115 ++++ .../truffle/r/library/stats/RNBinom.java | 56 ++ .../truffle/r/library/stats/RNbinomMu.java | 28 - .../foreign/CallAndExternalFunctions.java | 27 +- .../truffle/r/test/ExpectedTestOutput.test | 544 +++++++++++++++++- .../test/library/stats/TestDistributions.java | 12 +- .../library/stats/TestExternal_rnbinom.java | 3 +- .../stats/TestRandGenerationFunctions.java | 2 +- mx.fastr/copyrights/overrides | 5 +- testScript.R | 2 + 12 files changed, 980 insertions(+), 37 deletions(-) create mode 100644 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/DNBinom.java create mode 100644 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/PNBinom.java create mode 100644 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QNBinom.java create mode 100644 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNBinom.java delete mode 100644 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNbinomMu.java create mode 100644 testScript.R diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/DNBinom.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/DNBinom.java new file mode 100644 index 0000000000..f9acf7754f --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/DNBinom.java @@ -0,0 +1,127 @@ +/* + * 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) 2000--2016, The R Core Team + * Copyright (c) 2016, Oracle and/or its affiliates + * + * All rights reserved. + */ +/* + * AUTHOR + * Catherine Loader, catherine@research.bell-labs.com. + * October 23, 2000 and Feb, 2001. + * + * dnbinom_mu(): Martin Maechler, June 2008 + */ + +package com.oracle.truffle.r.library.stats; + +import static com.oracle.truffle.r.library.stats.DPois.dpoisRaw; +import static com.oracle.truffle.r.library.stats.Dbinom.dbinomRaw; +import static com.oracle.truffle.r.library.stats.GammaFunctions.lgamma; +import static com.oracle.truffle.r.library.stats.MathConstants.DBL_MAX; + +import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.r.library.stats.DPQ.EarlyReturn; +import com.oracle.truffle.r.library.stats.StatsFunctions.Function3_1; + +public final class DNBinom { + private DNBinom() { + // only static members + } + + public static final class DNBinomFunc implements Function3_1 { + private final BranchProfile nanProfile = BranchProfile.create(); + + @Override + public double evaluate(double x, double sizeIn, double prob, boolean giveLog) { + if (Double.isNaN(x) || Double.isNaN(sizeIn) || Double.isNaN(prob)) { + nanProfile.enter(); + return x + sizeIn + prob; + } + if (prob <= 0 || prob > 1 || sizeIn < 0) { + nanProfile.enter(); + return RMathError.defaultError(); + } + + try { + DPQ.nonintCheck(x, giveLog); + } catch (EarlyReturn e) { + return e.result; + } + + if (x < 0 || !Double.isFinite(x)) { + return DPQ.rd0(giveLog); + } + /* limiting case as size approaches zero is point mass at zero */ + if (x == 0 && sizeIn == 0) { + return DPQ.rd1(giveLog); + } + double ix = RMath.forceint(x); + double size = Double.isFinite(sizeIn) ? sizeIn : DBL_MAX; + double ans = dbinomRaw(size, ix + size, prob, 1 - prob, giveLog); + double p = size / (size + ix); + return giveLog ? Math.log(p) + ans : p * ans; + } + } + + public static final class DNBinomMu implements Function3_1 { + @Override + public double evaluate(double x, double size, double mu, boolean giveLog) { + /* + * originally, just set prob := size / (size + mu) and called dbinom_raw(), but that + * suffers from cancellation when mu << size + */ + if (Double.isNaN(x) || Double.isNaN(size) || Double.isNaN(mu)) { + return x + size + mu; + } + + if (mu < 0 || size < 0) { + return RMathError.defaultError(); + } + try { + DPQ.nonintCheck(x, giveLog); + } catch (EarlyReturn e) { + return e.result; + } + + if (x < 0 || !Double.isFinite(x)) { + return DPQ.rd0(giveLog); + } + + /* + * limiting case as size approaches zero is point mass at zero, even if mu is kept + * constant. limit distribution does not have mean mu, though. + */ + if (x == 0 && size == 0) { + return DPQ.rd1(giveLog); + } + x = RMath.forceint(x); + if (!Double.isFinite(size)) { + // limit case: Poisson + return (dpoisRaw(x, mu, giveLog)); + } + + if (x == 0)/* be accurate, both for n << mu, and n >> mu : */ { + double ans = size * (size < mu ? Math.log(size / (size + mu)) : RMath.log1p(-mu / (size + mu))); + return DPQ.rdexp(ans, giveLog); + } + if (x < 1e-10 * size) { /* don't use dbinom_raw() but MM's formula: */ + /* GnuR fix me --- 1e-8 shows problem; rather use algdiv() from ./toms708.c */ + double p = (size < mu ? Math.log(size / (1 + size / mu)) : Math.log(mu / (1 + mu / size))); + double ans = x * p - mu - lgamma(x + 1) + RMath.log1p(x * (x - 1) / (2 * size)); + return DPQ.rdexp(ans, giveLog); + } else { + /* + * no unnecessary cancellation inside dbinom_raw, when x_ = size and n_ = x+size are + * so close that n_ - x_ loses accuracy + */ + double p = size / (size + x); + double ans = dbinomRaw(size, x + size, size / (size + mu), mu / (size + mu), giveLog); + return ((giveLog) ? Math.log(p) + ans : p * ans); + } + } + } +} diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/PNBinom.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/PNBinom.java new file mode 100644 index 0000000000..7a45673c6c --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/PNBinom.java @@ -0,0 +1,96 @@ +/* + * 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) 2000-2016, The R Core Team + * Copyright (c) 2016, Oracle and/or its affiliates + * + * All rights reserved. + */ +package com.oracle.truffle.r.library.stats; + +import com.oracle.truffle.r.library.stats.StatsFunctions.Function3_2; +import com.oracle.truffle.r.library.stats.TOMS708.Bratio; +import com.oracle.truffle.r.runtime.RError.Message; +import com.oracle.truffle.r.runtime.Utils; + +public final class PNBinom { + private PNBinom() { + // only static members + } + + public static final class PNBinomFunc implements Function3_2 { + private final Pbeta pbeta = new Pbeta(); + + @Override + public double evaluate(double x, double size, double prob, boolean lowerTail, boolean logP) { + if (Double.isNaN(x) || Double.isNaN(size) || Double.isNaN(prob)) { + return x + size + prob; + } + if (!Double.isFinite(size) || !Double.isFinite(prob) || size < 0 || prob <= 0 || prob > 1) { + return RMathError.defaultError(); + } + + /* limiting case: point mass at zero */ + if (size == 0) { + return x >= 0 ? DPQ.rdt1(lowerTail, logP) : DPQ.rdt0(lowerTail, logP); + } + + if (x < 0) { + return DPQ.rdt0(lowerTail, logP); + } + if (!Double.isFinite(x)) { + return DPQ.rdt1(lowerTail, logP); + } + double floorX = Math.floor(x + 1e-7); + return pbeta.evaluate(prob, size, floorX + 1, lowerTail, logP); + } + } + + public static final class PNBinomMu implements Function3_2 { + private final PPois ppois = new PPois(); + + @Override + public double evaluate(double x, double size, double mu, boolean lowerTail, boolean logP) { + if (Double.isNaN(x) || Double.isNaN(size) || Double.isNaN(mu)) { + return x + size + mu; + } + if (!Double.isFinite(mu) || size < 0 || mu < 0) { + return RMathError.defaultError(); + } + + /* limiting case: point mass at zero */ + if (size == 0) { + return (x >= 0) ? DPQ.rdt1(lowerTail, logP) : DPQ.rdt0(lowerTail, logP); + } + + if (x < 0) { + return DPQ.rdt0(lowerTail, logP); + } + if (!Double.isFinite(x)) { + return DPQ.rdt1(lowerTail, logP); + } + if (!Double.isFinite(size)) { + // limit case: Poisson + return (ppois.evaluate(x, mu, lowerTail, logP)); + } + + double floorX = Math.floor(x + 1e-7); + /* + * return pbeta(pr, size, x + 1, lowerTail, logP); pr = size/(size + mu), 1-pr = + * mu/(size+mu) + * + * = pbeta_raw(pr, size, x + 1, lowerTail, logP) x. pin qin = bratio (pin, qin, x., + * 1-x., &w, &wc, &ierr, logP), and return w or wc .. = bratio (size, x+1, pr, 1-pr, &w, + * &wc, &ierr, logP) + */ + Bratio bratioResult = Bratio.bratio(size, floorX + 1, size / (size + mu), mu / (size + mu), logP); + if (bratioResult.ierr != 0) { + RMathError.warning(Message.GENERIC, Utils.stringFormat("pnbinom_mu() -> bratio() gave error code %d", bratioResult.ierr)); + } + return lowerTail ? bratioResult.w : bratioResult.w1; + } + } +} diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QNBinom.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QNBinom.java new file mode 100644 index 0000000000..c568e6e006 --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QNBinom.java @@ -0,0 +1,115 @@ +/* + * 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) 2000-2016, The R Core Team + * Copyright (c) 2005-2016, The R Foundation + * Copyright (c) 2016, Oracle and/or its affiliates + * + * All rights reserved. + */ +package com.oracle.truffle.r.library.stats; + +import static com.oracle.truffle.r.library.stats.MathConstants.DBL_EPSILON; + +import com.oracle.truffle.r.library.stats.DPQ.EarlyReturn; +import com.oracle.truffle.r.library.stats.PNBinom.PNBinomFunc; +import com.oracle.truffle.r.library.stats.StatsFunctions.Function3_2; + +public final class QNBinom { + private QNBinom() { + // only static members + } + + public static final class QNBinomFunc implements Function3_2 { + private final Qnorm qnorm = new Qnorm(); + private final PNBinomFunc pnbinom = new PNBinomFunc(); + + @Override + public double evaluate(double pIn, double size, double prob, boolean lowerTail, boolean logP) { + if (Double.isNaN(pIn) || Double.isNaN(size) || Double.isNaN(prob)) { + return pIn + size + prob; + } + + /* + * this happens if specified via mu, size, since prob == size/(size+mu) + */ + if (prob == 0 && size == 0) { + return 0; + } + + if (prob <= 0 || prob > 1 || size < 0) { + return RMathError.defaultError(); + } + + if (prob == 1 || size == 0) { + return 0; + } + + try { + DPQ.rqp01boundaries(pIn, 0, Double.POSITIVE_INFINITY, lowerTail, logP); + } catch (EarlyReturn e) { + return e.result; + } + + double capQ = 1.0 / prob; + double capP = (1.0 - prob) * capQ; + double mu = size * capP; + double sigma = Math.sqrt(size * capP * capQ); + double gamma = (capQ + capP) / sigma; + + /* + * Note : "same" code in qpois.c, qbinom.c, qnbinom.c -- GnuR fix me: This is far from + * optimal [cancellation for p ~= 1, etc]: + */ + double p = pIn; + if (!lowerTail || logP) { + p = DPQ.rdtqiv(p, lowerTail, logP); /* need check again (cancellation!): */ + if (p == DPQ.rdt0(lowerTail, logP)) { + return 0; + } + if (p == DPQ.rdt1(lowerTail, logP)) { + return Double.POSITIVE_INFINITY; + } + } + /* GnuR fix me: temporary hack */ + if (p + 1.01 * DBL_EPSILON >= 1.) { + return Double.POSITIVE_INFINITY; + } + + /* y := approx.value (Cornish-Fisher expansion) : */ + double qnormZ = qnorm.evaluate(p, 0., 1., /* lowerTail */true, /* logP */false); + double y = RMath.forceint(mu + sigma * (qnormZ + gamma * (qnormZ * qnormZ - 1) / 6)); + + /* fuzz to ensure left continuity: */ + p *= 1 - 64 * DBL_EPSILON; + + QuantileSearch search = new QuantileSearch((q, lt, lp) -> pnbinom.evaluate(q, size, prob, lt, lp)); + + if (y < 1e5) { + /* If the C-F value is not too large a simple search is OK */ + return search.simpleSearch(y, p, 1); + } else { + /* Otherwise be a bit cleverer in the search */ + return search.iterativeSearch(y, p); + } + } + } + + public static final class QNBinomMu implements Function3_2 { + private final QPois qpois = new QPois(); + private final QNBinomFunc qnbinom = new QNBinomFunc(); + + @Override + public double evaluate(double p, double size, double mu, boolean lowerTail, boolean logP) { + if (size == Double.POSITIVE_INFINITY) { + // limit case: poisson + return qpois.evaluate(p, mu, lowerTail, logP); + } + // GnuR fix me: implement this properly not losing acuracy for large size (prob ~= 1) + return qnbinom.evaluate(p, size, size / (size + mu), lowerTail, logP); + } + } +} diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNBinom.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNBinom.java new file mode 100644 index 0000000000..e8f56f4509 --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNBinom.java @@ -0,0 +1,56 @@ +/* + * 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) 2000--2016, The R Core Team + * Copyright (c) 2016, Oracle and/or its affiliates + * + * All rights reserved. + */ +package com.oracle.truffle.r.library.stats; + +import static com.oracle.truffle.r.library.stats.MathConstants.DBL_MAX; + +import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandFunction2_Double; +import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandomNumberProvider; + +public final class RNBinom { + private RNBinom() { + // only static members + } + + public static final class RNBinomFunc extends RandFunction2_Double { + @Child private RPois rpois = new RPois(); + @Child private RGamma rgamma = new RGamma(); + + @Override + public double execute(double size, double prob, RandomNumberProvider rand) { + if (!Double.isFinite(prob) || Double.isNaN(size) || size <= 0 || prob <= 0 || prob > 1) { + /* prob = 1 is ok, PR#1218 */ + return RMathError.defaultError(); + } + return (prob == 1) ? 0 : rpois.execute(rgamma.execute(fixupSize(size), (1 - prob) / prob, rand), rand); + } + } + + public static final class RNBinomMu extends RandFunction2_Double { + @Child private RPois rpois = new RPois(); + @Child private RGamma rgamma = new RGamma(); + + @Override + public double execute(double size, double mu, RandomNumberProvider rand) { + if (!Double.isFinite(mu) || Double.isNaN(size) || size <= 0 || mu < 0) { + return RMathError.defaultError(); + } + double fixedSize = fixupSize(size); + return (mu == 0) ? 0 : rpois.execute(rgamma.execute(fixedSize, mu / fixedSize, rand), rand); + } + } + + private static double fixupSize(double size) { + // 'DBL_MAX/2' to prevent rgamma() returning Inf + return !Double.isFinite(size) ? DBL_MAX / 2. : size; + } +} diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNbinomMu.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNbinomMu.java deleted file mode 100644 index cf5f8b0401..0000000000 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNbinomMu.java +++ /dev/null @@ -1,28 +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 RNbinomMu extends RandFunction2_Double { - private final RGamma rgamma = new RGamma(); - - @Override - public double execute(double initialSize, double mu, RandomNumberProvider rand) { - if (!Double.isFinite(mu) || Double.isNaN(initialSize) || initialSize <= 0 || mu < 0) { - return RMathError.defaultError(); - } - double size = Double.isFinite(initialSize) ? initialSize : Double.MAX_VALUE / 2.; - return (mu == 0) ? 0 : RPois.rpois(rgamma.execute(size, mu / size, rand), rand); - } -} 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 41d336596c..cac8a6973e 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 @@ -5,7 +5,7 @@ * * Copyright (c) 1995-2012, The R Core Team * Copyright (c) 2003, The R Foundation - * Copyright (c) 2015, 2016, Oracle and/or its affiliates + * Copyright (c) 2015, 2017, Oracle and/or its affiliates * * All rights reserved. */ @@ -53,6 +53,8 @@ import com.oracle.truffle.r.library.stats.CutreeNodeGen; import com.oracle.truffle.r.library.stats.DBeta; import com.oracle.truffle.r.library.stats.DHyper; import com.oracle.truffle.r.library.stats.DNBeta; +import com.oracle.truffle.r.library.stats.DNBinom.DNBinomFunc; +import com.oracle.truffle.r.library.stats.DNBinom.DNBinomMu; import com.oracle.truffle.r.library.stats.DNChisq; import com.oracle.truffle.r.library.stats.DNorm; import com.oracle.truffle.r.library.stats.DPois; @@ -80,6 +82,8 @@ import com.oracle.truffle.r.library.stats.Logis.RLogis; import com.oracle.truffle.r.library.stats.PGamma; import com.oracle.truffle.r.library.stats.PHyper; import com.oracle.truffle.r.library.stats.PNBeta; +import com.oracle.truffle.r.library.stats.PNBinom.PNBinomFunc; +import com.oracle.truffle.r.library.stats.PNBinom.PNBinomMu; import com.oracle.truffle.r.library.stats.PNChisq; import com.oracle.truffle.r.library.stats.PPois; import com.oracle.truffle.r.library.stats.Pbeta; @@ -91,6 +95,8 @@ import com.oracle.truffle.r.library.stats.Pt; import com.oracle.truffle.r.library.stats.QBeta; import com.oracle.truffle.r.library.stats.QHyper; import com.oracle.truffle.r.library.stats.QNBeta; +import com.oracle.truffle.r.library.stats.QNBinom.QNBinomFunc; +import com.oracle.truffle.r.library.stats.QNBinom.QNBinomMu; import com.oracle.truffle.r.library.stats.QNChisq; import com.oracle.truffle.r.library.stats.QPois; import com.oracle.truffle.r.library.stats.Qbinom; @@ -102,7 +108,8 @@ import com.oracle.truffle.r.library.stats.RBeta; import com.oracle.truffle.r.library.stats.RGamma; import com.oracle.truffle.r.library.stats.RHyper; import com.oracle.truffle.r.library.stats.RMultinomNodeGen; -import com.oracle.truffle.r.library.stats.RNbinomMu; +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; @@ -295,7 +302,7 @@ public class CallAndExternalFunctions { case "rnchisq": return RandFunction2Node.createDouble(new RNchisq()); case "rnbinom_mu": - return RandFunction2Node.createDouble(new RNbinomMu()); + return RandFunction2Node.createDouble(new RNBinomMu()); case "rwilcox": return RandFunction2Node.createInt(new RWilcox()); case "rchisq": @@ -306,6 +313,8 @@ public class CallAndExternalFunctions { return RandFunction1Node.createInt(new RGeom()); case "rpois": return RandFunction1Node.createInt(new RPois()); + case "rnbinom": + return RandFunction2Node.createInt(new RNBinomFunc()); case "rt": return RandFunction1Node.createDouble(new Rt()); case "rsignrank": @@ -418,6 +427,18 @@ public class CallAndExternalFunctions { return StatsFunctionsFactory.Function3_2NodeGen.create(new Logis.PLogis()); case "pgeom": return StatsFunctionsFactory.Function2_2NodeGen.create(new Geom.PGeom()); + case "qnbinom": + return StatsFunctionsFactory.Function3_2NodeGen.create(new QNBinomFunc()); + case "dnbinom": + return StatsFunctionsFactory.Function3_1NodeGen.create(new DNBinomFunc()); + case "pnbinom": + return StatsFunctionsFactory.Function3_2NodeGen.create(new PNBinomFunc()); + case "qnbinom_mu": + return StatsFunctionsFactory.Function3_2NodeGen.create(new QNBinomMu()); + case "dnbinom_mu": + return StatsFunctionsFactory.Function3_1NodeGen.create(new DNBinomMu()); + case "pnbinom_mu": + return StatsFunctionsFactory.Function3_2NodeGen.create(new PNBinomMu()); case "rmultinom": return RMultinomNodeGen.create(); case "Approx": 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 a737b28c29..c996358e21 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 @@ -112423,6 +112423,120 @@ In dhyper(c(2), 3, 4, 10, log = F) : NaNs produced Warning message: In dhyper(c(2), 3, 4, 10, log = T) : NaNs produced +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(0, -2, 0.33) +[1] NaN +Warning message: +In dnbinom(0, -2, 0.33) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(0, -Inf, 0.33) +[1] NaN +Warning message: +In dnbinom(0, -Inf, 0.33) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(0, 10, -2) +[1] NaN +Warning message: +In dnbinom(0, 10, -2) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(0, 10, -Inf) +[1] NaN +Warning message: +In dnbinom(0, 10, -Inf) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(0, 10, Inf) +[1] NaN +Warning message: +In dnbinom(0, 10, Inf) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(0, 10, NaN) +[1] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(0, Inf, 0.33) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(0, NaN, 0.33) +[1] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(c(0, 10, 100, 1000, 1100, 1200), 1000, 0.5, log=F) +[1] 9.332636e-302 2.626776e-281 9.523728e-188 8.919506e-03 7.667020e-04 +[6] 8.639136e-07 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(c(0, 10, 100, 1000, 1100, 1200), 1000, 0.5, log=T) +[1] -693.147181 -646.060654 -430.632211 -4.719515 -7.173412 -13.961793 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(c(2), 10, -0.1, log=F) +[1] NaN +Warning message: +In dnbinom(c(2), 10, -0.1, log = F) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(c(2), 10, -0.1, log=T) +[1] NaN +Warning message: +In dnbinom(c(2), 10, -0.1, log = T) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(c(2), 10, 5, log=F) +[1] NaN +Warning message: +In dnbinom(c(2), 10, 5, log = F) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(c(2), 10, 5, log=T) +[1] NaN +Warning message: +In dnbinom(c(2), 10, 5, log = T) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(c(3, 5, 6, 10, 11, 20, 100), 10, mu=60, log=F) +[1] 4.904581e-07 3.279063e-06 7.026563e-06 7.000358e-05 1.090965e-04 +[6] 1.624557e-03 3.048589e-03 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(c(3, 5, 6, 10, 11, 20, 100), 10, mu=60, log=T) +[1] -14.527926 -12.627953 -11.865813 -9.566964 -9.123278 -6.422520 -5.793076 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(c(5, 10, 11, 13, 20), 10.3, 0.4, log=F) +[1] 0.01405405 0.05506928 0.06097671 0.06683845 0.04084096 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(c(5, 10, 11, 13, 20), 10.3, 0.4, log=T) +[1] -4.264845 -2.899163 -2.797263 -2.705477 -3.198070 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(c(5, 10, 11, 13, 20, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, 0.33, log=F) + [1] 4.139782e-03 2.579028e-02 3.141724e-02 4.176717e-02 5.096671e-02 + [6] 0.000000e+00 0.000000e+00 1.531579e-05 1.531579e-05 0.000000e+00 +[11] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(c(5, 10, 11, 13, 20, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, 0.33, log=T) + [1] -5.487112 -3.657758 -3.460398 -3.175645 -2.976583 -Inf + [7] -Inf -11.086626 -11.086626 -Inf NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(c(5, 6, 10, 11, 20, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 1000, mu=10, log=F) + [1] 3.820978e-02 6.336771e-02 1.244890e-01 1.131719e-01 1.941149e-03 + [6] 2.281871e-61 0.000000e+00 0.000000e+00 4.771185e-05 4.771185e-05 +[11] 0.000000e+00 NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# +#dnbinom(c(5, 6, 10, 11, 20, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 1000, mu=10, log=T) + [1] -3.264664 -2.758801 -2.083538 -2.178848 -6.244475 -139.632695 + [7] -Inf -Inf -9.950331 -9.950331 -Inf NaN + ##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext# #dnorm(0, -Inf, -1) [1] NaN @@ -113716,6 +113830,199 @@ In phyper(c(2), 3, 4, 10, lower.tail = T, log.p = F) : NaNs produced Warning message: In phyper(c(2), 3, 4, 10, lower.tail = T, log.p = T) : NaNs produced +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(0, -2, 0.33) +[1] NaN +Warning message: +In pnbinom(0, -2, 0.33) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(0, -Inf, 0.33) +[1] NaN +Warning message: +In pnbinom(0, -Inf, 0.33) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(0, 10, -2) +[1] NaN +Warning message: +In pnbinom(0, 10, -2) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(0, 10, -Inf) +[1] NaN +Warning message: +In pnbinom(0, 10, -Inf) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(0, 10, Inf) +[1] NaN +Warning message: +In pnbinom(0, 10, Inf) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(0, 10, NaN) +[1] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(0, Inf, 0.33) +[1] NaN +Warning message: +In pnbinom(0, Inf, 0.33) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(0, NaN, 0.33) +[1] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(0, 10, 100, 1000, 1100, 1200), 1000, 0.5, lower.tail=F, log.p=F) +[1] 1.000000e+00 1.000000e+00 1.000000e+00 4.910805e-01 1.375028e-02 +[6] 9.007903e-06 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(0, 10, 100, 1000, 1100, 1200), 1000, 0.5, lower.tail=F, log.p=T) +[1] -9.332636e-302 -2.679787e-281 -1.163725e-187 -7.111472e-01 -4.286696e+00 +[6] -1.161741e+01 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(0, 10, 100, 1000, 1100, 1200), 1000, 0.5, lower.tail=T, log.p=F) +[1] 9.332636e-302 2.679787e-281 1.163725e-187 5.089195e-01 9.862497e-01 +[6] 9.999910e-01 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(0, 10, 100, 1000, 1100, 1200), 1000, 0.5, lower.tail=T, log.p=T) +[1] -6.931472e+02 -6.460407e+02 -4.304318e+02 -6.754654e-01 -1.384569e-02 +[6] -9.007944e-06 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(2), 10, -0.1, lower.tail=F, log.p=F) +[1] NaN +Warning message: +In pnbinom(c(2), 10, -0.1, lower.tail = F, log.p = F) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(2), 10, -0.1, lower.tail=F, log.p=T) +[1] NaN +Warning message: +In pnbinom(c(2), 10, -0.1, lower.tail = F, log.p = T) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(2), 10, -0.1, lower.tail=T, log.p=F) +[1] NaN +Warning message: +In pnbinom(c(2), 10, -0.1, lower.tail = T, log.p = F) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(2), 10, -0.1, lower.tail=T, log.p=T) +[1] NaN +Warning message: +In pnbinom(c(2), 10, -0.1, lower.tail = T, log.p = T) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(2), 10, 5, lower.tail=F, log.p=F) +[1] NaN +Warning message: +In pnbinom(c(2), 10, 5, lower.tail = F, log.p = F) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(2), 10, 5, lower.tail=F, log.p=T) +[1] NaN +Warning message: +In pnbinom(c(2), 10, 5, lower.tail = F, log.p = T) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(2), 10, 5, lower.tail=T, log.p=F) +[1] NaN +Warning message: +In pnbinom(c(2), 10, 5, lower.tail = T, log.p = F) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(2), 10, 5, lower.tail=T, log.p=T) +[1] NaN +Warning message: +In pnbinom(c(2), 10, 5, lower.tail = T, log.p = T) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(3, 5, 6, 10, 11, 20, 100), 10, mu=60, lower.tail=F, log.p=F) +[1] 0.99999933 0.99999469 0.99998766 0.99983583 0.99972674 0.99314777 0.03829234 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(3, 5, 6, 10, 11, 20, 100), 10, mu=60, lower.tail=F, log.p=T) +[1] -6.673927e-07 -5.312745e-06 -1.233937e-05 -1.641817e-04 -2.733021e-04 +[6] -6.875815e-03 -3.262505e+00 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(3, 5, 6, 10, 11, 20, 100), 10, mu=60, lower.tail=T, log.p=F) +[1] 6.673925e-07 5.312731e-06 1.233929e-05 1.641682e-04 2.732647e-04 +[6] 6.852230e-03 9.617077e-01 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(3, 5, 6, 10, 11, 20, 100), 10, mu=60, lower.tail=T, log.p=T) +[1] -14.21988749 -12.14540447 -11.30272172 -8.71461880 -8.20506952 +[6] -4.98318108 -0.03904476 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(5, 10, 11, 13, 20), 10.3, 0.4, lower.tail=F, log.p=F) +[1] 0.9714099 0.7782602 0.7172835 0.5855049 0.1959118 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(5, 10, 11, 13, 20), 10.3, 0.4, lower.tail=F, log.p=T) +[1] -0.02900671 -0.25069434 -0.33228410 -0.53528078 -1.63009087 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(5, 10, 11, 13, 20), 10.3, 0.4, lower.tail=T, log.p=F) +[1] 0.02859005 0.22173978 0.28271649 0.41449513 0.80408823 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(5, 10, 11, 13, 20), 10.3, 0.4, lower.tail=T, log.p=T) +[1] -3.5546965 -1.5062507 -1.2633107 -0.8806941 -0.2180463 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(5, 10, 11, 13, 20, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, 0.33, lower.tail=F, log.p=F) + [1] 0.9921440 0.9134220 0.8820048 0.8034009 0.4471190 1.0000000 1.0000000 + [8] 0.9999847 0.9999847 0.0000000 NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(5, 10, 11, 13, 20, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, 0.33, lower.tail=F, log.p=T) + [1] -7.886994e-03 -9.055724e-02 -1.255578e-01 -2.189014e-01 -8.049304e-01 + [6] 0.000000e+00 0.000000e+00 -1.531591e-05 -1.531591e-05 -Inf +[11] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(5, 10, 11, 13, 20, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, 0.33, lower.tail=T, log.p=F) + [1] 7.855973e-03 8.657795e-02 1.179952e-01 1.965991e-01 5.528810e-01 + [6] 0.000000e+00 0.000000e+00 1.531579e-05 1.531579e-05 1.000000e+00 +[11] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(5, 10, 11, 13, 20, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, 0.33, lower.tail=T, log.p=T) + [1] -4.8464812 -2.4467101 -2.1371114 -1.6265887 -0.5926126 -Inf + [7] -Inf -11.0866262 -11.0866262 0.0000000 NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(5, 6, 10, 11, 20, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 1000, mu=10, lower.tail=F, log.p=F) + [1] 9.319688e-01 8.686011e-01 4.169592e-01 3.037874e-01 1.683088e-03 + [6] 2.754691e-62 1.000000e+00 1.000000e+00 9.999523e-01 9.999523e-01 +[11] 0.000000e+00 NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(5, 6, 10, 11, 20, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 1000, mu=10, lower.tail=F, log.p=T) + [1] -7.045589e-02 -1.408712e-01 -8.747669e-01 -1.191427e+00 -6.387125e+00 + [6] -1.417470e+02 0.000000e+00 0.000000e+00 -4.771298e-05 -4.771298e-05 +[11] -Inf NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(5, 6, 10, 11, 20, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 1000, mu=10, lower.tail=T, log.p=F) + [1] 6.803115e-02 1.313989e-01 5.830408e-01 6.962126e-01 9.983169e-01 + [6] 1.000000e+00 0.000000e+00 0.000000e+00 4.771185e-05 4.771185e-05 +[11] 1.000000e+00 NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# +#pnbinom(c(5, 6, 10, 11, 20, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 1000, mu=10, lower.tail=T, log.p=T) + [1] -2.687790e+00 -2.029518e+00 -5.394981e-01 -3.621002e-01 -1.684505e-03 + [6] -2.754691e-62 -Inf -Inf -9.950331e+00 -9.950331e+00 +[11] 0.000000e+00 NaN + ##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext# #pnorm(0, -Inf, -1) [1] NaN @@ -115398,6 +115705,212 @@ Warning message: In qhyper(log(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1)), 7e+12, : NaNs produced +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(-0.42e-38, 10, 0.33) +[1] NaN +Warning message: +In qnbinom(-4.2e-39, 10, 0.33) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(-42, 10, 0.33) +[1] NaN +Warning message: +In qnbinom(-42, 10, 0.33) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(-Inf, 10, 0.33) +[1] NaN +Warning message: +In qnbinom(-Inf, 10, 0.33) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(0, -2, 0.33) +[1] NaN +Warning message: +In qnbinom(0, -2, 0.33) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(0, -Inf, 0.33) +[1] NaN +Warning message: +In qnbinom(0, -Inf, 0.33) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(0, 10, -2) +[1] NaN +Warning message: +In qnbinom(0, 10, -2) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(0, 10, -Inf) +[1] NaN +Warning message: +In qnbinom(0, 10, -Inf) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(0, 10, Inf) +[1] NaN +Warning message: +In qnbinom(0, 10, Inf) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(0, 10, NaN) +[1] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(0, Inf, 0.33) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(0, NaN, 0.33) +[1] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(Inf, 10, 0.33) +[1] NaN +Warning message: +In qnbinom(Inf, 10, 0.33) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(NaN, 10, 0.33) +[1] NaN + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 10, -0.1, lower.tail=F, log.p=F) +[1] NaN NaN NaN NaN NaN NaN NaN +Warning message: +In qnbinom(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1), 10, -0.1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 10, -0.1, lower.tail=T, log.p=F) +[1] NaN NaN NaN NaN NaN NaN NaN +Warning message: +In qnbinom(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1), 10, -0.1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 10, 0.33, lower.tail=F, log.p=F) +[1] Inf 0 31 19 16 0 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 10, 0.33, lower.tail=T, log.p=F) +[1] 0 0 11 19 24 Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 10, 5, lower.tail=F, log.p=F) +[1] NaN NaN NaN NaN NaN NaN NaN +Warning message: +In qnbinom(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1), 10, 5, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 10, 5, lower.tail=T, log.p=F) +[1] NaN NaN NaN NaN NaN NaN NaN +Warning message: +In qnbinom(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1), 10, 5, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 10, mu=60, lower.tail=F, log.p=F) +[1] Inf 0 87 58 48 0 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 10, mu=60, lower.tail=T, log.p=F) +[1] 0 0 36 58 69 Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 10.3, 0.4, lower.tail=F, log.p=F) +[1] Inf 0 24 15 12 0 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 10.3, 0.4, lower.tail=T, log.p=F) +[1] 0 0 8 15 18 Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 1000, 0.5, lower.tail=F, log.p=F) +[1] Inf 0 1058 999 976 0 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 1000, 0.5, lower.tail=T, log.p=F) +[1] 0 330 943 999 1023 Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 1000, mu=10, lower.tail=F, log.p=F) +[1] Inf 0 14 10 8 0 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 1000, mu=10, lower.tail=T, log.p=F) +[1] 0 0 6 10 12 Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 10, -0.1, lower.tail=F, log.p=T) +[1] NaN NaN NaN NaN NaN NaN NaN +Warning message: +In qnbinom(log(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1)), 10, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 10, -0.1, lower.tail=T, log.p=T) +[1] NaN NaN NaN NaN NaN NaN NaN +Warning message: +In qnbinom(log(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1)), 10, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 10, 0.33, lower.tail=F, log.p=T) +[1] Inf Inf 31 19 16 0 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 10, 0.33, lower.tail=T, log.p=T) +[1] 0 0 11 19 24 Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 10, 5, lower.tail=F, log.p=T) +[1] NaN NaN NaN NaN NaN NaN NaN +Warning message: +In qnbinom(log(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1)), 10, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 10, 5, lower.tail=T, log.p=T) +[1] NaN NaN NaN NaN NaN NaN NaN +Warning message: +In qnbinom(log(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1)), 10, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 10, mu=60, lower.tail=F, log.p=T) +[1] Inf Inf 87 58 48 0 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 10, mu=60, lower.tail=T, log.p=T) +[1] 0 0 36 58 69 Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 10.3, 0.4, lower.tail=F, log.p=T) +[1] Inf Inf 24 15 12 0 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 10.3, 0.4, lower.tail=T, log.p=T) +[1] 0 0 8 15 18 Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 1000, 0.5, lower.tail=F, log.p=T) +[1] Inf Inf 1058 999 976 0 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 1000, 0.5, lower.tail=T, log.p=T) +[1] 0 330 943 999 1023 Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 1000, mu=10, lower.tail=F, log.p=T) +[1] Inf Inf 14 10 8 0 0 + +##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# +#qnbinom(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 1000, mu=10, lower.tail=T, log.p=T) +[1] 0 0 6 10 12 Inf Inf + ##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext# #qnorm(-0.42e-38, 0, -1) [1] NaN @@ -115764,7 +116277,7 @@ In rbinom("aa", 10, 0.5) : NAs introduced by coercion #set.seed(42); rbinom(c(1,2), 11:12, c(0.1, 0.5, 0.9)) [1] 3 9 -##com.oracle.truffle.r.test.library.stats.TestExternal_rnbinom.testRbinomWithMu#Ignored.Unstable# +##com.oracle.truffle.r.test.library.stats.TestExternal_rnbinom.testRbinomWithMu# #set.seed(42); rnbinom(100, c(-1, 0, 1, 0.8, 10, NA, NaN, 1/0, -1/0), mu=c(-1, 0, 1, 0.8, 3, 10, NA, NaN, 1/0, -1/0)) [1] NaN NaN 1 1 4 NaN NaN NaN NaN NaN NaN 0 0 0 NaN NaN NaN NaN [19] NaN NaN NaN 0 0 NaN NaN 5 NaN NaN NaN NaN NaN 0 NaN NaN 5 NaN @@ -118406,6 +118919,35 @@ Warning message: In rlogis(30, c(NA, 0, NaN, 1/0, -1/0), c(NaN, NaN, NA, 0, 1/0, : NAs produced +##com.oracle.truffle.r.test.library.stats.TestRandGenerationFunctions.testFunctions2#Output.IgnoreWhitespace# +#set.seed(1); rnbinom(10, 10, 10) + [1] NA NA NA NA NA NA NA NA NA NA +Warning message: +In rnbinom(10, 10, 10) : NAs produced + +##com.oracle.truffle.r.test.library.stats.TestRandGenerationFunctions.testFunctions2#Output.IgnoreWhitespace# +#set.seed(1); rnbinom(20, c(-1, 0, 0.2, 2:5), c(-1, 0, 0.1, 0.9, 3)) + [1] NA NA 0 1 NA NA NA NA NA NA NA NA 66 0 NA NA NA 25 0 NA +Warning message: +In rnbinom(20, c(-1, 0, 0.2, 2:5), c(-1, 0, 0.1, 0.9, 3)) : NAs produced + +##com.oracle.truffle.r.test.library.stats.TestRandGenerationFunctions.testFunctions2#Output.IgnoreWhitespace# +#set.seed(1); rnbinom(24, c(0.0653, 0.000123, 32e-80, 8833, 79e70), c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1)) + [1] 0 0 0 NA NA NA NA 0 + [9] 71098679 NA NA NA NA NA NA 0 +[17] 0 NA NA NA NA 0 0 NA +Warning message: +In rnbinom(24, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71), c(0.0653, : + NAs produced + +##com.oracle.truffle.r.test.library.stats.TestRandGenerationFunctions.testFunctions2#Output.IgnoreWhitespace# +#set.seed(1); rnbinom(30, c(NA, 0, NaN, 1/0, -1/0), c(NaN, NaN, NA, 0, 1/0, -1/0)) + [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA +[26] NA NA NA NA NA +Warning message: +In rnbinom(30, c(NA, 0, NaN, 1/0, -1/0), c(NaN, NaN, NA, 0, 1/0, : + NAs produced + ##com.oracle.truffle.r.test.library.stats.TestRandGenerationFunctions.testFunctions2#Output.IgnoreWhitespace# #set.seed(1); rnorm(10, 10, 10) [1] 3.735462 11.836433 1.643714 25.952808 13.295078 1.795316 14.874291 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 60da23630a..75b3c9db33 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -128,6 +128,16 @@ public class TestDistributions extends TestBase { test("10000, 0.01", withQuantiles("1", "10", "100", "500", "900", "1000")). // non-probability value is error for the second parameter test("10, -0.1", withQuantiles("2")). + test("10, 5", withQuantiles("2")), + distr("nbinom"). + addErrorParamValues("-2"). + test("10, 0.33", withDefaultQ("5", "10", "11", "13", "20")). + test("10.3, 0.4", withQuantiles("5", "10", "11", "13", "20")). + test("1000, 0.5", withQuantiles("0", "10", "100", "1000", "1100", "1200")). + test("1000, mu=10", withDefaultQ("5", "6", "10", "11", "20", "100")). + 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")) }; // @formatter:on diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestExternal_rnbinom.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestExternal_rnbinom.java index 1da7643316..9ce75cb254 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestExternal_rnbinom.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestExternal_rnbinom.java @@ -31,7 +31,6 @@ public class TestExternal_rnbinom extends TestBase { @Test public void testRbinomWithMu() { assertEval("set.seed(42); rnbinom(5, 1, mu=2)"); - // TODO: maybe problem with state variables, see RNbinomMu - assertEval(Ignored.Unstable, "set.seed(42); rnbinom(100, c(-1, 0, 1, 0.8, 10, NA, NaN, 1/0, -1/0), mu=c(-1, 0, 1, 0.8, 3, 10, NA, NaN, 1/0, -1/0))"); + assertEval(Output.IgnoreWarningContext, "set.seed(42); rnbinom(100, c(-1, 0, 1, 0.8, 10, NA, NaN, 1/0, -1/0), mu=c(-1, 0, 1, 0.8, 3, 10, NA, NaN, 1/0, -1/0))"); } } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestRandGenerationFunctions.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestRandGenerationFunctions.java index 6a6b175ea8..e177706ddf 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestRandGenerationFunctions.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestRandGenerationFunctions.java @@ -31,7 +31,7 @@ import com.oracle.truffle.r.test.TestBase; * tests for its specific corner cases if those are not covered here. */ public class TestRandGenerationFunctions extends TestBase { - private static final String[] FUNCTION2_NAMES = {"rnorm", "runif", "rgamma", "rbeta", "rcauchy", "rf", "rlogis", "rweibull", "rchisq", "rwilcox", "rlnorm"}; + private static final String[] FUNCTION2_NAMES = {"rnorm", "runif", "rgamma", "rbeta", "rcauchy", "rf", "rlogis", "rweibull", "rchisq", "rwilcox", "rlnorm", "rnbinom"}; private static final String[] FUNCTION2_PARAMS = { "10, 10, 10", "20, c(-1, 0, 0.2, 2:5), c(-1, 0, 0.1, 0.9, 3)", diff --git a/mx.fastr/copyrights/overrides b/mx.fastr/copyrights/overrides index 53a014c748..eaa67587a1 100644 --- a/mx.fastr/copyrights/overrides +++ b/mx.fastr/copyrights/overrides @@ -39,6 +39,9 @@ com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Covcor.java, com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Cutree.java,gnu_r.core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Signrank.java,gnu_r.core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Dbinom.java,gnu_r.copyright +com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNBinom.java,gnu_r_ihaka_core.copyright +com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/PNBinom.java,gnu_r_ihaka_core.copyright +com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/DNBinom.java,gnu_r.core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/DoubleCentre.java,gnu_r.core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/DPQ.java,gnu_r.core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Rt.java,gnu_r_ihaka_core.copyright @@ -80,6 +83,7 @@ com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/StatsFunctio com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RandGenerationFunctions.java,gnu_r_gentleman_ihaka.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RMath.java,gnu_r_ihaka.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QuantileSearch.java,gnu_r_ihaka.copyright +com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QNBinom.java,gnu_r_ihaka.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RMathError.java,gnu_r.core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/LogNormal.java,gnu_r_ihaka.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/MathConstants.java,gnu_r_ihaka.copyright @@ -88,7 +92,6 @@ com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/SNorm.java,g com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/SExp.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RGamma.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/PGamma.java,gnu_r_welinder.copyright -com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNbinomMu.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Logis.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Pnf.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Rf.java,gnu_r_ihaka_core.copyright diff --git a/testScript.R b/testScript.R new file mode 100644 index 0000000000..7237eba327 --- /dev/null +++ b/testScript.R @@ -0,0 +1,2 @@ +x<-c(1) +cat(x) -- GitLab