I want to put random numbers come from first gamma [gamma with shape=2 , rate=4]
in vector and from second gamma [gamma with shape=3 , rate=4]
in another vector
x <- rep(0,20)
for (i in 1:20){
U[i] <- runif(1,0,1)
if( U[i] < 0.8){
x[i] <- rgamma(1,shape=2,rate=4)
} else {
x[i] <- rgamma(1,shape=3,rate=4)
}
}
Aucun commentaire:
Enregistrer un commentaire