R/rmix.binom.R

rmix.binom <-
function(n,alpha,theta,size)
#n:      sample size.
#alpha:  vector of mixture probabilities.
#theta:  vector of probabilities of success of each component.
#size:   number of trials.
{
	m=length(theta)
	alpha=alpha/sum(alpha)
	data=c()
	nindex=rmultinom(1,n,alpha)
	for(i in 1:m)
		data=c(data,rbinom(nindex[i],size,theta[i]))
	data
}

Try the MixtureInf package in your browser

Any scripts or data that you put into this service are public.

MixtureInf documentation built on May 2, 2019, 3:32 p.m.