rexpmix: Simulate from Mixtures of Exponentials

Description Usage Arguments Value See Also Examples

View source: R/expReliabilityMixEM.R

Description

Simulate from a mixture of univariate exponential distributions.

Usage

1
rexpmix(n, lambda = 1, rate = 1)

Arguments

n

Number of cases to simulate.

lambda

Vector of mixture probabilities, with length equal to m, the desired number of components (subpopulations). This is assumed to sum to 1.

rate

Vector of component rates.

Value

rexpmix returns an n-vector sampled from an m-component mixture of univariate exponential distributions.

See Also

rnormmix, rmvnormmix for Gaussian mixtures, rweibullmix for mixture of Weibull distributions.

Examples

1
2
3
4
5
6
7
8
9
## Generate data from a 2-component mixture of exponentials.
n=300 # sample size
m=2 # nb components
lambda=c(1/3, 2/3); rate = c(1,1/10) # parameters
set.seed(1234)
x <- rexpmix(n, lambda, rate) # iid ~ exp mixture

## histogram of the simulated data.
hist(x, col=8)

Example output

mixtools package, version 1.1.0, Released 2017-03-10
This package is based upon work supported by the National Science Foundation under Grant No. SES-0518772.

mixtools documentation built on Feb. 7, 2020, 5:12 p.m.