diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/SignrankFreeNode.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/SignrankFreeNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..9a49e74cee80eb6453451ebcb88800a8aa3045ca
--- /dev/null
+++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/SignrankFreeNode.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.r.library.stats;
+
+import com.oracle.truffle.r.nodes.builtin.RExternalBuiltinNode;
+import com.oracle.truffle.r.runtime.data.RNull;
+import com.oracle.truffle.r.runtime.nmath.distr.Signrank.SignrankData;
+
+public final class SignrankFreeNode extends RExternalBuiltinNode.Arg0 {
+    @Override
+    public Object execute() {
+        SignrankData.freeData();
+        return RNull.instance;
+    }
+}
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 26cbf2838b662e95123e0e2e50840bcce2c20224..1c9a963a3b3d7295ea6b767315e95187e9db7072 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
@@ -50,6 +50,7 @@ import com.oracle.truffle.r.library.stats.RandFunctionsNodes;
 import com.oracle.truffle.r.library.stats.RandFunctionsNodes.RandFunction1Node;
 import com.oracle.truffle.r.library.stats.RandFunctionsNodes.RandFunction2Node;
 import com.oracle.truffle.r.library.stats.RandFunctionsNodes.RandFunction3Node;
+import com.oracle.truffle.r.library.stats.SignrankFreeNode;
 import com.oracle.truffle.r.library.stats.SplineFunctionsFactory.SplineCoefNodeGen;
 import com.oracle.truffle.r.library.stats.SplineFunctionsFactory.SplineEvalNodeGen;
 import com.oracle.truffle.r.library.stats.StatsFunctionsNodes;
@@ -103,6 +104,7 @@ import com.oracle.truffle.r.runtime.nmath.distr.DPois;
 import com.oracle.truffle.r.runtime.nmath.distr.Dbinom;
 import com.oracle.truffle.r.runtime.nmath.distr.Df;
 import com.oracle.truffle.r.runtime.nmath.distr.Dnf;
+import com.oracle.truffle.r.runtime.nmath.distr.Dnt;
 import com.oracle.truffle.r.runtime.nmath.distr.Dt;
 import com.oracle.truffle.r.runtime.nmath.distr.Exp.DExp;
 import com.oracle.truffle.r.runtime.nmath.distr.Exp.PExp;
@@ -125,11 +127,13 @@ import com.oracle.truffle.r.runtime.nmath.distr.PNBinom.PNBinomFunc;
 import com.oracle.truffle.r.runtime.nmath.distr.PNBinom.PNBinomMu;
 import com.oracle.truffle.r.runtime.nmath.distr.PNChisq;
 import com.oracle.truffle.r.runtime.nmath.distr.PPois;
+import com.oracle.truffle.r.runtime.nmath.distr.PTukey;
 import com.oracle.truffle.r.runtime.nmath.distr.Pbeta;
 import com.oracle.truffle.r.runtime.nmath.distr.Pbinom;
 import com.oracle.truffle.r.runtime.nmath.distr.Pf;
 import com.oracle.truffle.r.runtime.nmath.distr.Pnf;
 import com.oracle.truffle.r.runtime.nmath.distr.Pnorm;
+import com.oracle.truffle.r.runtime.nmath.distr.Pnt;
 import com.oracle.truffle.r.runtime.nmath.distr.Pt;
 import com.oracle.truffle.r.runtime.nmath.distr.QBeta;
 import com.oracle.truffle.r.runtime.nmath.distr.QGamma;
@@ -139,10 +143,12 @@ import com.oracle.truffle.r.runtime.nmath.distr.QNBinom.QNBinomFunc;
 import com.oracle.truffle.r.runtime.nmath.distr.QNBinom.QNBinomMu;
 import com.oracle.truffle.r.runtime.nmath.distr.QNChisq;
 import com.oracle.truffle.r.runtime.nmath.distr.QPois;
+import com.oracle.truffle.r.runtime.nmath.distr.QTukey;
 import com.oracle.truffle.r.runtime.nmath.distr.Qbinom;
 import com.oracle.truffle.r.runtime.nmath.distr.Qf;
 import com.oracle.truffle.r.runtime.nmath.distr.Qnf;
 import com.oracle.truffle.r.runtime.nmath.distr.Qnorm;
+import com.oracle.truffle.r.runtime.nmath.distr.Qnt;
 import com.oracle.truffle.r.runtime.nmath.distr.Qt;
 import com.oracle.truffle.r.runtime.nmath.distr.RBeta;
 import com.oracle.truffle.r.runtime.nmath.distr.RGamma;
@@ -155,6 +161,9 @@ import com.oracle.truffle.r.runtime.nmath.distr.Rbinom;
 import com.oracle.truffle.r.runtime.nmath.distr.Rf;
 import com.oracle.truffle.r.runtime.nmath.distr.Rnorm;
 import com.oracle.truffle.r.runtime.nmath.distr.Rt;
+import com.oracle.truffle.r.runtime.nmath.distr.Signrank.DSignrank;
+import com.oracle.truffle.r.runtime.nmath.distr.Signrank.PSignrank;
+import com.oracle.truffle.r.runtime.nmath.distr.Signrank.QSignrank;
 import com.oracle.truffle.r.runtime.nmath.distr.Signrank.RSignrank;
 import com.oracle.truffle.r.runtime.nmath.distr.Unif.DUnif;
 import com.oracle.truffle.r.runtime.nmath.distr.Unif.PUnif;
