Dear R-helpers,

My question is related to how to impose constraints when when sampling from a 
distribution.

For example, suppose I'm sampling a vector from a multivariate normal 
distribution

vbeta <- 100*diag(2)
mbeta <- c(1,1)
ans <- beta <- c(rmvnorm(1,mbeta,vbeta))

ans will thus be a vector with two elements. 

My question is how do I place a restriction on one of the elements of the ans 
vector. For example, suppose my goal is to reject any draw for ans[2] below -1 
and above 1, how should I implement that in the above setting?

Thanks in advance for your help.

Kind Regards

Anup



      
        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to