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.655421740.69146246 0.72574688 0.75803635 0.7881446 0.81593987]
These are special functions and distributions from the math libraryof the statistics package, R. Threading is supported, as in theexample above in which the normal distribution function with mean0, and standard deviation 1, is evaluated for ten values.
Note that all the functions of the form 'rdist' return randomnumbers derived from a single random number generator which givesuniform deviates. The generator of uniform deviates can beselected. Currently only one is supplied-- the one from the originalR code, sunif. You can select the generator of uniform deviatesbefore 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 isthe default generator. You can use this example xsub code tocreate an interface to another generator of random deviates, andthen 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 gammafunction and the natural logarithm of the gamma func-tion.
The functions `digamma', `trigamma', `tetragamma' and`pentagamma' return the first, second, third and fourthderivatives of the logarithm of the gamma function.
The functions `choose' and `lchoose' return binomialcoefficients 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' givesthe density, `pbeta' the distribution function, `qbeta'the quantile function and `rbeta' generates randomdeviates.
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 theGamma 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 binomialdistribution with parameters `n' and `p'. `dbinom'gives the density, `pbinom' gives the distributionfunction `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 Cauchydistribution with location parameter `location' andscale parameter `scale'.
`dcauchy', `pcauchy', and `qcauchy' are respectivelythe density, distribution function and quantile func-tion of the Cauchy distribution. `rcauchy' generatesrandom deviates from the Cauchy.
The Cauchy distribution with location l and scale s hasdensity
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 functionand `rchisq' generates random deviates.
The chi-square distribution with `df' = n degrees offreedom 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 thedistribution 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' forthe Weibull distribution which both generalize theexponential.
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' generatesrandom deviates.
The F distribution with n1 and n2 degrees of freedomhas 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 gammadistribution with parameters `shape' and `scale'.`dgamma' gives the density, `pgamma' gives the distri-bution function `qgamma' gives the quantile functionand `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 geometricdistribution with parameter `p'. `dgeom' gives thedensity, `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 functionand `rhyper' generates random deviates.
The hypergeometric distribution is used for samplingwithout 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 functionand `rlnorm' generates random deviates.
If `meanlog' or `sdlog' are not specified they assumethe 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 deviationof 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 logisticdistribution with parameters `location' and `scale'.`dlogis' gives the density, `plogis' gives the distri-bution function `qlogis' gives the quantile functionand `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 negativebinomial 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 Poissondistribution.
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 distributionfunction, `qnchisq' gives the quantile function and`rnchisq' generates random deviates.
The non-central chi-square distribution with df degreesof 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 normaldistribution with mean equal to `mean' and standarddeviation equal to `sd'. `dnorm' gives the density,`pnorm' gives the distribution function `qnorm' givesthe quantile function and `rnorm' generates randomdeviates.
If `mean' or `sd' are not specified they assume thedefault 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 thestandard 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 Poissondistribution with parameter `lambda'. `dpois' givesthe 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 thedensity, `pt' gives the distribution function, `qt'gives the quantile function and `rt' generates randomdeviates.
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 tone.
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 uniformdistribution 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 thedefault 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 Weibulldistribution 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 aWeibull 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.