cdf: Cumulative density function (cdf)

Description Usage Arguments Value Examples

Description

This function compute the Cumulative Density Function (cdf) value of any univariate distribution in point t, i.e. P(T ≤q 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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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)
  }

Example output

Attaching package:DISTRIBThe following object is masked frompackage:grDevices:

    pdf

The following object is masked frompackage:base:

    q

[1] 0.5
[1] 0.04280966
[1] 0.006737947
[1] 0.6159607
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)
}

DISTRIB documentation built on May 2, 2019, 2:51 p.m.