rpois_mix: Random Generator of a Poisson Mixture

Description Usage Arguments Author(s) Examples

View source: R/rpois_mix.R

Description

Generates random samples of a univariate Poisson mixture.

Usage

1
2
 rpois_mix(n, pi, lambda, plot.it = TRUE, empirical = FALSE, col.pop = "red3",
                     col.empirical = "navy", ...)

Arguments

n

number of observations.

pi

vector of mixture weights.

lambda

vector of (non-negative) parameters.

plot.it

logical, TRUE to plot the histogram with estimated distribution curve.

empirical

logical, TRUE to add the empirical curve ("Kernel Density Estimation") in the plot.

col.pop

a colour to be used in the curve of population density.

col.empirical

a colour to be used in the curve of empirical density.

...

further arguments and graphical parameters passed to hist.

Author(s)

CASTRO, M. O.; MONTALVO, G. S. A.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Generate a sample.
data = rpois_mix(n = 1000, pi = c(0.6, 0.4), lambda = c(10, 15))

## Sample vector.
data$sample
## The classification of each observation.
data$classification
## The histogram of the sample with population density curve.
data$plot

## Not plotting the graphic.
rpois_mix(n = 1000, pi = c(0.6, 0.4), lambda = c(10, 25), plot.it = FALSE)

## Adding the empirical curve to the graphic.
rpois_mix(n = 1000, pi = c(0.6, 0.4), lambda = c(10, 25), plot.it = TRUE,
          empirical = TRUE)

## Changing the color of the curves.
rpois_mix(n = 1000, pi = c(0.6, 0.4), lambda = c(10, 25), plot.it = TRUE,
          empirical = TRUE, col.pop = "blue", col.empirical = "green")

## Using "...".
rpois_mix(n = 1000, pi = c(0.6, 0.4), lambda = c(10, 25), breaks = 300)

matheuscastro43/mixGM documentation built on March 2, 2020, 12:19 a.m.