Learn R Programming

bivariate (version 0.7.0)

21_function_placeholders: Function Objects

Description

Hard-coded functions, representing (runtime) function objects.

DO NOT CALL THESE FUNCTIONS. CALL A CONSTRUCTOR, WHICH SHOULD RETURN A FUNCTION OBJECT.

Usage

#PMF/PDF and CDF
#(all distributions, except the exceptions below)
fobj.f (x, y)
fobj.F (x, y)

#Categorical PMF fobj.gf (a, b)

#Trivariate Normal PDF fobj.f3 (x, y, z)

#Dirichlet PDF fobj.wf (x, y, z = 1 - x - y, …, log=FALSE)

#ECDF fobj.Fh (x, y)

Arguments

x, y, z

Vectors giving the evaluation bins/points. In discrete distributions, they should be integers. In continuous distributions they should be numerics. Currently, missing values, non-finite values and zero-length vectors are not allowed.

a, b

Integer or character vectors, giving the evaluation bins. (Same as x and y above, except that strings are allowed).

log

Logical, if true, return log-transformed densities.

Ignored.

Value

PMFs return a numeric vector, giving mass. P (X = x, Y = y)

PDFs return a numeric vector, giving density.

CDFs return a numeric vector, giving cumulative probability. P (X <= x, Y <= y)

Details

DO NO CALL THESE FUNCTIONS. CALL A CONSTRUCTOR, WHICH SHOULD RETURN A FUNCTION OBJECT.

Uniform and binomial distributions allow evaluation values outside the supported region. (PMFs/PDFs return zero mass/density, and CDFs return the corresponding values).

Poisson evaluation values need to be non-negative.

Categorical string evaluation values need to match group names, taken from the parameter matrix.

Categorical integer evaluation values, need to have: x in [1, ngx], where ngx is the number of x groups (and rows of the parameter matrix). y in [1, ngy], where ngy is the number of y groups (and columns of the parameter matrix).

In Dirichlet distributions, z is optional. And the three variables should be in the interval (0, 1) and sum to one.

Note that kbvpdf objects (often labelled fh), can't be evaluated. (However, the bvmat function can be used to compute density matrices).

Also note that the help pages, linked to in the see also section, have better examples.

References

Refer to the vignette for an overview, references, theoretical background and better examples.

See Also

Uniform For uniform distributions.

Binomial, Poisson and Categorical For other probability distributions of discrete random variables.

Normal, Bimodal, Dirichlet and Nonparametric For other probability distributions of continuous random variables.

Examples

Run this code
# NOT RUN {
f <- nbvpdf ()

x <- -3:3
y <- 0
density <- f (x, y)

cbind (x, y, density)
# }

Run the code above in your browser using DataLab