mixnorm: The mixture of normal distributions

Description Usage Arguments Details Value References See Also Examples

Description

Density, distribution function and random generation for the mixture of normals with each component specified by mean and sd, and mixture weights by prob. paramExample gives detailed parameters for some examples specified by type.

Usage

1
2
3
4

Arguments

x

vector of locations.

n

integer; number of observations.

mean

vector of means for each mixture component.

sd

vector of standard deviations for each mixture component.

prob

vector of prior probability for each mixture component (i.e. mixture weights).

type

a (case insensitive) character string of example name; It includes examples from Marron & Wand (1992): "MW1", ..., "MW15", or equivalently "guass", "skewed_unimodal", "strong_skewed", "kurtotic_unimodal", "outlier", "bimodal", "separated_bimodal", "skewed_bimodal", "trimodal", "claw", "double_claw", "asymmetric_claw", "asymmetric_double_claw", "smooth_comb", "discrete_comb"; It also includes "harp" example from Li et al. (2016).

...

further arguments passed to dnorm and pnorm.

Details

Users have to either provide mean, sd and optionally prob; or type. In case of providing type, the values of mean, sd and prob are ignored.

If prob is not specified it assumes the default value of equal weights. Each component is computed via dnorm, pnorm and rnorm.

Value

dmixnorm gives the density, pmixnorm gives the distribution function, and rmixnorm generates random deviates.

The length of the result is determined by n for rmixnorm, and is the length of x for dmixnorm and pmixnorm.

paramExample gives a data frame with components mean, sd and prob.

References

Li, H., Munk, A., Sieling, H., and Walther, G. (2016). The essential histogram. arXiv:1612.07216.

Marron, J. S., & Wand, M. P. (1992). Exact mean integrated squred error. The Annals of Statistics, 20(2), 712–736.

See Also

Normal for standard normal distributions; Distributions for other standard distributions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Example claw 
type = "claw" # or equivalently "MW10"
#     generate random numbers
n = 500
Y = rmixnorm(n, type = type)
#     compute the density
x = seq(min(Y), max(Y), length.out = n)
f = dmixnorm(x, type = type)
#     compute the distribution
F = pmixnorm(x, type = type)
#     plots
op = par(mfrow = c(1,2))
plot(x, f, type = "l", main = "Claw Density")
points(Y, rep(0,n))
plot(x, F, type = "l", main = "Claw Distribution")
points(Y, rep(0,n))
par(op)

essHist documentation built on April 9, 2018, 5:04 p.m.