Re: [R] Mixture of Distributions

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Tue, 04 Mar 2008 12:29:24 +0000 (UTC)

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

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 04 Mar 2008 - 12:39:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 04 Mar 2008 - 13:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive