Type: | Package |
Title: | Sampling Multivariate Normal Distribution under Linear Constraints |
Version: | 0.1 |
Date: | 2021-10-25 |
Maintainer: | Yunyi Shen <yshen99@wisc.edu> |
Description: | Sample truncated multivariate Normal distribution following Gessner, A., Kanjilal, O., & Hennig, P. (2019). Integrals over Gaussians under Linear Domain Constraints. 108. <doi:10.48550/arXiv.1910.09328>. |
License: | GPL-3 |
Imports: | Rcpp (≥ 1.0.7), MASS |
LinkingTo: | Rcpp, RcppArmadillo |
URL: | https://github.com/YunyiShen/linconGaussR |
BugReports: | https://github.com/YunyiShen/linconGaussR/issues |
RoxygenNote: | 7.1.1 |
NeedsCompilation: | yes |
Packaged: | 2021-10-25 16:28:46 UTC; yunyi |
Author: | Yunyi Shen |
Repository: | CRAN |
Date/Publication: | 2021-10-26 14:10:02 UTC |
Sample Gaussian distribution with linear constraints Taking truncated sample of Gaussian distribution over a linear constraint domain.
Description
Sample Gaussian distribution with linear constraints Taking truncated sample of Gaussian distribution over a linear constraint domain.
Usage
linconGauss(
n,
A,
b,
Sigma,
mu,
x_init = NULL,
intersection = TRUE,
n_retry_init = 1000,
nskp = 5
)
Arguments
n |
number of samples to take |
A |
a matrix with M by D dimensions, the linear constraints, such that Ax+b>=0 |
b |
the offset of the linear constraints with dimension M such that Ax+b>=0 |
Sigma |
covariance matrix of the Gaussian |
mu |
mean vector of the Gaussian |
x_init |
the sample to start with, if NULL, a sample will be drawn using rejection method |
intersection |
bool whether sample from the intersection or the union of the linear constraints, default true, sample from the intersection |
n_retry_init |
how many times to try finding a initial value |
nskp |
how many sample to skip during the sampling routine |
Value
a matrix with truncated sample, row as samples
Examples
my_sample <- linconGauss(100, diag(2),c(0,0),diag(2),c(0,0))
MASS_sample <- MASS::mvrnorm(1000,c(0,0),diag(2))
plot(MASS_sample)
points(my_sample,col = "red")
abline(h=0)
abline(v=0)