Description Usage Arguments Value Examples
This function compute the value of Probability Density/Mass Function (pdf/pmf) for any univariate distribution at point t, i.e. f(t) for continues random variable T, or P(T = t) for discrete random variable.
Unlike the common pdf's/pmf's of other distributions (such as dnorm
, dpois
and etc.) the name of the introduced pdf
function is fix for any distribution and the name of distribution is considered as an argument of this function.
So the pdf
function is applicable for any kind of distribution with an unique form but by considering the name of T distribution (and its parameters) as two arguments of pdf
function.
1 |
T.dist |
The distribution name of the random variable is determined by characteristic element |
T.dist.par |
A vector of distribution parameters with considered ordering in |
t |
A real number or a vector of real numbers. |
This function gives the value of probability density function (pdf) at point t
for continues random variable, or gives the value of probability mass function (pmf) at point t
for discrete random variable.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | pdf(T.dist="norm", T.dist.par=c(0,1), t=0) # Is equal to dnorm(0)
pdf(T.dist="t", T.dist.par=c(7), -2) # Is equal to dt(-2,7)
pdf(T.dist="pois", T.dist.par=5, 5) # Is equal to dpois(5,5)
## The function is currently defined as
function (T.dist, T.dist.par, t)
{
dDis = paste("d", T.dist, sep = "", collapse = "")
if (length(T.dist.par) == 1) {
pdf.t = do.call(dDis, list(t, T.dist.par[1]))
}
else {
if (length(T.dist.par) == 2) {
pdf.t = do.call(dDis, list(t, T.dist.par[1], T.dist.par[2]))
}
else {
pdf.t = do.call(dDis, list(t, T.dist.par[1], T.dist.par[2],
T.dist.par[3]))
}
}
return(pdf.t)
}
|
Attaching package: 'DISTRIB'
The following object is masked from 'package:grDevices':
pdf
The following object is masked from 'package:base':
q
[1] 0.3989423
[1] 0.06313534
[1] 0.1754674
function (T.dist, T.dist.par, t)
{
dDis = paste("d", T.dist, sep = "", collapse = "")
if (length(T.dist.par) == 1) {
pdf.t = do.call(dDis, list(t, T.dist.par[1]))
}
else {
if (length(T.dist.par) == 2) {
pdf.t = do.call(dDis, list(t, T.dist.par[1], T.dist.par[2]))
}
else {
pdf.t = do.call(dDis, list(t, T.dist.par[1], T.dist.par[2],
T.dist.par[3]))
}
}
return(pdf.t)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.