Dear Paul,

On May 5, 2005, at 6:43 AM, Paul Smith wrote:

Dear All

I would like to get the histogram for the following model with
discrete and continuous random variables:

* with probability 1/3, a random number is drawn from the continuous
uniform distribution (min=0, max=1);
* with probability 2/3, a random number is drawn from a different
continuous uniform distribution (min=-1/2, max=1/2).

Any help would be most welcome.

Thanks in advance,

Paul

My approach to generate the data would be

rMyfun <- function(n){
  x1 <- runif(n, 0, 1)
  x2 <- runif(n, -0.5, 0.5)
  ifelse(rbinom(n, 1, 1/3), x1, x2)
}

Hope this helps,

Stephen

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to