DISTRIBUTION_factory {convdistr}R Documentation

A factory of DISTRIBUTION classes

Description

Generate a function that creates DISTRIBUTION objects

Usage

DISTRIBUTION_factory(distname, rfunction, ovalfunc)

Arguments

distname

name of the distribution. By convention they are upper case

rfunction

a function to generate random numbers from the distribution

ovalfunc

a function that calculate the oval value, should used only the same arguments that the rfunction

Value

A function that is able to create DISTRIBUTION objects.

Note

The function return a new function, that have as arguments the formals of the rfunction plus a new argument dimnames for the dimension names. If The distribution is unidimensional, the default value dimnames = "rvar" will works well, but if not, the dimnames argument should be specified when the generated function is used as in the example for the new_MyDIRICHLET

Author(s)

John J. Aponte

Examples

new_MYDISTR <- DISTRIBUTION_factory("MYDISTR", rnorm, function(){mean})
d1 <- new_MYDISTR(0,1)
summary(d1)
require(extraDistr)
new_MyDIRICHLET <- DISTRIBUTION_factory('rdirichlet',
                       rdirichlet,
                       function() {
                         salpha = sum(alpha)
                         alpha / salpha
                       })
d2 <- new_MyDIRICHLET(c(10, 20, 70), dimnames = c("A", "B", "C"))
summary(d2)

[Package convdistr version 1.5.3 Index]