21_function_placeholders: Function Objects

Description Usage Arguments Details Value References See Also Examples

Description

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

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#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.

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.

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)

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

1
2
3
4
5
6
7
f <- nbvpdf ()

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

cbind (x, y, density)

Example output

      x y     density
[1,] -3 0 0.001768052
[2,] -2 0 0.021539279
[3,] -1 0 0.096532353
[4,]  0 0 0.159154943
[5,]  1 0 0.096532353
[6,]  2 0 0.021539279
[7,]  3 0 0.001768052

bivariate documentation built on April 11, 2021, 9:06 a.m.