@@ -457,6 +466,22 @@ public class CallAndExternalFunctions {
                     return StatsFunctionsNodes.Function3_2Node.create(new PWilcox());
                 case "dwilcox":
                     return StatsFunctionsNodes.Function3_1Node.create(new DWilcox());
+                case "dsignrank":
+                    return StatsFunctionsNodes.Function2_1Node.create(new DSignrank());
+                case "psignrank":
+                    return StatsFunctionsNodes.Function2_2Node.create(new PSignrank());
+                case "dnt":
+                    return StatsFunctionsNodes.Function3_1Node.create(new Dnt());
+                case "pnt":
+                    return StatsFunctionsNodes.Function3_2Node.create(new Pnt());
+                case "qnt":
+                    return StatsFunctionsNodes.Function3_2Node.create(new Qnt());
+                case "qsignrank":
+                    return StatsFunctionsNodes.Function2_2Node.create(new QSignrank());
+                case "qtukey":
+                    return StatsFunctionsNodes.Function4_2Node.create(new QTukey());
+                case "ptukey":
+                    return StatsFunctionsNodes.Function4_2Node.create(new PTukey());
                 case "rmultinom":
                     return RMultinomNode.create();
                 case "Approx":
@@ -710,6 +735,8 @@ public class CallAndExternalFunctions {
                     return RprofmemNodeGen.create();
                 case "wilcox_free":
                     return new WilcoxFreeNode();
+                case "signrank_free":
+                    return new SignrankFreeNode();
                 case "unzip":
                 case "addhistory":
                 case "loadhistory":
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java
index 59bf703f0708ea61942afac7864152e9ec33b8cd..3c1af498acfa2ae64a12b6e4312cf2c122717b6e 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java
@@ -466,7 +466,7 @@ public final class RError extends RuntimeException {
         UNUSED_ARGUMENT("unused argument (%s)"),
         UNUSED_ARGUMENTS("unused arguments (%s)"),
         INFINITE_MISSING_VALUES("infinite or missing values in '%s'"),
-        CALLOC_COULD_NOT_ALLOCATE_INF("'Calloc' could not allocate memory (18446744071562067968 of 4 bytes)"),
+        CALLOC_COULD_NOT_ALLOCATE("'Calloc' could not allocate memory (%s of %d bytes)"),
         NON_SQUARE_MATRIX("non-square matrix in '%s'"),
         LAPACK_ERROR("error code %d from Lapack routine '%s'"),
         VALUE_OUT_OF_RANGE("value out of range in '%s'"),
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Dnt.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Dnt.java
new file mode 100644
index 0000000000000000000000000000000000000000..9a8731981dd91ac6dc3435074c8e7df2e82fb755
--- /dev/null
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Dnt.java
@@ -0,0 +1,75 @@
+/*
+ * 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) 2003-2015, The R Foundation
+ * Copyright (c) 2017, Oracle and/or its affiliates
+ *
+ * All rights reserved.
+ */
+/*
+ *  AUTHOR
+ *    Claus Ekstrøm, ekstrom@dina.kvl.dk
+ *    July 15, 2003.
+ */
+package com.oracle.truffle.r.runtime.nmath.distr;
+
+import static com.oracle.truffle.r.runtime.nmath.GammaFunctions.lgammafn;
+import static com.oracle.truffle.r.runtime.nmath.MathConstants.DBL_EPSILON;
+import static com.oracle.truffle.r.runtime.nmath.MathConstants.M_LN_SQRT_PI;
+
+import com.oracle.truffle.r.runtime.nmath.DPQ;
+import com.oracle.truffle.r.runtime.nmath.MathFunctions.Function3_1;
+import com.oracle.truffle.r.runtime.nmath.RMathError;
+import com.oracle.truffle.r.runtime.nmath.TOMS708;
+
+public final class Dnt implements Function3_1 {
+    private final Dt dt = new Dt();
+    private final DNorm dnorm = new DNorm();
+    private final Pnt pnt = new Pnt();
+
+    @Override
+    public double evaluate(double x, double df, double ncp, boolean giveLog) {
+        if (Double.isNaN(x) || Double.isNaN(df)) {
+            return x + df;
+        }
+
+        /* If non-positive df then error */
+        if (df <= 0.0) {
+            return RMathError.defaultError();
+        }
+
+        if (ncp == 0.0) {
+            return dt.evaluate(x, df, giveLog);
+        }
+
+        /* If x is infinite then return 0 */
+        if (!Double.isFinite(x)) {
+            return DPQ.rd0(giveLog);
+        }
+
+        /*
+         * If infinite df then the density is identical to a normal distribution with mean = ncp.
+         * However, the formula loses a lot of accuracy around df=1e9
+         */
+        if (!Double.isFinite(df) || df > 1e8) {
+            return dnorm.evaluate(x, ncp, 1., giveLog);
+        }
+
+        /* Do calculations on log scale to stabilize */
+
+        /* Consider two cases: x ~= 0 or not */
+        double u;
+        if (TOMS708.fabs(x) > Math.sqrt(df * DBL_EPSILON)) {
+            u = Math.log(df) - Math.log(TOMS708.fabs(x)) +
+                            Math.log(TOMS708.fabs(pnt.evaluate(x * Math.sqrt((df + 2) / df), df + 2, ncp, true, false) -
+                                            pnt.evaluate(x, df, ncp, true, false)));
+            /* GnuR fix me: the above still suffers from cancellation (but not horribly) */
+        } else { /* x ~= 0 : -> same value as for x = 0 */
+            u = lgammafn((df + 1) / 2) - lgammafn(df / 2) - (M_LN_SQRT_PI + .5 * (Math.log(df) + ncp * ncp));
+        }
+
+        return (giveLog ? u : Math.exp(u));
+    }
+}
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/PTukey.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/PTukey.java
new file mode 100644
index 0000000000000000000000000000000000000000..b238d42c7797c61d15ddc7e2ed17462e60c460e2
--- /dev/null
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/PTukey.java
@@ -0,0 +1,310 @@
+/*
+ * 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--2007, The R Core Team
+ * Copyright (c) 2017, Oracle and/or its affiliates
+ *
+ * All rights reserved.
+ */
+package com.oracle.truffle.r.runtime.nmath.distr;
+
+import static com.oracle.truffle.r.runtime.nmath.GammaFunctions.lgammafn;
+import static com.oracle.truffle.r.runtime.nmath.MathConstants.M_1_SQRT_2PI;
+import static com.oracle.truffle.r.runtime.nmath.MathConstants.M_LN2;
+
+import com.oracle.truffle.r.runtime.nmath.DPQ;
+import com.oracle.truffle.r.runtime.nmath.MathFunctions.Function4_2;
+import com.oracle.truffle.r.runtime.nmath.RMathError;
+import com.oracle.truffle.r.runtime.nmath.RMathError.MLError;
+
+public class PTukey implements Function4_2 {
+    private static final int nlegq = 16;
+    private static final int ihalfq = 8;
+    private static final int nleg = 12;
+    private static final int ihalf = 6;
+    private static final double eps1 = -30.0;
+    private static final double eps2 = 1.0e-14;
+    private static final double dhaf = 100.0;
+    private static final double dquar = 800.0;
+    private static final double deigh = 5000.0;
+    private static final double dlarg = 25000.0;
+    private static final double ulen1 = 1.0;
+    private static final double ulen2 = 0.5;
+    private static final double ulen3 = 0.25;
+    private static final double ulen4 = 0.125;
+    private static final double[] xlegq = {
+                    0.989400934991649932596154173450,
+                    0.944575023073232576077988415535,
+                    0.865631202387831743880467897712,
+                    0.755404408355003033895101194847,
+                    0.617876244402643748446671764049,
+                    0.458016777657227386342419442984,
+                    0.281603550779258913230460501460,
+                    0.950125098376374401853193354250e-1
+    };
+    private static final double[] alegq = {
+                    0.271524594117540948517805724560e-1,
+                    0.622535239386478928628438369944e-1,
+                    0.951585116824927848099251076022e-1,
+                    0.124628971255533872052476282192,
+                    0.149595988816576732081501730547,
+                    0.169156519395002538189312079030,
+                    0.182603415044923588866763667969,
+                    0.189450610455068496285396723208
+    };
+
+    private final Pnorm pnorm = new Pnorm();
+
+    @Override
+    public double evaluate(double q, double rr, double cc, double df, boolean lowerTail, boolean logP) {
+        if (Double.isNaN(q) || Double.isNaN(rr) || Double.isNaN(cc) || Double.isNaN(df)) {
+            return RMathError.defaultError();
+        }
+
+        if (q <= 0) {
+            return DPQ.rdt0(lowerTail, logP);
+        }
+
+        /* df must be > 1 */
+        /* there must be at least two values */
+
+        if (df < 2 || rr < 1 || cc < 2) {
+            return RMathError.defaultError();
+        }
+
+        if (!Double.isFinite(q)) {
+            return DPQ.rdt1(lowerTail, logP);
+        }
+
+        if (df > dlarg) {
+            return DPQ.rdtval(wprob(q, rr, cc), lowerTail, logP);
+        }
+
+        /* calculate leading constant */
+
+        double f2 = df * 0.5;
+        /* lgammafn(u) = Math.log(gamma(u)) */
+        double f2lf = ((f2 * Math.log(df)) - (df * M_LN2)) - lgammafn(f2);
+        double f21 = f2 - 1.0;
+
+        /* integral is divided into unit, half-unit, quarter-unit, or */
+        /* eighth-unit length intervals depending on the value of the */
+        /* degrees of freedom. */
+
+        double ff4 = df * 0.25;
+        double ulen = getULen(df);
+        f2lf += Math.log(ulen);
+
+        /* integrate over each subinterval */
+        double ans = 0.0;
+
+        double otsum = 0.0;
+        for (int i = 1; i <= 50; i++) {
+            otsum = 0.0;
+
+            /* legendre quadrature with order = nlegq */
+            /* nodes (stored in xlegq) are symmetric around zero. */
+
+            double twa1 = (2 * i - 1) * ulen;
+
+            for (int jj = 1; jj <= nlegq; jj++) {
+                int j;
+                double t1;
+                if (ihalfq < jj) {
+                    j = jj - ihalfq - 1;
+                    t1 = (f2lf + (f21 * Math.log(twa1 + (xlegq[j] * ulen)))) - (((xlegq[j] * ulen) + twa1) * ff4);
+                } else {
+                    j = jj - 1;
+                    t1 = (f2lf + (f21 * Math.log(twa1 - (xlegq[j] * ulen)))) + (((xlegq[j] * ulen) - twa1) * ff4);
+
+                }
+
+                /* if Math.exp(t1) < 9e-14, then doesn't contribute to integral */
+                if (t1 >= eps1) {
+                    double qsqz;
+                    if (ihalfq < jj) {
+                        qsqz = q * Math.sqrt(((xlegq[j] * ulen) + twa1) * 0.5);
+                    } else {
+                        qsqz = q * Math.sqrt(((-(xlegq[j] * ulen)) + twa1) * 0.5);
+                    }
+
+                    /* call wprob to find integral of range portion */
+
+                    double wprb = wprob(qsqz, rr, cc);
+                    double rotsum = (wprb * alegq[j]) * Math.exp(t1);
+                    otsum += rotsum;
+                }
+                /* end legendre integral for interval i */
+                /* L200: */
+            }
+
+            /*
+             * if integral for interval i < 1e-14, then stop. However, in order to avoid small area
+             * under left tail, at least 1 / ulen intervals are calculated.
+             */
+            if (i * ulen >= 1.0 && otsum <= eps2) {
+                break;
+            }
+
+            /* end of interval i */
+            /* L330: */
+
+            ans += otsum;
+        }
+
+        if (otsum > eps2) { /* not converged */
+            RMathError.error(MLError.PRECISION, "ptukey");
+        }
+        if (ans > 1.) {
+            ans = 1.;
+        }
+        return DPQ.rdtval(ans, lowerTail, logP);
+    }
+
+    private double getULen(double df) {
+        if (df <= dhaf) {
+            return ulen1;
+        } else if (df <= dquar) {
+            return ulen2;
+        } else if (df <= deigh) {
+            return ulen3;
+        }
+        return ulen4;
+    }
+
+    private static final double C1 = -30.;
+    private static final double C2 = -50.;
+    private static final double C3 = 60.;
+    private static final double bb = 8.;
+    private static final double wlar = 3.;
+    private static final double wincr1 = 2.;
+    private static final double wincr2 = 3.;
+    private static final double[] xleg = {
+                    0.981560634246719250690549090149,
+                    0.904117256370474856678465866119,
+                    0.769902674194304687036893833213,
+                    0.587317954286617447296702418941,
+                    0.367831498998180193752691536644,
+                    0.125233408511468915472441369464
+    };
+    private static final double[] aleg = {
+                    0.047175336386511827194615961485,
+                    0.106939325995318430960254718194,
+                    0.160078328543346226334652529543,
+                    0.203167426723065921749064455810,
+                    0.233492536538354808760849898925,
+                    0.249147045813402785000562436043
+    };
+
+    private double wprob(double w, double rr, double cc) {
+        // double a, ac, prW, b, binc, c, cc1,
+        // pminus, pplus, qexpo, qsqz, rinsum, wi, wincr, xx;
+        // LDOUBLE blb, bub, einsum, elsum;
+        // int j, jj;
+
+        double qsqz = w * 0.5;
+
+        /* if w >= 16 then the integral lower bound (occurs for c=20) */
+        /* is 0.99999999999995 so return a value of 1. */
+
+        if (qsqz >= bb) {
+            return 1.0;
+        }
+
+        /* find (f(w/2) - 1) ^ cc */
+        /* (first term in integral of hartley's form). */
+
+        double prW = 2 * pnorm.evaluate(qsqz, 0., 1., true, false) - 1.; /* erf(qsqz / M_SQRT2) */
+        /* if prW ^ cc < 2e-22 then set prW = 0 */
+        if (prW >= Math.exp(C2 / cc)) {
+            prW = Math.pow(prW, cc);
+        } else {
+            prW = 0.0;
+        }
+
+        /* if w is large then the second component of the */
+        /* integral is small, so fewer intervals are needed. */
+
+        double wincr = w > wlar ? wincr1 : wincr2;
+
+        /* find the integral of second term of hartley's form */
+        /* for the integral of the range for equal-length */
+        /* intervals using legendre quadrature. limits of */
+        /* integration are from (w/2, 8). two or three */
+        /* equal-length intervals are used. */
+
+        /* blb and bub are lower and upper limits of integration. */
+
+        /* LDOUBLE */double blb = qsqz;
+        double binc = (bb - qsqz) / wincr;
+        /* LDOUBLE */double bub = blb + binc;
+        /* LDOUBLE */double einsum = 0.0;
+
+        /* integrate over each interval */
+
+        double cc1 = cc - 1.0;
+        for (double wi = 1; wi <= wincr; wi++) {
+            /* LDOUBLE */double elsum = 0.0;
+            double a = 0.5 * (bub + blb);
+
+            /* legendre quadrature with order = nleg */
+
+            double b = 0.5 * (bub - blb);
+
+            for (int jj = 1; jj <= nleg; jj++) {
+                double xx;
+                int j;
+                if (ihalf < jj) {
+                    j = (nleg - jj) + 1;
+                    xx = xleg[j - 1];
+                } else {
+                    j = jj;
+                    xx = -xleg[j - 1];
+                }
+                double c = b * xx;
+                double ac = a + c;
+
+                /* if Math.exp(-qexpo/2) < 9e-14, */
+                /* then doesn't contribute to integral */
+
+                double qexpo = ac * ac;
+                if (qexpo > C3) {
+                    break;
+                }
+
+                double pplus = 2 * pnorm.evaluate(ac, 0., 1., true, false);
+                double pminus = 2 * pnorm.evaluate(ac, w, 1., true, false);
+
+                /* if rinsum ^ (cc-1) < 9e-14, */
+                /* then doesn't contribute to integral */
+
+                double rinsum = (pplus * 0.5) - (pminus * 0.5);
+                if (rinsum >= Math.exp(C1 / cc1)) {
+                    rinsum = (aleg[j - 1] * Math.exp(-(0.5 * qexpo))) * Math.pow(rinsum, cc1);
+                    elsum += rinsum;
+                }
+            }
+            elsum *= (((2.0 * b) * cc) * M_1_SQRT_2PI);
+            einsum += elsum;
+            blb = bub;
+            bub += binc;
+        }
+
+        /* if prW ^ rr < 9e-14, then return 0 */
+        prW += einsum;
+        if (prW <= Math.exp(C1 / rr)) {
+            return 0.;
+        }
+
+        prW = Math.pow(prW, rr);
+        if (prW >= 1.) {
+            /* 1 was iMax was eps */
+            return 1.;
+        }
+
+        return prW;
+    }
+}
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Pnt.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Pnt.java
new file mode 100644
index 0000000000000000000000000000000000000000..d1dc11c6b66f59cb090de6964a06a1a3e48c7cf3
--- /dev/null
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Pnt.java
@@ -0,0 +1,174 @@
+/*
+ * 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-2015, The R Core Team
+ * Copyright (c) 2017, Oracle and/or its affiliates
+ *
+ * All rights reserved.
+ */
+/*
+ *  based on AS243 (C) 1989 Royal Statistical Society
+ */
+package com.oracle.truffle.r.runtime.nmath.distr;
+
+import static com.oracle.truffle.r.runtime.nmath.GammaFunctions.lgammafn;
+import static com.oracle.truffle.r.runtime.nmath.MathConstants.DBL_EPSILON;
+import static com.oracle.truffle.r.runtime.nmath.MathConstants.DBL_MIN_EXP;
+import static com.oracle.truffle.r.runtime.nmath.MathConstants.M_LN2;
+import static com.oracle.truffle.r.runtime.nmath.MathConstants.M_LN_SQRT_PI;
+import static com.oracle.truffle.r.runtime.nmath.MathConstants.M_SQRT_2dPI;
+
+import com.oracle.truffle.r.runtime.nmath.DPQ;
+import com.oracle.truffle.r.runtime.nmath.MathFunctions.Function3_2;
+import com.oracle.truffle.r.runtime.nmath.RMath;
+import com.oracle.truffle.r.runtime.nmath.RMathError;
+import com.oracle.truffle.r.runtime.nmath.RMathError.MLError;
+import com.oracle.truffle.r.runtime.nmath.TOMS708;
+
+public class Pnt implements Function3_2 {
+    private static final int itrmax = 1000;
+    private static final double errmax = 1.e-12;
+
+    private final Pt pt = new Pt();
+    private final Pnorm pnorm = new Pnorm();
+    private final Pbeta pbeta = new Pbeta();
+
+    @Override
+    public double evaluate(double t, double df, double ncp, boolean lowerTail, boolean logP) {
+        if (df <= 0.0) {
+            return RMathError.defaultError();
+        }
+        if (ncp == 0.0) {
+            return pt.evaluate(t, df, lowerTail, logP);
+        }
+
+        if (!Double.isFinite(t)) {
+            return t < 0 ? DPQ.rdt0(lowerTail, logP) : DPQ.rdt1(lowerTail, logP);
+        }
+
+        boolean negdel;
+        double tt;
+        double del;
+        if (t >= 0.) {
+            negdel = false;
+            tt = t;
+            del = ncp;
+        } else {
+            /*
+             * We deal quickly with left tail if extreme, since pt(q, df, ncp) <= pt(0, df, ncp) =
+             * \Phi(-ncp)
+             */
+            if (ncp > 40 && (!logP || !lowerTail)) {
+                return DPQ.rdt0(lowerTail, logP);
+            }
+            negdel = true;
+            tt = -t;
+            del = -ncp;
+        }
+
+        /* LDOUBLE */double s;
+        if (df > 4e5 || del * del > 2 * M_LN2 * (-DBL_MIN_EXP)) {
+            /*-- 2nd part: if del > 37.62, then p=0 below
+              GnuR fix me: test should depend on `df', `tt' AND `del' ! */
+            /* Approx. from Abramowitz & Stegun 26.7.10 (p.949) */
+            s = 1. / (4. * df);
+            double pnormSigma = Math.sqrt(1. + tt * tt * 2. * s);
+            return pnorm.evaluate(tt * (1. - s), del, pnormSigma, lowerTail != negdel, logP);
+        }
+
+        /* initialize twin series */
+        /* Guenther, J. (1978). Statist. Computn. Simuln. vol.6, 199. */
+
+        double x = t * t;
+        double rxb = df / (x + df); /* := (1 - x) {x below} -- but more accurately */
+        x = x / (x + df); /* in [0,1) */
+        debugPrintf("pnt(t=%7g, df=%7g, ncp=%7g) ==> x= %10g:", t, df, ncp, x);
+        if (x <= 0.) {
+            return finish(0., del, negdel, lowerTail, logP);
+        }
+
+        /* LDOUBLE */double tnc;
+        /* else x > 0. <==> t != 0 */
+        double lambda = del * del;
+        /* LDOUBLE */double p = .5 * Math.exp(-.5 * lambda);
+        debugPrintf("\t p=%10Lg\n", p);
+
+        if (p == 0.) { /* underflow! */
+            /// GnuR note: really use an other algorithm for this case
+            RMathError.error(MLError.UNDERFLOW, "pnt");
+            RMathError.error(MLError.RANGE, "pnt"); /* |ncp| too large */
+            return DPQ.rdt0(lowerTail, logP);
+        }
+
+        debugPrintf("it  1e5*(godd,   geven)|          p           q           s        pnt(*)     errbd\n");
+
+        /* LDOUBLE */double q = M_SQRT_2dPI * p * del;
+        s = .5 - p;
+        /* s = 0.5 - p = 0.5*(1 - Math.exp(-.5 L)) = -0.5*expm1(-.5 L)) */
+        if (s < 1e-7) {
+            s = -0.5 * RMath.expm1(-0.5 * lambda);
+        }
+        double a = .5;
+        double b = .5 * df;
+        /*
+         * rxb = (1 - x) ^ b [ ~= 1 - b*x for tiny x --> see 'xeven' below] where '(1 - x)' =: rxb
+         * {accurately!} above
+         */
+        rxb = Math.pow(rxb, b);
+        double albeta = M_LN_SQRT_PI + lgammafn(b) - lgammafn(.5 + b);
+        /* LDOUBLE */double xodd = pbeta.evaluate(x, a, b, /* lower */true, /* logP */false);
+        /* LDOUBLE */double godd = 2. * rxb * Math.exp(a * Math.log(x) - albeta);
+        tnc = b * x;
+        /* LDOUBLE */double xeven = (tnc < DBL_EPSILON) ? tnc : 1. - rxb;
+        /* LDOUBLE */double geven = tnc * rxb;
+        tnc = p * xodd + q * xeven;
+
+        /* repeat until convergence or iteration limit */
+        for (int it = 1; it <= itrmax; it++) {
+            a += 1.;
+            xodd -= godd;
+            xeven -= geven;
+            godd *= x * (a + b - 1.) / a;
+            geven *= x * (a + b - .5) / (a + .5);
+            p *= lambda / (2 * it);
+            q *= lambda / (2 * it + 1);
+            tnc += p * xodd + q * xeven;
+            s -= p;
+            /* R 2.4.0 added test for rounding error here. */
+            if (s < -1.e-10) { /* happens e.g. for (t,df,ncp)=(40,10,38.5), after 799 it. */
+                RMathError.error(MLError.PRECISION, "pnt");
+                debugPrintf("s = %#14.7Lg < 0 !!! ---> non-convergence!!\n", s);
+                return finish(tnc, del, negdel, lowerTail, logP);
+            }
+            if (s <= 0 && it > 1) {
+                return finish(tnc, del, negdel, lowerTail, logP);
+            }
+            double errbd = 2. * s * (xodd - godd);
+            debugPrintf("%3d %.4g %.4g|%.4Lg %.4g %.4g %.10g %.4g\n",
+                            it, 1e5 * godd, 1e5 * geven, p, q, s, tnc, errbd);
+            if (TOMS708.fabs(errbd) < errmax) {
+                return finish(tnc, del, negdel, lowerTail, logP); /* convergence */
+            }
+        }
+        /* non-convergence: */
+        RMathError.error(MLError.NOCONV, "pnt");
+        return finish(tnc, del, negdel, lowerTail, logP);
+    }
+
+    private double finish(double tncIn, double del, boolean negdel, boolean lowerTailIn, boolean logP) {
+        /* LDOUBLE */double tnc = tncIn + pnorm.evaluate(-del, 0., 1., /* lower */true, /* logP */false);
+
+        boolean lowerTail = lowerTailIn != negdel; /* xor */
+        if (tnc > 1 - 1e-10 && lowerTail) {
+            RMathError.error(MLError.PRECISION, "pnt{final}");
+        }
+        return DPQ.rdtval(RMath.fmin2(tnc, 1.) /* Precaution */, lowerTail, logP);
+    }
+
+    @SuppressWarnings("unused")
+    private void debugPrintf(String fmt, Object... args) {
+        // System.out.printf(fmt + "\n", args);
+    }
+}
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/QTukey.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/QTukey.java
new file mode 100644
index 0000000000000000000000000000000000000000..dbd69d4df5a607bae641b51e7d8e63f107e39b39
--- /dev/null
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/QTukey.java
@@ -0,0 +1,155 @@
+/*
+ * 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--2005, The R Core Team
+ * Copyright (c) 2017, Oracle and/or its affiliates
+ *
+ * All rights reserved.
+ */
+/*
+ *  based in part on AS70 (C) 1974 Royal Statistical Society
+ */
+package com.oracle.truffle.r.runtime.nmath.distr;
+
+import com.oracle.truffle.r.runtime.nmath.DPQ;
+import com.oracle.truffle.r.runtime.nmath.DPQ.EarlyReturn;
+import com.oracle.truffle.r.runtime.nmath.MathFunctions.Function4_2;
+import com.oracle.truffle.r.runtime.nmath.RMath;
+import com.oracle.truffle.r.runtime.nmath.RMathError;
+import com.oracle.truffle.r.runtime.nmath.RMathError.MLError;
+import com.oracle.truffle.r.runtime.nmath.TOMS708;
+
+/*
+ *  Copenhaver, Margaret Diponzio & Holland, Burt S.
+ *  Multiple comparisons of simple effects in
+ *  the two-way analysis of variance with fixed effects.
+ *  Journal of Statistical Computation and Simulation,
+ *  Vol.30, pp.1-15, 1988.
+ *
+ *  Uses the secant method to find critical values.
+ *
+ *  p = confidence level (1 - alpha)
+ *  rr = no. of rows or groups
+ *  cc = no. of columns or treatments
+ *  df = degrees of freedom of error term
+ *
+ *  ir(1) = error flag = 1 if wprob probability > 1
+ *  ir(2) = error flag = 1 if ptukey probability > 1
+ *  ir(3) = error flag = 1 if convergence not reached in 50 iterations
+ *       = 2 if df < 2
+ *
+ *  qtukey = returned critical value
+ *
+ *  If the difference between successive iterates is less than eps,
+ *  the search is terminated
+ */
+
+public final class QTukey implements Function4_2 {
+    private static final double eps = 0.0001;
+    private static final int maxiter = 50;
+
+    private final PTukey ptukey = new PTukey();
+
+    @Override
+    public double evaluate(double pIn, double rr, double cc, double df, boolean lowerTail, boolean logP) {
+        if (Double.isNaN(pIn) || Double.isNaN(rr) || Double.isNaN(cc) || Double.isNaN(df)) {
+            RMathError.error(MLError.DOMAIN, "qtukey");
+            return pIn + rr + cc + df;
+        }
+
+        /* df must be > 1 ; there must be at least two values */
+        if (df < 2 || rr < 1 || cc < 2) {
+            return RMathError.defaultError();
+        }
+
+        try {
+            DPQ.rqp01boundaries(pIn, 0, Double.POSITIVE_INFINITY, lowerTail, logP);
+        } catch (EarlyReturn e) {
+            return e.result;
+        }
+
+        double p = DPQ.rdtqiv(pIn, lowerTail, logP); /* lowerTail,non-log "p" */
+
+        /* Initial value */
+
+        double x0 = qinv(p, cc, df);
+
+        /* Find prob(value < x0) */
+
+        double valx0 = ptukey.evaluate(x0, rr, cc, df, /* LOWER */true, /* LOG_P */false) - p;
+
+        /* Find the second iterate and prob(value < x1). */
+        /* If the first iterate has probability value */
+        /* exceeding p then second iterate is 1 less than */
+        /* first iterate; otherwise it is 1 greater. */
+
+        double x1 = valx0 > 0.0 ? RMath.fmax2(0.0, x0 - 1.0) : x0 + 1.0;
+        double valx1 = ptukey.evaluate(x1, rr, cc, df, /* LOWER */true, /* LOG_P */false) - p;
+
+        /* Find new iterate */
+
+        double ans = 0.;
+        for (int iter = 1; iter < maxiter; iter++) {
+            ans = x1 - ((valx1 * (x1 - x0)) / (valx1 - valx0));
+            valx0 = valx1;
+
+            /* New iterate must be >= 0 */
+
+            x0 = x1;
+            if (ans < 0.0) {
+                ans = 0.0;
+                valx1 = -p;
+            }
+            /* Find prob(value < new iterate) */
+
+            valx1 = ptukey.evaluate(ans, rr, cc, df, /* LOWER */true, /* LOG_P */false) - p;
+            x1 = ans;
+
+            /* If the difference between two successive */
+            /* iterates is less than eps, stop */
+            double xabs = TOMS708.fabs(x1 - x0);
+            if (xabs < eps) {
+                return ans;
+            }
+        }
+
+        /* The process did not converge in 'maxiter' iterations */
+        RMathError.error(MLError.NOCONV, "qtukey");
+        return ans;
+
+    }
+
+    private static final double p0 = 0.322232421088;
+    private static final double q0 = 0.993484626060e-01;
+    private static final double p1 = -1.0;
+    private static final double q1 = 0.588581570495;
+    private static final double p2 = -0.342242088547;
+    private static final double q2 = 0.531103462366;
+    private static final double p3 = -0.204231210125;
+    private static final double q3 = 0.103537752850;
+    private static final double p4 = -0.453642210148e-04;
+    private static final double q4 = 0.38560700634e-02;
+    private static final double c1 = 0.8832;
+    private static final double c2 = 0.2368;
+    private static final double c3 = 1.214;
+    private static final double c4 = 1.208;
+    private static final double c5 = 1.4142;
+    private static final double vmax = 120.0;
+
+    static double qinv(double p, double c, double v) {
+        double ps = 0.5 - 0.5 * p;
+        double yi = Math.sqrt(Math.log(1.0 / (ps * ps)));
+        double t = yi + ((((yi * p4 + p3) * yi + p2) * yi + p1) * yi + p0) / ((((yi * q4 + q3) * yi + q2) * yi + q1) * yi + q0);
+        if (v < vmax) {
+            t += (t * t * t + t) / v / 4.0;
+        }
+        double q = c1 - c2 * t;
+        if (v < vmax) {
+            q += -c3 / v + c4 * t / v;
+        }
+        return t * (q * Math.log(c - 1.0) + c5);
+    }
+}
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Qnt.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Qnt.java
new file mode 100644
index 0000000000000000000000000000000000000000..2479dff17891dd68b71ce5f42d7022afea95048e
--- /dev/null
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Qnt.java
@@ -0,0 +1,87 @@
+/*
+ * 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) 2006-2015, The R Core Team
+ * Copyright (c) 2017, Oracle and/or its affiliates
+ *
+ * All rights reserved.
+ */
+package com.oracle.truffle.r.runtime.nmath.distr;
+
+import static com.oracle.truffle.r.runtime.nmath.MathConstants.DBL_EPSILON;
+import static com.oracle.truffle.r.runtime.nmath.MathConstants.DBL_MAX;
+import static com.oracle.truffle.r.runtime.nmath.distr.Qnorm.qnorm;
+
+import com.oracle.truffle.r.runtime.nmath.DPQ;
+import com.oracle.truffle.r.runtime.nmath.DPQ.EarlyReturn;
+import com.oracle.truffle.r.runtime.nmath.MathFunctions.Function3_2;
+import com.oracle.truffle.r.runtime.nmath.RMath;
+import com.oracle.truffle.r.runtime.nmath.RMathError;
+import com.oracle.truffle.r.runtime.nmath.TOMS708;
+
+public final class Qnt implements Function3_2 {
+    private static final double accu = 1e-13;
+    private static final double Eps = 1e-11; /* must be > accu */
+
+    private final Pnt pnt = new Pnt();
+    private final Qt qt = new Qt();
+
+    @Override
+    public double evaluate(double pIn, double df, double ncp, boolean lowerTail, boolean logP) {
+        if (Double.isNaN(pIn) || Double.isNaN(df) || Double.isNaN(ncp)) {
+            return pIn + df + ncp;
+        }
+        if (df <= 0.0) {
+            return RMathError.defaultError();
+        }
+
+        if (ncp == 0.0 && df >= 1.0) {
+            return qt.evaluate(pIn, df, lowerTail, logP);
+        }
+
+        try {
+            DPQ.rqp01boundaries(pIn, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, lowerTail, logP);
+        } catch (EarlyReturn e) {
+            return e.result;
+        }
+
+        if (!Double.isFinite(df)) {
+            // df = Inf ==> limit N(ncp,1)
+            return qnorm(pIn, ncp, 1., lowerTail, logP);
+        }
+
+        double p = DPQ.rdtqiv(pIn, lowerTail, logP);
+
+        /*
+         * Invert pnt(.) : 1. finding an upper and lower bound
+         */
+        if (p > 1 - DBL_EPSILON) {
+            return Double.POSITIVE_INFINITY;
+        }
+        double pp = RMath.fmin2(1 - DBL_EPSILON, p * (1 + Eps));
+        double ux = RMath.fmax2(1., ncp);
+        while (ux < DBL_MAX && pnt.evaluate(ux, df, ncp, true, false) < pp) {
+            ux *= 2;
+        }
+        pp = p * (1 - Eps);
+        double lx = RMath.fmin2(-1., -ncp);
+        while (lx > -DBL_MAX && pnt.evaluate(lx, df, ncp, true, false) > pp) {
+            lx *= 2;
+        }
+
+        /* 2. interval (lx,ux) halving : */
+        double nx;
+        do {
+            nx = 0.5 * (lx + ux); // could be zero
+            if (pnt.evaluate(nx, df, ncp, true, false) > p) {
+                ux = nx;
+            } else {
+                lx = nx;
+            }
+        } while ((ux - lx) > accu * RMath.fmax2(TOMS708.fabs(lx), TOMS708.fabs(ux)));
+
+        return 0.5 * (lx + ux);
+    }
+}
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Signrank.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Signrank.java
index a45f69b73ffc1609bfe57a22e6dab26556381a41..8d0f14b55465e532472cdd511250b1d50ce322ee 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Signrank.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Signrank.java
@@ -11,14 +11,22 @@
 
 package com.oracle.truffle.r.runtime.nmath.distr;
 
-import static com.oracle.truffle.r.runtime.RError.Message.GENERIC;
+import static com.oracle.truffle.r.runtime.RError.Message.CALLOC_COULD_NOT_ALLOCATE;
+import static com.oracle.truffle.r.runtime.nmath.MathConstants.DBL_EPSILON;
+import static com.oracle.truffle.r.runtime.nmath.MathConstants.M_LN2;
 import static com.oracle.truffle.r.runtime.nmath.RMath.forceint;
 
 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
 import com.oracle.truffle.r.runtime.RError;
+import com.oracle.truffle.r.runtime.nmath.DPQ;
+import com.oracle.truffle.r.runtime.nmath.DPQ.EarlyReturn;
+import com.oracle.truffle.r.runtime.nmath.MathFunctions.Function2_1;
+import com.oracle.truffle.r.runtime.nmath.MathFunctions.Function2_2;
+import com.oracle.truffle.r.runtime.nmath.RMath;
 import com.oracle.truffle.r.runtime.nmath.RMathError;
 import com.oracle.truffle.r.runtime.nmath.RandomFunctions.RandFunction1_Double;
 import com.oracle.truffle.r.runtime.nmath.RandomFunctions.RandomNumberProvider;
+import com.oracle.truffle.r.runtime.nmath.TOMS708;
 
 public final class Signrank {
     private Signrank() {
@@ -26,7 +34,7 @@ public final class Signrank {
     }
 
     /**
-     * Holds cache for the dynamic algorithm that wilcox uses.
+     * Holds cache for the dynamic algorithm that signrank uses.
      */
     public static final class SignrankData {
         private static final ThreadLocal<double[]> data = new ThreadLocal<>();
@@ -44,7 +52,8 @@ public final class Signrank {
                 try {
                     result = new double[c + 1];
                 } catch (OutOfMemoryError e) {
-                    throw RError.error(RError.SHOW_CALLER, GENERIC, "signrank allocation error");
+                    // GnuR seems to be reporting the same number regardless of 'c'
+                    throw couldNotAllocateError();
                 }
                 data.set(result);
             }
@@ -56,6 +65,180 @@ public final class Signrank {
         }
     }
 
+    private static RError couldNotAllocateError() {
+        return RError.error(RError.SHOW_CALLER, CALLOC_COULD_NOT_ALLOCATE, "18446744073172680704", 8);
+    }
+
+    private static double csignrank(double[] w, int kIn, int n) {
+        int u = n * (n + 1) / 2;
+        int c = (u / 2);
+
+        if (kIn < 0 || kIn > u) {
+            return 0;
+        }
+        int k = kIn <= c ? kIn : u - kIn;
+
+        if (n == 1) {
+            return 1.;
+        }
+        if (w[0] == 1.) {
+            return w[k];
+        }
+
+        w[0] = w[1] = 1.;
+        for (int j = 2; j < n + 1; ++j) {
+            int end = Math.min(j * (j + 1) / 2, c);
+            for (int i = end; i >= j; --i) {
+                w[i] += w[i - j];
+            }
+        }
+        return w[k];
+    }
+
+    public static final class DSignrank implements Function2_1 {
+        @Override
+        public double evaluate(double xIn, double nIn, boolean giveLog) {
+            /* NaNs propagated correctly */
+            if (Double.isNaN(xIn) || Double.isNaN(nIn)) {
+                return xIn + nIn;
+            }
+
+            if (nIn == Double.POSITIVE_INFINITY) {
+                // to have the same output as GnuR:
+                throw couldNotAllocateError();
+            }
+
+            double n = RMath.forceint(nIn);
+            if (n <= 0) {
+                return RMathError.defaultError();
+            }
+
+            double x = RMath.forceint(xIn);
+            if (TOMS708.fabs(xIn - x) > 1e-7) {
+                return DPQ.rd0(giveLog);
+            }
+            if ((x < 0) || (x > (n * (n + 1) / 2))) {
+                return DPQ.rd0(giveLog);
+            }
+
+            int nn = (int) n;
+            double[] data = SignrankData.getData(nn);
+            return DPQ.rdexp(Math.log(csignrank(data, (int) x, nn)) - n * M_LN2, giveLog);
+        }
+    }
+
+    public static final class PSignrank implements Function2_2 {
+        @Override
+        public double evaluate(double xIn, double nIn, boolean lowerTail, boolean logP) {
+            if (Double.isNaN(xIn) || Double.isNaN(nIn)) {
+                return (xIn + nIn);
+            }
+            if (!Double.isFinite(nIn)) {
+                return RMathError.defaultError();
+            }
+
+            double n = RMath.forceint(nIn);
+            if (n <= 0) {
+                return RMathError.defaultError();
+            }
+
+            double x = RMath.forceint(xIn + 1e-7);
+            if (x < 0.0) {
+                return DPQ.rdt0(lowerTail, logP);
+            }
+            if (x >= n * (n + 1) / 2) {
+                return DPQ.rdt1(lowerTail, logP);
+            }
+
+            int nn = (int) n;
+            double[] data = SignrankData.getData(nn);
+            double f = Math.exp(-n * M_LN2);
+            double p = 0;
+            if (x <= (n * (n + 1) / 4)) {
+                int xUpperLimit = getUpperIntBound(x);
+                for (int i = 0; i <= xUpperLimit; i++) {
+                    p += csignrank(data, i, nn) * f;
+                }
+                return DPQ.rdtval(p, lowerTail, logP);
+            } else {
+                x = n * (n + 1) / 2 - x;
+                int xUpperLimit = getUpperIntBound(x);
+                for (int i = 0; i < xUpperLimit; i++) {
+                    p += csignrank(data, i, nn) * f;
+                }
+                // !lowerTail, because p = 1 - p; */
+                return DPQ.rdtval(p, !lowerTail, logP);
+            }
+        }
+
+        /**
+         * Makes sure that the value can be reached by integer counter, this is probably just really
+         * defensive, since the allocation with such number is bound to fail anyway.
+         */
+        private int getUpperIntBound(double x) {
+            return (x + 1) > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) Math.ceil(x);
+        }
+    }
+
+    public static final class QSignrank implements Function2_2 {
+        @Override
+        public double evaluate(double xIn, double nIn, boolean lowerTail, boolean logP) {
+            if (Double.isNaN(xIn) || Double.isNaN(nIn)) {
+                return (xIn + nIn);
+            }
+
+            if (!Double.isFinite(xIn) || !Double.isFinite(nIn)) {
+                return RMathError.defaultError();
+            }
+
+            try {
+                DPQ.rqp01check(xIn, logP);
+            } catch (EarlyReturn earlyReturn) {
+                return earlyReturn.result;
+            }
+
+            double n = RMath.forceint(nIn);
+            if (n <= 0) {
+                return RMathError.defaultError();
+            }
+
+            if (xIn == DPQ.rdt0(lowerTail, logP)) {
+                return 0;
+            }
+            if (xIn == DPQ.rdt1(lowerTail, logP)) {
+                return n * (n + 1) / 2;
+            }
+
+            double x = !logP && lowerTail ? xIn : DPQ.rdtqiv(xIn, lowerTail, logP);
+            int nn = (int) n;
+            double[] data = SignrankData.getData(nn);
+            double f = Math.exp(-n * M_LN2);
+            double p = 0;
+            int q = 0;
+            if (x <= 0.5) {
+                x = x - 10 * DBL_EPSILON;
+                while (true) {
+                    p += csignrank(data, q, nn) * f;
+                    if (p >= x) {
+                        break;
+                    }
+                    q++;
+                }
+            } else {
+                x = 1 - x + 10 * DBL_EPSILON;
+                while (true) {
+                    p += csignrank(data, q, nn) * f;
+                    if (p > x) {
+                        q = (int) (n * (n + 1) / 2 - q);
+                        break;
+                    }
+                    q++;
+                }
+            }
+            return q;
+        }
+    }
+
     public static final class RSignrank extends RandFunction1_Double {
         @Override
         public double execute(double nIn, RandomNumberProvider rand) {
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Wilcox.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Wilcox.java
index 72ff4f983a427afec9810e53b2261df454735634..fc9e1f2ecdac225c952861d95594006314befa11 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Wilcox.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Wilcox.java
@@ -11,7 +11,7 @@
 
 package com.oracle.truffle.r.runtime.nmath.distr;
 
-import static com.oracle.truffle.r.runtime.RError.Message.CALLOC_COULD_NOT_ALLOCATE_INF;
+import static com.oracle.truffle.r.runtime.RError.Message.CALLOC_COULD_NOT_ALLOCATE;
 import static com.oracle.truffle.r.runtime.nmath.Choose.choose;
 import static com.oracle.truffle.r.runtime.nmath.Choose.lchoose;
 import static com.oracle.truffle.r.runtime.nmath.MathConstants.DBL_EPSILON;
@@ -86,8 +86,7 @@ public final class Wilcox {
                 try {
                     result = new double[m + 1][n + 1][];
                 } catch (OutOfMemoryError e) {
-                    // GnuR seems to be reporting the same number regardless of the actual size
-                    throw RError.error(RError.SHOW_CALLER, CALLOC_COULD_NOT_ALLOCATE_INF);
+                    throw couldNotAllocateError();
                 }
                 data.set(result);
             }
@@ -99,6 +98,11 @@ public final class Wilcox {
         }
     }
 
+    private static RError couldNotAllocateError() {
+        // GnuR seems to be reporting the same number regardless of the actual size?
+        return RError.error(RError.SHOW_CALLER, CALLOC_COULD_NOT_ALLOCATE, "18446744071562067968", 4);
+    }
+
     private static double cwilcox(double[][][] w, int kIn, int m, int n) {
         int u = m * n;
         if (kIn < 0 || kIn > u) {
@@ -318,7 +322,7 @@ public final class Wilcox {
             if (!Double.isFinite(mIn) || !Double.isFinite(nIn)) {
                 // GnuR does not check this and tries to allocate the memory, we do check this, but
                 // fail with the same error message for compatibility reasons.
-                throw RError.error(RError.SHOW_CALLER, CALLOC_COULD_NOT_ALLOCATE_INF);
+                throw couldNotAllocateError();
             }
 
             double m = RMath.round(mIn);
@@ -343,8 +347,7 @@ public final class Wilcox {
             try {
                 x = new int[k];
             } catch (OutOfMemoryError ex) {
-                // GnuR seems to be reporting the same number regardless of 'k'
-                throw RError.error(RError.SHOW_CALLER, CALLOC_COULD_NOT_ALLOCATE_INF);
+                throw couldNotAllocateError();
             }
             for (int i = 0; i < k; i++) {
                 x[i] = i;
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 f8e922a309213fb0ed51df55aff111a0c07e99cb..4584dcf48a9bc969471e07186c6cc935382ec31c 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
@@ -112780,6 +112780,110 @@ In dpois(c(1e-11, 0.1, 1, 10), 1e-07, log = T) : non-integer x = 0.100000
  [1]  -3.274566  -2.078562  -3.360495  -6.283915 -15.580684       -Inf
  [7]       -Inf -10.000000 -10.000000       -Inf        NaN
 
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dsignrank(0, -3)
+[1] NaN
+Warning message:
+In dsignrank(0, -3) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dsignrank(0, -Inf)
+[1] NaN
+Warning message:
+In dsignrank(0, -Inf) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dsignrank(0, 0)
+[1] NaN
+Warning message:
+In dsignrank(0, 0) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dsignrank(0, Inf)
+Error in dsignrank(0, Inf) :
+  'Calloc' could not allocate memory (18446744073172680704 of 8 bytes)
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dsignrank(0, NaN)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dsignrank(c(0.3, 0.6, 2, 3, 6, 15, 20), 5.5, log=F)
+[1] 0.000000 0.000000 0.015625 0.031250 0.062500 0.062500 0.015625
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dsignrank(c(0.3, 0.6, 2, 3, 6, 15, 20), 5.5, log=T)
+[1]      -Inf      -Inf -4.158883 -3.465736 -2.772589 -2.772589 -4.158883
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dsignrank(c(5, 15, 20, 27, 35, 50, 54, 55, 56, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, log=F)
+ [1] 0.0029296875 0.0195312500 0.0302734375 0.0390625000 0.0302734375
+ [6] 0.0029296875 0.0009765625 0.0009765625 0.0000000000 0.0000000000
+[11] 0.0000000000 0.0009765625 0.0009765625 0.0009765625 0.0000000000
+[16]          NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dsignrank(c(5, 15, 20, 27, 35, 50, 54, 55, 56, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, log=T)
+ [1] -5.832860 -3.935740 -3.497485 -3.242592 -3.497485 -5.832860 -6.931472
+ [8] -6.931472      -Inf      -Inf      -Inf -6.931472 -6.931472 -6.931472
+[15]      -Inf       NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dt(0, -Inf,  ncp=0.5)
+[1] NaN
+Warning message:
+In dt(0, -Inf, ncp = 0.5) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dt(0, 3e100, -Inf)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dt(0, 3e100, NaN)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dt(0, NaN,  ncp=0.5)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dt(c(-10, -5, -4, -3, -2, -1, 0, 1.1, 2, 3, 4, 10, 100), Inf, ncp=-1, log=F)
+ [1] 1.027977e-18 1.338302e-04 4.431848e-03 5.399097e-02 2.419707e-01
+ [6] 3.989423e-01 2.419707e-01 4.398360e-02 4.431848e-03 1.338302e-04
+[11] 1.486720e-06 2.118819e-27 0.000000e+00
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dt(c(-10, -5, -4, -3, -2, -1, 0, 1.1, 2, 3, 4, 10, 100), Inf, ncp=-1, log=T)
+ [1]   -41.4189385    -8.9189385    -5.4189385    -2.9189385    -1.4189385
+ [6]    -0.9189385    -1.4189385    -3.1239385    -5.4189385    -8.9189385
+[11]   -13.4189385   -61.4189385 -5101.4189385
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dt(c(-30, -20, -4, 0.5, 1.3, 2, 3, 4, 10, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 3e100, ncp=0.5, log=F)
+ [1] 3.978223e-203  2.211984e-92  1.598374e-05  3.989423e-01  2.896916e-01
+ [6]  1.295176e-01  1.752830e-02  8.726827e-04  1.007794e-20  0.000000e+00
+[11]  0.000000e+00  3.520653e-01  3.520653e-01  3.520653e-01  0.000000e+00
+[16]           NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dt(c(-30, -20, -4, 0.5, 1.3, 2, 3, 4, 10, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 3e100, ncp=0.5, log=T)
+ [1]  -466.0439385  -211.0439385   -11.0439385    -0.9189385    -1.2389385
+ [6]    -2.0439385    -4.0439385    -7.0439385   -46.0439385 -4951.0439385
+[11]          -Inf    -1.0439385    -1.0439385    -1.0439385          -Inf
+[16]           NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dt(c(1), -10, ncp=2, log=F)
+[1] NaN
+Warning message:
+In dt(c(1), -10, ncp = 2, log = F) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
+#dt(c(1), -10, ncp=2, log=T)
+[1] NaN
+Warning message:
+In dt(c(1), -10, ncp = 2, log = T) : NaNs produced
+
 ##com.oracle.truffle.r.test.library.stats.TestDistributions.testDensityFunctions#Output.MayIgnoreWarningContext#
 #dunif(0, -3, -Inf)
 [1] NaN
@@ -114454,6 +114558,270 @@ In ppois(0, -Inf) : NaNs produced
  [6]          -Inf          -Inf -1.000000e+01 -1.000000e+01  0.000000e+00
 [11]           NaN
 
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#psignrank(0, -3)
+[1] NaN
+Warning message:
+In psignrank(0, -3) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#psignrank(0, -Inf)
+[1] NaN
+Warning message:
+In psignrank(0, -Inf) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#psignrank(0, 0)
+[1] NaN
+Warning message:
+In psignrank(0, 0) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#psignrank(0, Inf)
+[1] NaN
+Warning message:
+In psignrank(0, Inf) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#psignrank(0, NaN)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#psignrank(c(0.3, 0.6, 2, 3, 6, 15, 20), 5.5, lower.tail=F, log.p=F)
+[1] 0.984375 0.968750 0.953125 0.921875 0.781250 0.156250 0.015625
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#psignrank(c(0.3, 0.6, 2, 3, 6, 15, 20), 5.5, lower.tail=F, log.p=T)
+[1] -0.01574836 -0.03174870 -0.04800922 -0.08134564 -0.24686008 -1.85629799
+[7] -4.15888308
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#psignrank(c(0.3, 0.6, 2, 3, 6, 15, 20), 5.5, lower.tail=T, log.p=F)
+[1] 0.015625 0.031250 0.046875 0.078125 0.218750 0.843750 0.984375
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#psignrank(c(0.3, 0.6, 2, 3, 6, 15, 20), 5.5, lower.tail=T, log.p=T)
+[1] -4.15888308 -3.46573590 -3.06027079 -2.54944517 -1.51982575 -0.16989904
+[7] -0.01574836
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#psignrank(c(5, 15, 20, 27, 35, 50, 54, 55, 56, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, lower.tail=F, log.p=F)
+ [1] 0.9902343750 0.8837890625 0.7539062500 0.5000000000 0.2158203125
+ [6] 0.0068359375 0.0009765625 0.0000000000 0.0000000000 0.0000000000
+[11] 1.0000000000 0.9990234375 0.9990234375 0.9990234375 0.0000000000
+[16]          NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#psignrank(c(5, 15, 20, 27, 35, 50, 54, 55, 56, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, lower.tail=F, log.p=T)
+ [1] -0.0098136214 -0.1235368619 -0.2824872556 -0.6931471806 -1.5333091041
+ [6] -4.9855616565 -6.9314718056          -Inf          -Inf          -Inf
+[11]  0.0000000000 -0.0009770396 -0.0009770396 -0.0009770396          -Inf
+[16]           NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#psignrank(c(5, 15, 20, 27, 35, 50, 54, 55, 56, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, lower.tail=T, log.p=F)
+ [1] 0.0097656250 0.1162109375 0.2460937500 0.5000000000 0.7841796875
+ [6] 0.9931640625 0.9990234375 1.0000000000 1.0000000000 1.0000000000
+[11] 0.0000000000 0.0009765625 0.0009765625 0.0009765625 1.0000000000
+[16]          NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#psignrank(c(5, 15, 20, 27, 35, 50, 54, 55, 56, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, lower.tail=T, log.p=T)
+ [1] -4.6288867126 -2.1523483125 -1.4020427181 -0.6931471806 -0.2431170917
+ [6] -0.0068594096 -0.0009770396  0.0000000000  0.0000000000  0.0000000000
+[11]          -Inf -6.9314718056 -6.9314718056 -6.9314718056  0.0000000000
+[16]           NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(0, -Inf,  ncp=0.5)
+[1] NaN
+Warning message:
+In pt(0, -Inf, ncp = 0.5) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(0, 3e100, -Inf)
+[1] 1
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(0, 3e100, NaN)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(0, NaN,  ncp=0.5)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(c(-10, -5, -4, -3, -2, -1, 0, 1.1, 2, 3, 4, 10, 100), Inf, ncp=-1, lower.tail=F, log.p=F)
+ [1] 1.000000e+00 9.999683e-01 9.986501e-01 9.772499e-01 8.413447e-01
+ [6] 5.000000e-01 1.586553e-01 1.786442e-02 1.349898e-03 3.167124e-05
+[11] 2.866516e-07 1.910660e-28 0.000000e+00
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(c(-10, -5, -4, -3, -2, -1, 0, 1.1, 2, 3, 4, 10, 100), Inf, ncp=-1, lower.tail=F, log.p=T)
+ [1] -1.128588e-19 -3.167174e-05 -1.350810e-03 -2.301291e-02 -1.727538e-01
+ [6] -6.931472e-01 -1.841022e+00 -4.024944e+00 -6.607726e+00 -1.036010e+01
+[11] -1.506500e+01 -6.382493e+01 -5.106034e+03
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(c(-10, -5, -4, -3, -2, -1, 0, 1.1, 2, 3, 4, 10, 100), Inf, ncp=-1, lower.tail=T, log.p=F)
+ [1] 1.128588e-19 3.167124e-05 1.349898e-03 2.275013e-02 1.586553e-01
+ [6] 5.000000e-01 8.413447e-01 9.821356e-01 9.986501e-01 9.999683e-01
+[11] 9.999997e-01 1.000000e+00 1.000000e+00
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(c(-10, -5, -4, -3, -2, -1, 0, 1.1, 2, 3, 4, 10, 100), Inf, ncp=-1, lower.tail=T, log.p=T)
+ [1] -4.362815e+01 -1.036010e+01 -6.607726e+00 -3.783184e+00 -1.841022e+00
+ [6] -6.931472e-01 -1.727538e-01 -1.802592e-02 -1.350810e-03 -3.167174e-05
+[11] -2.866516e-07 -1.910660e-28  0.000000e+00
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(c(-30, -20, -4, 0.5, 1.3, 2, 3, 4, 10, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 3e100, ncp=0.5, lower.tail=F, log.p=F)
+ [1] 1.000000e+00 1.000000e+00 9.999966e-01 5.000000e-01 2.118554e-01
+ [6] 6.680720e-02 6.209665e-03 2.326291e-04 1.049452e-21 0.000000e+00
+[11] 1.000000e+00 6.914625e-01 6.914625e-01 6.914625e-01 0.000000e+00
+[16]          NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(c(-30, -20, -4, 0.5, 1.3, 2, 3, 4, 10, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 3e100, ncp=0.5, lower.tail=F, log.p=T)
+ [1] -1.302938e-204  -1.076467e-93  -3.397679e-06  -6.931472e-01  -1.551851e+00
+ [6]  -2.705944e+00  -5.081648e+00  -8.366065e+00  -4.830602e+01  -4.955644e+03
+[11]   0.000000e+00  -3.689464e-01  -3.689464e-01  -3.689464e-01           -Inf
+[16]            NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(c(-30, -20, -4, 0.5, 1.3, 2, 3, 4, 10, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 3e100, ncp=0.5, lower.tail=T, log.p=F)
+ [1] 1.302938e-204  1.076467e-93  3.397673e-06  5.000000e-01  7.881446e-01
+ [6]  9.331928e-01  9.937903e-01  9.997674e-01  1.000000e+00  1.000000e+00
+[11]  0.000000e+00  3.085375e-01  3.085375e-01  3.085375e-01  1.000000e+00
+[16]           NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(c(-30, -20, -4, 0.5, 1.3, 2, 3, 4, 10, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 3e100, ncp=0.5, lower.tail=T, log.p=T)
+ [1] -4.694627e+02 -2.140667e+02 -1.259242e+01 -6.931472e-01 -2.380737e-01
+ [6] -6.914346e-02 -6.229025e-03 -2.326561e-04 -1.049452e-21  0.000000e+00
+[11]          -Inf -1.175912e+00 -1.175912e+00 -1.175912e+00  0.000000e+00
+[16]           NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(c(1), -10, ncp=2, lower.tail=F, log.p=F)
+[1] NaN
+Warning message:
+In pt(c(1), -10, ncp = 2, lower.tail = F, log.p = F) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(c(1), -10, ncp=2, lower.tail=F, log.p=T)
+[1] NaN
+Warning message:
+In pt(c(1), -10, ncp = 2, lower.tail = F, log.p = T) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(c(1), -10, ncp=2, lower.tail=T, log.p=F)
+[1] NaN
+Warning message:
+In pt(c(1), -10, ncp = 2, lower.tail = T, log.p = F) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#pt(c(1), -10, ncp=2, lower.tail=T, log.p=T)
+[1] NaN
+Warning message:
+In pt(c(1), -10, ncp = 2, lower.tail = T, log.p = T) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, -10,  5,  4)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, -Inf,  5,  4)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, 0,  5,  4)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, 1,  5,  4)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, 10,  5, -10)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, 10,  5, -Inf)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, 10,  5, 0)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, 10,  5, 1)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, 10,  5, Inf)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, 10,  5, NaN)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, 10, -10,  4)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, 10, -Inf,  4)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, 10, 0,  4)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, 10, 1,  4)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, 10, Inf,  4)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, 10, NaN,  4)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, Inf,  5,  4)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(0, NaN,  5,  4)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(c(-1, 1, 1.9, 3, 5, 10, 15, 20, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, 5, 4, lower.tail=F, log.p=F)
+ [1] 1.000000e+00 1.000000e+00 9.934805e-01 8.305223e-01 3.211940e-01
+ [6] 2.527372e-02 4.050344e-03 1.054660e-03 5.155335e-07 1.000000e+00
+[11] 1.000000e+00 1.000000e+00 1.000000e+00 0.000000e+00          NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(c(-1, 1, 1.9, 3, 5, 10, 15, 20, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, 5, 4, lower.tail=F, log.p=T)
+ [1]   0.000000000   0.000000000  -0.006540828  -0.185700543  -1.135710025
+ [6]  -3.677990327  -5.508953426  -6.854537201 -14.478063579   0.000000000
+[11]   0.000000000   0.000000000   0.000000000          -Inf           NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(c(-1, 1, 1.9, 3, 5, 10, 15, 20, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, 5, 4, lower.tail=T, log.p=F)
+ [1] 0.000000000 0.000000000 0.006519484 0.169477737 0.678806015 0.974726284
+ [7] 0.995949656 0.998945340 0.999999484 0.000000000 0.000000000 0.000000000
+[13] 0.000000000 1.000000000         NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
+#ptukey(c(-1, 1, 1.9, 3, 5, 10, 15, 20, 100, -Inf, -0.42e-30, 0, 0.42e-30, Inf, NaN), 10, 5, 4, lower.tail=T, log.p=T)
+ [1]          -Inf          -Inf -5.032960e+00 -1.775034e+00 -3.874199e-01
+ [6] -2.559858e-02 -4.058569e-03 -1.055216e-03 -5.155336e-07          -Inf
+[11]          -Inf          -Inf          -Inf  0.000000e+00           NaN
+
 ##com.oracle.truffle.r.test.library.stats.TestDistributions.testDistributionFunctions#Output.MayIgnoreWarningContext#
 #punif(0, -3, -Inf)
 [1] NaN
@@ -116569,6 +116937,376 @@ In qpois(Inf, 10) : NaNs produced
 #qpois(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 1e100, lower.tail=T, log.p=T)
 [1]  0e+00 1e+100 1e+100 1e+100 1e+100    Inf    Inf
 
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(-0.42e-38, 10)
+[1] NaN
+Warning message:
+In qsignrank(-4.2e-39, 10) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(-42, 10)
+[1] NaN
+Warning message:
+In qsignrank(-42, 10) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(-Inf, 10)
+[1] NaN
+Warning message:
+In qsignrank(-Inf, 10) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(0, -3)
+[1] NaN
+Warning message:
+In qsignrank(0, -3) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(0, -Inf)
+[1] NaN
+Warning message:
+In qsignrank(0, -Inf) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(0, 0)
+[1] NaN
+Warning message:
+In qsignrank(0, 0) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(0, Inf)
+[1] NaN
+Warning message:
+In qsignrank(0, Inf) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(0, NaN)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(Inf, 10)
+[1] NaN
+Warning message:
+In qsignrank(Inf, 10) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(NaN, 10)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 10, lower.tail=F, log.p=F)
+[1] 55 55 40 27 22  0  0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 10, lower.tail=T, log.p=F)
+[1]  0  0 15 27 33 55 55
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 5.5, lower.tail=F, log.p=F)
+[1] 21 21 17 10  8  0  0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 5.5, lower.tail=T, log.p=F)
+[1]  0  0  4 10 13 21 21
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 10, lower.tail=F, log.p=T)
+[1] NaN  55  40  27  22   0   0
+Warning message:
+In qsignrank(log(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1)),  :
+  NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 10, lower.tail=T, log.p=T)
+[1] NaN   0  15  27  33  55  55
+Warning message:
+In qsignrank(log(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1)),  :
+  NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 5.5, lower.tail=F, log.p=T)
+[1] NaN  21  17  10   8   0   0
+Warning message:
+In qsignrank(log(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1)),  :
+  NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qsignrank(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 5.5, lower.tail=T, log.p=T)
+[1] NaN   0   4  10  13  21  21
+Warning message:
+In qsignrank(log(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1)),  :
+  NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(-0.42e-38, 3e100, ncp=0.5)
+[1] NaN
+Warning message:
+In qt(-4.2e-39, 3e+100, ncp = 0.5) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(-42, 3e100, ncp=0.5)
+[1] NaN
+Warning message:
+In qt(-42, 3e+100, ncp = 0.5) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(-Inf, 3e100, ncp=0.5)
+[1] NaN
+Warning message:
+In qt(-Inf, 3e+100, ncp = 0.5) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(0, -Inf,  ncp=0.5)
+[1] NaN
+Warning message:
+In qt(0, -Inf, ncp = 0.5) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(0, 3e100, -Inf)
+[1] -Inf
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(0, 3e100, NaN)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(0, NaN,  ncp=0.5)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(Inf, 3e100, ncp=0.5)
+[1] NaN
+Warning message:
+In qt(Inf, 3e+100, ncp = 0.5) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(NaN, 3e100, ncp=0.5)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), -10, ncp=2, lower.tail=F, log.p=F)
+[1] NaN NaN NaN NaN NaN NaN NaN
+Warning message:
+In qt(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1), -10, ncp = 2,  :
+  NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), -10, ncp=2, lower.tail=T, log.p=F)
+[1] NaN NaN NaN NaN NaN NaN NaN
+Warning message:
+In qt(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1), -10, ncp = 2,  :
+  NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 3e100, ncp=0.5, lower.tail=F, log.p=F)
+[1]         Inf         Inf  1.78155157  0.50000000 -0.02440051        -Inf
+[7]        -Inf
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 3e100, ncp=0.5, lower.tail=T, log.p=F)
+[1]        -Inf -18.2943519  -0.7815516   0.5000000   1.0244005         Inf
+[7]         Inf
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), Inf, ncp=-1, lower.tail=F, log.p=F)
+[1]        Inf 17.7943519  0.2815516 -1.0000000 -1.5244005       -Inf       -Inf
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), Inf, ncp=-1, lower.tail=T, log.p=F)
+[1]        -Inf -19.7943519  -2.2815516  -1.0000000  -0.4755995         Inf
+[7]         Inf
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), -10, ncp=2, lower.tail=F, log.p=T)
+[1] NaN NaN NaN NaN NaN NaN NaN
+Warning message:
+In qt(log(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1)), -10, ncp = 2,  :
+  NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), -10, ncp=2, lower.tail=T, log.p=T)
+[1] NaN NaN NaN NaN NaN NaN NaN
+Warning message:
+In qt(log(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1)), -10, ncp = 2,  :
+  NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 3e100, ncp=0.5, lower.tail=F, log.p=T)
+[1]         Inf         Inf  1.78155157  0.50000000 -0.02440051        -Inf
+[7]        -Inf
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 3e100, ncp=0.5, lower.tail=T, log.p=T)
+[1]        -Inf -18.2943519  -0.7815516   0.5000000   1.0244005         Inf
+[7]         Inf
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), Inf, ncp=-1, lower.tail=F, log.p=T)
+[1]        Inf 17.7943519  0.2815516 -1.0000000 -1.5244005       -Inf       -Inf
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qt(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), Inf, ncp=-1, lower.tail=T, log.p=T)
+[1]        -Inf -19.7943519  -2.2815516  -1.0000000  -0.4755995         Inf
+[7]         Inf
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(-0.42e-38, 10, 5, 4)
+[1] NaN
+Warning message:
+In qtukey(-4.2e-39, 10, 5, 4) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(-42, 10, 5, 4)
+[1] NaN
+Warning message:
+In qtukey(-42, 10, 5, 4) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(-Inf, 10, 5, 4)
+[1] NaN
+Warning message:
+In qtukey(-Inf, 10, 5, 4) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, -10,  5,  4)
+[1] NaN
+Warning message:
+In qtukey(0, -10, 5, 4) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, -Inf,  5,  4)
+[1] NaN
+Warning message:
+In qtukey(0, -Inf, 5, 4) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, 0,  5,  4)
+[1] NaN
+Warning message:
+In qtukey(0, 0, 5, 4) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, 1,  5,  4)
+[1] NaN
+Warning message:
+In qtukey(0, 1, 5, 4) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, 10,  5, -10)
+[1] NaN
+Warning message:
+In qtukey(0, 10, 5, -10) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, 10,  5, -Inf)
+[1] NaN
+Warning message:
+In qtukey(0, 10, 5, -Inf) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, 10,  5, 0)
+[1] NaN
+Warning message:
+In qtukey(0, 10, 5, 0) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, 10,  5, 1)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, 10,  5, Inf)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, 10,  5, NaN)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, 10, -10,  4)
+[1] NaN
+Warning message:
+In qtukey(0, 10, -10, 4) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, 10, -Inf,  4)
+[1] NaN
+Warning message:
+In qtukey(0, 10, -Inf, 4) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, 10, 0,  4)
+[1] NaN
+Warning message:
+In qtukey(0, 10, 0, 4) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, 10, 1,  4)
+[1] NaN
+Warning message:
+In qtukey(0, 10, 1, 4) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, 10, Inf,  4)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, 10, NaN,  4)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, Inf,  5,  4)
+[1] 0
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(0, NaN,  5,  4)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(Inf, 10, 5, 4)
+[1] NaN
+Warning message:
+In qtukey(Inf, 10, 5, 4) : NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(NaN, 10, 5, 4)
+[1] NaN
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 10, 5, 4, lower.tail=F, log.p=F)
+[1]      Inf      NaN 7.124296 4.179388 3.465450 0.000000 0.000000
+Warning messages:
+1: In qtukey(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1), 10, 5, 4,  :
+  convergence failed in 'qtukey'
+2: In qtukey(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1), 10, 5, 4,  :
+  NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1), 10, 5, 4, lower.tail=T, log.p=F)
+[1] 0.0000000 0.6000925       NaN 4.1793878 5.1226189       Inf       Inf
+Warning messages:
+1: In qtukey(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1), 10, 5, 4,  :
+  convergence failed in 'qtukey'
+2: In qtukey(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1), 10, 5, 4,  :
+  NaNs produced
+
+##com.oracle.truffle.r.test.library.stats.TestDistributions.testQuantileFunctions#Output.MayIgnoreWarningContext#
+#qtukey(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 10, 5, 4, lower.tail=F, log.p=T)
+[1]      Inf      NaN 7.124296 4.179388 3.465450 0.000000 0.000000
+Warning messages:
+1: In qtukey(log(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1)), 10,  :
+  convergence failed in 'qtukey'
+2: In qtukey(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#
+#qtukey(log(c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)), 10, 5, 4, lower.tail=T, log.p=T)
+[1] 0.0000000 0.6000925       NaN 4.1793878 5.1226189       Inf       Inf
+Warning messages:
+1: In qtukey(log(c(0, 4.2e-79, 0.1, 0.5, 0.7, 1 - 4.2e-79, 1)), 10,  :
+  convergence failed in 'qtukey'
+2: In qtukey(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#
 #qunif(-0.42e-38, -3, 3.3)
 [1] NaN
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 6917112ebe0bb74895719f461f6217f634d5418a..ce30d364d5e4d0fd6873f81496b96f878ccdfda5 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
@@ -44,6 +44,7 @@ public class TestDistributions extends TestBase {
     private static final String[] DEFAULT_Q = new String[]{"-Inf", "-0.42e-30", "0", "0.42e-30", "Inf", "NaN"};
     private static final String PROBABILITIES = "c(0, 42e-80, 0.1, 0.5, 0.7, 1-42e-80, 1)";
     private static final String[] ERROR_PROBABILITIES = new String[]{"Inf", "-Inf", "NaN", "-42", "-0.42e-38"};
+    private static final String[] DEFAULT_ERROR_PARAMS = {"-Inf", "Inf", "NaN"};
 
     // @formatter:off
     /**
@@ -144,16 +145,36 @@ public class TestDistributions extends TestBase {
                     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")),
-            // Note: wilcox is very memory consuming, so we test only small argument values here
+            // Note: wilcox and signrank are memory consuming, so we test only small argument values here
             distr("wilcox").
                     test("10, 10", withDefaultQ("1", "3", "5", "100", "1000")).
-                    test("4, 7", withQuantiles("1", "3", "5", "100", "1000"))
+                    test("4, 7", withQuantiles("1", "3", "5", "100", "1000")),
+            distr("signrank").
+                    addErrorParamValues("-3", "0").
+                    test("10", withDefaultQ("5", "15", "20", "27", "35", "50", "54", "55", "56", "100")).
+                    test("5.5", withQuantiles("0.3", "0.6", "2", "3", "6", "15", "20")),
+            // Non-central t distribution (t distr. with extra parameter ncp)
+            distr("t").
+                    clearDefaultErrorParamValues().
+                    addErrorParamValues("-Inf", "NaN").
+                    test("3e100, ncp=0.5", withDefaultQ("-30", "-20", "-4", "0.5", "1.3", "2", "3", "4", "10", "100")).
+                    test("Inf, ncp=-1", withQuantiles("-10", "-5", "-4", "-3", "-2", "-1", "0", "1.1", "2", "3", "4", "10", "100")).
+                    // negative first parameter => error
+                    test("-10, ncp=2", withQuantiles("1")),
+            distr("tukey").
+                    hasNoDensityFunction().
+                    addErrorParamValues("-10", "0", "1").
+                    test("10, 5, 4", withDefaultQ("-1", "1", "1.9", "3", "5", "10", "15", "20", "100"))
     };
     // @formatter:on
 
     @Test
     public void testDensityFunctions() {
         for (DistrTest testCase : testCases) {
+            if (!testCase.hasDensityFunction) {
+                continue;
+            }
+
             for (ParamsAndQuantiles paramsAndQ : testCase.paramsAndQuantiles) {
                 testDensityFunction("d" + testCase.name, paramsAndQ.params, paramsAndQ.quantiles);
             }
@@ -237,6 +258,7 @@ public class TestDistributions extends TestBase {
         public final String name;
         public final ArrayList<ParamsAndQuantiles> paramsAndQuantiles = new ArrayList<>();
         private int paramsCount = -1;
+        private boolean hasDensityFunction = true;
         /**
          * Set of single R values that are supposed to produce error when used as any of the
          * parameters.
@@ -245,7 +267,7 @@ public class TestDistributions extends TestBase {
 
         DistrTest(String name) {
             this.name = name;
-            addErrorParamValues("-Inf", "Inf", "NaN");
+            addErrorParamValues(DEFAULT_ERROR_PARAMS);
         }
 
         public DistrTest test(String params, String[] quantiles) {
@@ -265,11 +287,15 @@ public class TestDistributions extends TestBase {
          * but this method is here to make the API "complete". May be removed if all distributions
          * already have tests and non of them needs it.
          */
-        @SuppressWarnings("unused")
         public DistrTest clearDefaultErrorParamValues() {
             errorParamValues.clear();
             return this;
         }
+
+        public DistrTest hasNoDensityFunction() {
+            hasDensityFunction = false;
+            return this;
+        }
     }
 
     /**
diff --git a/mx.fastr/copyrights/gnu_r.foundation.copyright.star b/mx.fastr/copyrights/gnu_r.foundation.copyright.star
new file mode 100644
index 0000000000000000000000000000000000000000..fd68e5453f6ecded2f090283cb5f60befa8f6c49
--- /dev/null
+++ b/mx.fastr/copyrights/gnu_r.foundation.copyright.star
@@ -0,0 +1,10 @@
+/*
+ * 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) 1995-2015, The R Foundation
+ * Copyright (c) 2017, Oracle and/or its affiliates
+ *
+ * All rights reserved.
+ */
diff --git a/mx.fastr/copyrights/gnu_r.foundation.copyright.star.regex b/mx.fastr/copyrights/gnu_r.foundation.copyright.star.regex
new file mode 100644
index 0000000000000000000000000000000000000000..b2688a9d63cece9df9bf726daeb2253e67bc7c12
--- /dev/null
+++ b/mx.fastr/copyrights/gnu_r.foundation.copyright.star.regex
@@ -0,0 +1 @@
+/\*\n \* This material is distributed under the GNU General Public License\n \* Version 2. You may review the terms of this license at\n \* http://www.gnu.org/licenses/gpl-2.0.html\n \*\n \* Copyright \(c\) (?:[1-2][09][0-9][0-9]--?)?(:?[1-2][09])?[0-9]?[0-9], The R Foundation\n \* Copyright \(c\) (?:(20[0-9][0-9]), )?(20[0-9][0-9]), Oracle and/or its affiliates\n \*\n \* All rights reserved.\n \*/\n.*
diff --git a/mx.fastr/copyrights/overrides b/mx.fastr/copyrights/overrides
index df3d2df47da92d0af1a38d77f0a8e635573b2460..c4d5072ca3abfe11429054e5243bc0fa5edd8bf8 100644
--- a/mx.fastr/copyrights/overrides
+++ b/mx.fastr/copyrights/overrides
@@ -33,6 +33,8 @@ com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/DNorm.
 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/RBeta.java,gnu_r_gentleman_ihaka.copyright
 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/RMultinom.java,gnu_r_gentleman_ihaka.copyright
 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Cauchy.java,gnu_r_ihaka_core.copyright
+com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/QTukey.java,gnu_r_ihaka_core.copyright
+com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/PTukey.java,gnu_r_ihaka_core.copyright
 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Cdist.java,gnu_r_gentleman_ihaka.copyright
 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/CompleteCases.java,gnu_r_gentleman_ihaka2.copyright
 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Covcor.java,gnu_r.copyright
@@ -59,6 +61,9 @@ com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/PNBeta
 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/QNBeta.java,gnu_r.core.copyright
 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Qnf.java,gnu_r.core.copyright
 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Dnf.java,gnu_r.core.copyright
+com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Qnt.java,gnu_r.core.copyright
+com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Pnt.java,gnu_r.core.copyright
+com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Dnt.java,gnu_r.foundation.copyright
 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/DNBeta.java,gnu_r_ihaka_core.copyright
 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/LBeta.java,gnu_r_ihaka.copyright
 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Pbinom.java,gnu_r_ihaka.copyright