Description Usage Arguments Value References Examples
Random vector generation for the truncated multivariate normal distribution using a Gibbs sampler.
1 |
n |
number of samples to be generated |
Mean |
mean vector |
Sigma |
covariance matrix |
D |
matrix of linear constraints |
lower |
vector of lower bounds |
upper |
vector of upper bounds |
init |
vector of initial values for the Gibbs sampler. Must satisfy the linear constraints. |
Sigma_chol |
the lower triangular cholesky of the covariance matrix. Only one of Sigma and Sigma_chol can be NULL. |
a matrix of samples with each column being an idependent sample.
Li, Y., & Ghosh, S. K. (2015). Efficient sampling methods for truncated multivariate normal and student-t distributions subject to linear inequality constraints. Journal of Statistical Theory and Practice, 9(4), 712-732.
1 2 3 4 5 6 7 8 9 10 | Mean = rep(0,2)
rho = 0.5
Sigma = matrix(c(10,rho,rho,0.1),2,2)
D = matrix(c(1,1,1,-1),2,2)
varp = Sigma[1,1]+Sigma[2,2]+2*Sigma[1,2] # var of the sum
varm = Sigma[1,1]+Sigma[2,2]-2*Sigma[1,2] # var of the diff
sd = c(sqrt(varp),sqrt(varm))
lower = -1.5*sd; upper = 1.5*sd; init = rep(0,2)
n = 20
rtmvn(n,Mean,Sigma,D,lower,upper,init)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.