Reference

PDL::R(3pm)

PDL::R - routines from statistics package, R , for PDL

 use PDL::R;
 pnorm(.1,0.0,1.0);

 $a = sequence(10)
   [0 1 2 3 4 5 6 7 8 9]
 $a /=10.0
  [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9]
 pnorm($a,0.0,1.0)
    [0.5 0.53982784 0.57925971 0.61791142 0.65542174
     0.69146246 0.72574688 0.75803635  0.7881446 0.81593987]

   These are special functions and distributions from the math library
   of the statistics package, R.  Threading is supported, as in the
   example above in which the normal distribution function with mean
   0, and standard deviation 1, is evaluated for ten values.

   Note that all the functions of the form 'rdist' return random
   numbers derived from a single random number generator which gives
   uniform deviates.  The generator of uniform deviates can be
   selected.  Currently only one is supplied-- the one from the original
   R code, sunif.  You can select the generator of uniform deviates
   before generating random numbers from the distributions, like this

   PDL::set_random_generator( PDL::Ptr_sunif());

   The line above is executed upon loading the module, so that sunif is
   the default generator.  You can use this example xsub code to
   create an interface to another generator of random deviates, and
   then use it via set_random_generator.

   void *
   Ptr_sunif()
     CODE:
         RETVAL = &sunif;
     OUTPUT:
         RETVAL

   Details on algorithms can be found in the source files.  
   The functions are described below with their C prototypes.

   SSppeecciiaall FFuunnccttiioonnss ooff MMaatthheemmaattiiccss

 double beta(double, double);
 double lbeta(double, double);
 double gamma(double);
 double lgamma(double);
 double lfastchoose(double, double);
 double fastchoose(double, double);
 double choose(double, double);
 double lchoose(double, double);
 void dpsifn(double, int, int, int, double*, int*, int*);
 double digamma(double);
 double trigamma(double);
 double tetragamma(double);
 double pentagamma(double);

   DDeessccrriippttiioonn::

        The functions `beta' and `lbeta' return the beta func-
        tion and the natural logarithm of the beta function.

        The functions `gamma' and `lgamma' return the gamma
        function and the natural logarithm of the gamma func-
        tion.

        The functions `digamma', `trigamma', `tetragamma' and
        `pentagamma' return the first, second, third and fourth
        derivatives of the logarithm of the gamma function.

        The functions `choose' and `lchoose' return binomial
        coefficients and their logarithms.

   TThhee BBeettaa DDiissttrriibbuuttiioonn

 double dbeta(double x, double a, double b);
 double pbeta(double x, double a, double);
 double pbeta_b(double x, double a, double b, double logbeta);
     (looks like pbeta_b should be removed)
 double qbeta(double x, double a, double b);
 double rbeta(double a, double b);

        These functions provide information about the Beta dis-
        tribution with parameters `a' and `b'.  `dbeta' gives
        the density, `pbeta' the distribution function, `qbeta'
        the quantile function and `rbeta' generates random
        deviates.

        The Beta distribution has density

            Gamma(a+b)/(Gamma(a)Gamma(b))x^(a-1)(1-x)^(b-1)

        for a > 0, b > 0 and 0 < x < 1.

   SSeeee AAllssoo::

        `beta' for the beta function, and `dgamma' for the
        Gamma distribution.

   TThhee BBiinnoommiiaall DDiissttrriibbuuttiioonn

 double dbinom(double x, double n, double p);
 double pbinom(double x, double n, double p);
 double qbinom(double x, double n, double p);
 double rbinom(double x, double n);

        These functions provide information about the binomial
        distribution with parameters `n' and `p'.  `dbinom'
        gives the density, `pbinom' gives the distribution
        function `qbinom' gives the quantile function and
        `rbinom' generates random deviates.

        The binomial distribution has density

                  p(x) = Choose(n,x) p^x (1-p)^(n-x)

        for x = 0, ..., n.

TThhee CCaauucchhyy DDiissttrriibbuuttiioonn

 double dcauchy(double x, double scale, double location);
 double pcauchy(double x, double scale, double location);
 double qcauchy(double x, double scale, double location);
 double rcauchy(double scale, double location);

        These functions provide information about the Cauchy
        distribution with location parameter `location' and
        scale parameter `scale'.

        `dcauchy', `pcauchy', and `qcauchy' are respectively
        the density, distribution function and quantile func-
        tion of the Cauchy distribution.  `rcauchy' generates
        random deviates from the Cauchy.

        The Cauchy distribution with location l and scale s has
        density

                  f(x) = 1 / (pi s (1 + ((x-l)/s)^2))

        for all x.

   SSeeee AAllssoo::

        `dt' for the t distribution which generalizes
        `dcauchy(*, l = 0, s = 1)'.

   TThhee CChhii--SSqquuaarree DDiissttrriibbuuttiioonn

 double dchisq(double x, double df);
 double pchisq(double x, double df);
 double qchisq(double x, double df);
 double rchisq(double df);

        These functions provide information about the chi-
        square distribution with `df' degrees of freedom.
        `dchisq' gives the density, `pchisq' gives the distri-
        bution function `qchisq' gives the quantile function
        and `rchisq' generates random deviates.

        The chi-square distribution with `df' = n degrees of
        freedom has density

          f(x) = 1 / (2^(n/2) Gamma(n/2))  x^(n/2-1) e^(-x/2)

        for x > 0.

   SSeeee AAllssoo::

        `dnchisq', `dgamma', `dexp'.

   TThhee EExxppoonneennttiiaall DDiissttrriibbuuttiioonn

 double dexp(double x, double rate);
 double pexp(double x, double rate);
 double qexp(double x, double rate);
 double rexp(double rate);

        These functions provide information about the exponen-
        tial distribution with rate `rate' (i.e., mean
        `1/rate').  `dexp' gives the density, `pexp' gives the
        distribution function, `qexp' gives the quantile func-
        tion and `rexp' generates random deviates.

        The exponential distribution with rate lambda has den-
        sity

                     f(x) = lambda e^(- lambda x)

        for x >= 0.

   SSeeee AAllssoo::

        `exp', `dchisq' for the chisquare and `dweibull' for
        the Weibull distribution which both generalize the
        exponential.

   TThhee FF DDiissttrriibbuuttiioonn

 double df(double x, double n1, double n2);
 double pf(double x, double n1, double n2);
 double qf(double x, double n1, double n2);
 double rf(double n1, double);

        These functions provide information about the F distri-
        bution with `n1' and `n2' degrees of freedom.  `df'
        gives the density, `pf' gives the distribution function
        `qf' gives the quantile function and `rf' generates
        random deviates.

        The F distribution with n1 and n2 degrees of freedom
        has density

            f(x) =
            Gamma((n1 + n2)/2) / (Gamma(n1/2) Gamma(n2/2))
            (n1/n2)^(n1/2) x^(n1/2 - 1)
            (1 + (n1/n2) x)^-(n1 + n2)/2

        for x > 0.

   SSeeee AAllssoo::

        `dt' for Student's t distribution which is (almost)
        equivalent to `*f(..., n2 = 1)'.

   TThhee GGaammmmaa DDiissttrriibbuuttiioonn

 double dgamma(double x, double shape, double scale);
 double pgamma(double x, double shape, double scale);
 double qgamma(double x, double shape, double scale);
 double rgamma(double x, double shape);

        These functions provide information about the gamma
        distribution with parameters `shape' and `scale'.
        `dgamma' gives the density, `pgamma' gives the distri-
        bution function `qgamma' gives the quantile function
        and `rgamma' generates random deviates.

        The gamma distribution with parameters `shape' = a and
        `scale' = b has density

               f(x) = 1/(b^a Gamma(a)) x^(a-1) e^-(x/b)

        for x > 0, a > 0 and b > 0.

   SSeeee AAllssoo::

        `gamma', `dbeta'.

   TThhee GGeeoommeettrriicc DDiissttrriibbuuttiioonn

 double dgeom(double x, double p);
 double pgeom(double x, double p);
 double qgeom(double x, double p);
 double rgeom(double p);

        These functions provide information about the geometric
        distribution with parameter `p'.  `dgeom' gives the
        density, `pgeom' gives the distribution function,
        `qgeom' gives the quantile function, and `rgeom' gener-
        ates random deviates.

        The geometric distribution has density

                           p(x) = p (1-p)^x

        for x = 0, 1, 2, ...

   TThhee HHyyppeerrggeeoommeettrriicc DDiissttrriibbuuttiioonn

 double dhyper(double x, double N1, double N2, double n);
 double phyper(double x, double N1, double N2, double n);
 double qhyper(double x, double N1, double N2, double n);
 double rhyper(double N1, double N2, double n);

        These functions provide information about the hypergeo-
        metric distribution with parameters `N1', `N2' and `n'.
        `dhyper' gives the density, `phyper' gives the distri-
        bution function `qhyper' gives the quantile function
        and `rhyper' generates random deviates.

        The hypergeometric distribution is used for sampling
        without replacement.  It has density

           p(x) =
           Choose(N1, x) Choose(N2, n-x) / Choose(N1+N2, n)

        for x = 0, ..., n.

   TThhee LLoogg NNoorrmmaall DDiissttrriibbuuttiioonn

 double dlnorm(double x, double meanlog, double sdlog);
 double plnorm(double x, double meanlog, double sdlog);
 double qlnorm(double x, double meanlog, double sdlog);
 double rlnorm(double meanlog, double sdlog);

        These functions provide information about the log nor-
        mal distribution whose logarithm has mean equal to
        `meanlog' and standard deviation equal to `sdlog'.
        `dlnorm' gives the density, `plnorm' gives the distri-
        bution function `qlnorm' gives the quantile function
        and `rlnorm' generates random deviates.

        If `meanlog' or `sdlog' are not specified they assume
        the default values of `0' and `1' respectively.

        The log normal distribution has density

        f(x) = 1/(sqrt(2 pi) sigma x) e^-((log x - mu)^2 / (2 sigma^2))

        where mu and sigma are the mean and standard deviation
        of the logarithm.

   SSeeee AAllssoo::

        `dnorm', etc.

   TThhee LLooggiissttiicc DDiissttrriibbuuttiioonn

 double dlogis(double x, double location, double scale);
 double plogis(double x, double location, double scale);
 double qlogis(double x, double location, double scale);
 double rlogis(double location, double scale);

        These functions provide information about the logistic
        distribution with parameters `location' and `scale'.
        `dlogis' gives the density, `plogis' gives the distri-
        bution function `qlogis' gives the quantile function
        and `rlogis' generates random deviates.

        The Logistic distribution with `location' a and `scale'
        b has density

                f(x) =
                1/b exp((x-a)/b) (1 + exp((x-a)/b))^-2.

   TThhee NNeeggaattiivvee BBiinnoommiiaall DDiissttrriibbuuttiioonn

 double dnbinom(double x, double n, double p);
 double pnbinom(double x, double n, double p);
 double qnbinom(double x, double n, double p);
 double rnbinom(double n, double p);

        These functions provide information about the negative
        binomial distribution with parameters `n' and `p'.
        `dnbinom' gives the density, `pnbinom' gives the dis-
        tribution function, `qnbinom' gives the quantile func-
        tion and `rnbinom' generates random deviates.

        The negative binomial distribution has density

                  p(x) = Choose(x+n-1,x) p^n (1-p)^x

        for x = 0, 1, 2, ...

   SSeeee AAllssoo::

        `dbinom' for the binomial and `dpois' for the Poisson
        distribution.

   TThhee NNoonn--CCeennttrraall CChhii--SSqquuaarree DDiissttrriibbuuttiioonn

 double dnchisq(double x, double df, double lambda);
 double pnchisq(double x, double df, double lambda);
 double qnchisq(double x, double df, double lambda);
 double rnchisq(double df, double lambda);

        These functions provide information about the non-cen-
        tral chi-square distribution with `df' degrees of free-
        dom and non-centrality parameter `lambda'.  `dnchisq'
        gives the density, `pnchisq' gives the distribution
        function, `qnchisq' gives the quantile function and
        `rnchisq' generates random deviates.

        The non-central chi-square distribution with df degrees
        of freedom and non-centrality parameter lambda has den-
        sity

        f(x) = exp(-lambda/2) SUM_{r=0}^infty (lambda^r / 2^r r!)
        pchisq(x, df + 2r)

        for x >= 0.

   SSeeee AAllssoo::

        `dchisq', `dgamma'.

   TThhee NNoorrmmaall DDiissttrriibbuuttiioon

 double dnorm(double x, double mean, double sd);
 double pnorm(double x, double mean, double sd);
 double qnorm(double x, double mean, double sd);
 double rnorm(double mean, double sd);
 
        These functions provide information about the normal
        distribution with mean equal to `mean' and standard
        deviation equal to `sd'.  `dnorm' gives the density,
        `pnorm' gives the distribution function `qnorm' gives
        the quantile function and `rnorm' generates random
        deviates.

        If `mean' or `sd' are not specified they assume the
        default values of `0' and `1', respectively.

        The normal distribution has density

        f(x) = 1/(sqrt(2 pi) sigma) e^-((x - mu)^2/(2 sigma^2))

        where mu is the mean of the distribution and sigma the
        standard deviation.

   SSeeee AAllssoo::

        `dlnorm' for the Lognormal distribution.

   TThhee PPooiissssoonn DDiissttrriibbuuttiioonn

 double dpois(double x, double lambda);
 double ppois(double x, double lambda);
 double qpois(double x, double lambda);
 double rpois(double lambda);

        These functions provide information about the Poisson
        distribution with parameter `lambda'.  `dpois' gives
        the density, `ppois' gives the distribution function
        `qpois' gives the quantile function and `rpois' gener-
        ates random deviates.

        The Poisson distribution has density

                    p(x) = lambda^x exp(-lambda)/x!

        for x = 0, 1, 2, ....

   TThhee SSttuuddeenntt tt DDiissttrriibbuuttiioonn

 double dt(double x, double df);
 double pt(double x, double df);
 double qt(double x, double df);
 double rt(double df);

        These functions provide information about the t distri-
        bution with `df' degrees of freedom.  `dt' gives the
        density, `pt' gives the distribution function, `qt'
        gives the quantile function and `rt' generates random
        deviates.

        The t distribution with n degrees of freedom has den-
        sity

        f(x) = Gamma((n+1)/2) / (sqrt(n pi) Gamma(n/2)) (1 + x^2/n)^-((n+1)/2)

        for all real x.

   SSeeee AAllssoo::

        `df' for the F distribution which generalizes the t
        one.

   TThhee UUnniiffoorrmm DDiissttrriibbuuttiioonn

 double dunif(double x, double min, double max);
 double punif(double x, double min, double max);
 double qunif(double x, double min, double max);
 double runif(double min, double max);

        These functions provide information about the uniform
        distribution on the interval from `min' to `max'.
        `dunif' gives the density, `punif' gives the distribu-
        tion function `qunif' gives the quantile function and
        `runif' generates random deviates.

        If `min' or `max' are not specified they assume the
        default values of `0' and `1' respectively.

        The uniform distribution has density

                          f(x) = 1/(max-min)

        for min <= x <= max.

   TThhee WWeeiibbuullll DDiissttrriibbuuttiioonn

 double dweibull(double x, double shape, double scale);
 double pweibull(double x, double shape, double scale);
 double qweibull(double x, double shape, double scale);
 double rweibull(double shape, double scale);

        These functions provide information about the Weibull
        distribution with parameters `shape' and `scale'.
        `dweibull' gives the density, `pweibull' gives the dis-
        tribution function, `qweibull' gives the quantile func-
        tion and `rweibull' generates random deviates.

        The Weibull distribution with `shape' parameter a and
        `scale' parameter b has density given by

                f(x) = (a/b) (x/b)^(a-1) exp(- (x/b)^a)

        for x > 0.

   SSeeee AAllssoo::

        `dexp' for the Exponential which is a special case of a
        Weibull distribution.

beta

  Signature: (a(); b();  [o]ppret())

info not available
lfastchoose

  Signature: (a(); b();  [o]ppret())

info not available
fastchoose

  Signature: (a(); b();  [o]ppret())

info not available
lchoose

  Signature: (a(); b();  [o]ppret())

info not available
choose

  Signature: (a(); b();  [o]ppret())

info not available
dbeta

  Signature: (a(); b(); c();  [o]ppret())

info not available
dbinom

  Signature: (a(); b(); c();  [o]ppret())

info not available
dcauchy

  Signature: (a(); b(); c();  [o]ppret())

info not available
dchisq

  Signature: (a(); b();  [o]ppret())

info not available
dexp

  Signature: (a(); b();  [o]ppret())

info not available
df

  Signature: (a(); b(); c();  [o]ppret())

info not available
dgamma

  Signature: (a(); b(); c();  [o]ppret())

info not available
dgeom

  Signature: (a(); b();  [o]ppret())

info not available
dhyper

  Signature: (a(); b(); c(); d();  [o]ppret())

info not available
digamma

  Signature: (a();  [o]ppret())

info not available
trigamma

  Signature: (a();  [o]ppret())

info not available
tetragamma

  Signature: (a();  [o]ppret())

info not available
pentagamma

  Signature: (a();  [o]ppret())

info not available
dlnorm

  Signature: (a(); b(); c();  [o]ppret())

info not available
dlogis

  Signature: (a(); b(); c();  [o]ppret())

info not available
dnbinom

  Signature: (a(); b(); c();  [o]ppret())

info not available
dnorm

  Signature: (a(); b(); c();  [o]ppret())

info not available
dpois

  Signature: (a(); b();  [o]ppret())

info not available
dt

  Signature: (a(); b();  [o]ppret())

info not available
dunif

  Signature: (a(); b(); c();  [o]ppret())

info not available
dweibull

  Signature: (a(); b(); c();  [o]ppret())

info not available
fcube

  Signature: (a();  [o]ppret())

info not available
fint

  Signature: (a();  [o]ppret())

info not available
fmax2

  Signature: (a(); b();  [o]ppret())

info not available
fmin2

  Signature: (a(); b();  [o]ppret())

info not available
fmod

  Signature: (a(); b();  [o]ppret())

info not available
fsign

  Signature: (a(); b();  [o]ppret())

info not available
fsquare

  Signature: (a();  [o]ppret())

info not available
gamma

  Signature: (a();  [o]ppret())

info not available
imax2

  Signature: (a(); b();  [o]ppret())

info not available
imin2

  Signature: (a(); b();  [o]ppret())

info not available
lbeta

  Signature: (a(); b();  [o]ppret())

info not available
lgamma

  Signature: (a();  [o]ppret())

info not available
pbeta

  Signature: (a(); b(); c();  [o]ppret())

info not available
pbeta_b

  Signature: (a(); b(); c(); d();  [o]ppret())

info not available
pbinom

  Signature: (a(); b(); c();  [o]ppret())

info not available
pcauchy

  Signature: (a(); b(); c();  [o]ppret())

info not available
pchisq

  Signature: (a(); b();  [o]ppret())

info not available
pexp

  Signature: (a(); b();  [o]ppret())

info not available
pf

  Signature: (a(); b(); c();  [o]ppret())

info not available
pgamma

  Signature: (a(); b(); c();  [o]ppret())

info not available
pgeom

  Signature: (a(); b();  [o]ppret())

info not available
phyper

  Signature: (a(); b(); c(); d();  [o]ppret())

info not available
plnorm

  Signature: (a(); b(); c();  [o]ppret())

info not available
plogis

  Signature: (a(); b(); c();  [o]ppret())

info not available
pnbinom

  Signature: (a(); b(); c();  [o]ppret())

info not available
pnchisq

  Signature: (a(); b(); c();  [o]ppret())

info not available
pnorm

  Signature: (a(); b(); c();  [o]ppret())

info not available
ppois

  Signature: (a(); b();  [o]ppret())

info not available
prec

  Signature: (a(); b();  [o]ppret())

info not available
pt

  Signature: (a(); b();  [o]ppret())

info not available
punif

  Signature: (a(); b(); c();  [o]ppret())

info not available
pweibull

  Signature: (a(); b(); c();  [o]ppret())

info not available
qbeta

  Signature: (a(); b(); c();  [o]ppret())

info not available
qbinom

  Signature: (a(); b(); c();  [o]ppret())

info not available
qcauchy

  Signature: (a(); b(); c();  [o]ppret())

info not available
qchisq

  Signature: (a(); b();  [o]ppret())

info not available
qf

  Signature: (a(); b(); c();  [o]ppret())

info not available
qexp

  Signature: (a(); b();  [o]ppret())

info not available
qgamma

  Signature: (a(); b(); c();  [o]ppret())

info not available
qgeom

  Signature: (a(); b();  [o]ppret())

info not available
qhyper

  Signature: (a(); b(); c(); d();  [o]ppret())

info not available
qlnorm

  Signature: (a(); b(); c();  [o]ppret())

info not available
qlogis

  Signature: (a(); b(); c();  [o]ppret())

info not available
qnbinom

  Signature: (a(); b(); c();  [o]ppret())

info not available
qnchisq

  Signature: (a(); b(); c();  [o]ppret())

info not available
qnorm

  Signature: (a(); b(); c();  [o]ppret())

info not available
qpois

  Signature: (a(); b();  [o]ppret())

info not available
qt

  Signature: (a(); b();  [o]ppret())

info not available
qunif

  Signature: (a(); b(); c();  [o]ppret())

info not available
qweibull

  Signature: (a(); b(); c();  [o]ppret())

info not available
rbeta

  Signature: (a(); b();  [o]ppret())

info not available
rbinom

  Signature: (a(); b();  [o]ppret())

info not available
rcauchy

  Signature: (a(); b();  [o]ppret())

info not available
rchisq

  Signature: (a();  [o]ppret())

info not available
rexp

  Signature: (a();  [o]ppret())

info not available
rf

  Signature: (a(); b();  [o]ppret())

info not available
rgamma

  Signature: (a(); b();  [o]ppret())

info not available
rgeom

  Signature: (a();  [o]ppret())

info not available
rhyper

  Signature: (a(); b(); c();  [o]ppret())

info not available
rlnorm

  Signature: (a(); b();  [o]ppret())

info not available
rlogis

  Signature: (a(); b();  [o]ppret())

info not available
rnbinom

  Signature: (a(); b();  [o]ppret())

info not available
rnorm

  Signature: (a(); b();  [o]ppret())

info not available
rround

  Signature: (a(); b();  [o]ppret())

info not available
trunc

  Signature: (a();  [o]ppret())

info not available
rpois

  Signature: (a();  [o]ppret())

info not available
rt

  Signature: (a();  [o]ppret())

info not available
runif

  Signature: (a(); b();  [o]ppret())

info not available
rweibull

  Signature: (a(); b();  [o]ppret())

info not available
sexp

  Signature: ([o]ppret())

info not available
sign

  Signature: (a();  [o]ppret())

info not available
snorm

  Signature: ([o]ppret())

info not available
sunif

  Signature: ([o]ppret())

info not available
dpsifn_in

  Signature: (x(); n(); kode(); m(); [o]ans(n); int [o]nz(); int [o]ierr())

info not available PDL::R is almost completley untested. Arguments may not be omitted as stated in the documentation. This document and and the PDL::R interface are copyrighted: Copyright (C) 1998 John Lapeyre and may be distributed under the terms in the file COPYING in the PDL distribution. This document is a modified version of the documentation found in the R distribution. It is modified only to provide a description of the PDL calling sytax. The R language including all sources and documentation is copyrighted under the terms of the Gnu Public License: R : A Computer Langage for Statistical Data Analysis Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka The PDL language is copyrighted: Copyright (C) R.J.R. Williams 1997 ([email protected]), Karl Glazebrook ([email protected]) and Tuomas J. Lukka ([email protected]). All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the copyright notice should be included in the file.