Description Usage Arguments Details Examples
View source: R/rstnorm_ineq_cork.R
Sample from multivariate normal distribution with mean 0 and covariance matrix I_d with the constraint that M^t z ≤q m where M is given by ineq.mat and m is given by ineq.vec
1 2 3 4 5 6 7 | rstnorm_ineq_cork = function(
n,
ineq.mat,
ineq.vec,
thin = 1,
burn = 0,
init = NULL)
|
n |
number of elements to generate |
ineq.mat |
Inequality matrix |
ineq.vec |
Inequality vector |
thin |
Take every thinth value from the gibbs sampler |
burn |
Discard the first burn elements generated |
init |
initial z value. If not given, an SVD of ineq.mat happens. |
See Schmidt, Mikkel. "Linearly constrained bayesian matrix factorization for blind source separation." Advances in neural information processing systems. 2009.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # sample on a cube!
M = rbind(c(-1,1,0,0),c(0,0,-1,1))
xmin = 1
xmax = 100
ymin = 1
ymax = 100
m = c(-xmin, xmax, -ymin, ymax)
n = 1000
rr = rstnorm_ineq_cork(n, M, m)
plot(rr[,1], rr[,2])
# sample on a triangle and have the third dimension truncated positive
M = cbind(c(-1, 0, 0), c(0, -1, 0), c(1, 1, 0), c(0, 0, -1))
m = c(0, 0, 3, 0)
n = 10000
rr = rstnorm_ineq_cork(n, M, m)
plot(rr[,1], rr[,2])
hist(rr[,3])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.