mixnorm: Generating a random sample from the specified mixture of...

Description Usage Arguments Details Value References See Also Examples

Description

Generating a random sample of size n from the normal mixture defined by expression (2.3) of Marron and Wand (1992).

Usage

1
mixnorm(n, w, mu, sdev)

Arguments

n

desired sample size,

w

vector of weighs (positive numbers between 0 and 1 that add up to one),

mu

vector of means,

sdev

vector of standard deviations.

Details

Producing a random sample of size n from the normal mixture defined by the vector of weights w, the vector of means μ, and the vector of standard deviations σ. See Marron and Wand (1992). It is assumed that the normals are defined as parsimonious as possible. The normal distributions in the mixture should be ordered such that the means in μ are arranged in a nondecreasing order.

Value

A random sample of size n from the specified mixture of normals.

References

Marron, J.S., Wand, M.P. (1992). Exact Mean Integrated Squared Error. The Annals of Statistics, 20(2), 712-736.

See Also

ISE_mixnorm, h_isemixnorm, MISE_mixnorm.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
# Generating a sample of size n=300 from the separated bimodal density of Marron and Wand (1992).
w=c(0.5,0.5)
mu=c(-3/2,3/2)
sdev=c(1/2,1/2)
dat=mixnorm(300,w,mu,sdev) # generated data vector
arg=seq(-4,4,len=1000)  # argument
f=w[1]*dnorm(arg,mu[1],sd=sdev[1])+w[2]*dnorm(arg,mu[2],sd=sdev[2])     # true density
dev.new()
hist(dat,freq=F,ylab="",main="",cex.lab=1.7,cex.axis=1.7,xlim=c(-4,4),lwd=2,ylim=c(0,0.45),
col='grey')
title(main="Separated bimodal density",cex.main=1.7)
legend(-5,0.4,legend="n=300",cex=2,bty="n")
lines(arg,f,lwd=3,'l')

## End(Not run)

ICV documentation built on May 2, 2019, 7:31 a.m.

Related to mixnorm in ICV...