mixnorm function

Mixture of Normal distribution

Mixture of Normal distribution

Random generation and density function for a finite mixture of univariate Normal distribution.

rmixnorm( n = 10, weight = 1, mean = 0, sd = 1 ) dmixnorm( x, weight = 1, mean = 0, sd = 1 )

Arguments

  • n: number of observations.
  • x: vector of quantiles.
  • weight: vector of probability weights, with length equal to number of components (kk). This is assumed to sum to 1; if not, it is normalized.
  • mean: vector of means.
  • sd: vector of standard deviations.

Details

Sampling from finite mixture of Normal distribution, with density:

Pr(xw,μ,σ)=i=1kwiN(xμi,σi). Pr(x|\underline{w}, \underline{\mu}, \underline{\sigma}) = \sum_{i=1}^{k} w_{i} N(x|\mu_{i}, \sigma_{i}).

Returns

Generated data as an vector with size nn.

References

Mohammadi, A., Salehi-Rad, M. R., and Wit, E. C. (2013) Using mixture of Gamma distributions for Bayesian analysis in an M/G/1 queue with optional second service. Computational Statistics, 28(2):683-700, tools:::Rd_expr_doi("10.1007/s00180-012-0323-3")

Mohammadi, A., and Salehi-Rad, M. R. (2012) Bayesian inference and prediction in an M/G/1 with optional second service. Communications in Statistics-Simulation and Computation, 41(3):419-435, tools:::Rd_expr_doi("10.1080/03610918.2011.588358")

Author(s)

Reza Mohammadi a.mohammadi@uva.nl

See Also

rnorm, rmixt, rmixgamma

Examples

## Not run: n = 10000 weight = c( 0.3, 0.5, 0.2 ) mean = c( 0 , 10 , 3 ) sd = c( 1 , 1 , 1 ) data = rmixnorm( n = n, weight = weight, mean = mean, sd = sd ) hist( data, prob = TRUE, nclass = 30, col = "gray" ) x = seq( -20, 20, 0.05 ) densmixnorm = dmixnorm( x, weight, mean, sd ) lines( x, densmixnorm, lwd = 2 ) ## End(Not run)