Learn R Programming

convdistr (version 1.6.1)

DISTRIBUTION_factory: A factory of DISTRIBUTION classes

Description

Generate a function that creates DISTRIBUTION objects

Usage

DISTRIBUTION_factory(distname, rfunction, ovalfunc)

Value

A function that is able to create DISTRIBUTION objects.

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

Author

John J. Aponte

Examples

Run this code
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)

Run the code above in your browser using DataLab