Mixture of Distributions
David Winsemius <dwinsemius at comcast.net> wrote in news:Xns9A56ED77CB8C4dNOTwinscomcast at 80.91.229.13:
#-----toy code-------
rf1 <- function(n){rnorm(n,0,1)} ## normal distribution with mean=0
rf2 <- function(n){rnorm(n,4,1)} ## normal distribution with mean=4
rf3 <- function(n){rnorm(n,9,1)} ## normal distribution with mean=9
S0 <- cbind(rf1(10),rf2(10),rf3(10))
p1 <- 0.2; p2 <- 0.3; p3 <-0.5
set.seed<-37
That doesn't do anything useful. set.seed(123) ...will result in an ix that has at least one of each of "1", "2", and "3", .
set.seed(5) ix <- sample(c(1,2,3),10,prob=c(p1,p2,p3),replace=TRUE) ix
[1] 3 2 1 3 3 2 2 1 1 3
David Winsemius