Learn R Programming

DISTRIB (version 1.0)

cdf: Cumulative density function (cdf)

Description

This function compute the Cumulative Density Function (cdf) value of any univariate distribution in point $t$, i.e. $P(T \leq t)$. Unlike the common cdf's of other distributions (such as pnorm, ppois and etc.) the name of the introduced cdf function is fix in which the name of distribution is considered as an argument. So the cdf function is applicable for any kind of distribution with a unique form but by considering the name of distribution as a parameter (argument) of cdf function.

Usage

cdf(T.dist, T.dist.par, t)

Arguments

T.dist
The distribution name of the random variable is determined by characteristic element T.dist. The names of distributions is similar to stats package.
T.dist.par
A vector of distribution parameters with considered ordering in stats package.
t
A real number or a vector of real numbers. cdf function compute the cumulative density function (cdf) of a distribution in point t.

Value

This function gives the value of cumulative density function (cdf) at point t.

Examples

Run this code
# Example:
cdf(T.dist="norm", T.dist.par=c(0,1), 0)
cdf(T.dist="t", T.dist.par=c(7), -2)
cdf(T.dist="pois", T.dist.par=5, 0) # Equal to  dpois(0,5)
cdf(T.dist="pois", T.dist.par=5, 5)


## The function is currently defined as
function (T.dist, T.dist.par, t) 
{
    pDis = paste("p", T.dist, sep = "", collapse = "")
    if (length(T.dist.par) == 1) {
        cdf.t = do.call(pDis, list(t, T.dist.par[1]))
    }
    else {
        if (length(T.dist.par) == 2) {
            cdf.t = do.call(pDis, list(t, T.dist.par[1], T.dist.par[2]))
        }
        else {
            cdf.t = do.call(pDis, list(t, T.dist.par[1], T.dist.par[2], 
                T.dist.par[3]))
        }
    }
    return(cdf.t)
  }

Run the code above in your browser using DataLab