Commit d92e4397 authored by stefanow's avatar stefanow
Browse files

Merge branch 'master' of gitlab.ethz.ch:stefanow/tmcmc

parents c37341d2 340f05c6
......@@ -5,7 +5,6 @@ static std::normal_distribution<> dist_mvn;
/// Struct that returns a sample of a 'N_DIM'-dimensional Gaussian with mean zero and covariance matrix
/// 'transform'
struct normal_random_variable {
normal_random_variable(CovMat const& covar){
Eigen::SelfAdjointEigenSolver<CovMat> eigenSolver(covar);
transform = eigenSolver.eigenvectors() * eigenSolver.eigenvalues().cwiseSqrt().asDiagonal();
......@@ -13,10 +12,12 @@ struct normal_random_variable {
CovMat transform;
ThetaVector operator()() const {
ThetaVector randomStandardNormal;
for(index_t i = 0; i < N_DIM; ++i) {
randomStandardNormal(i) = dist_mvn(GEN);
ThetaVector operator()(index_t n_samples) const {
PartPopMatrix randomStandardNormal(N_DIM, n_samples);
for(index_t j = 0; j < N_DIM; ++j) {
for(index_t i = 0; i < n_samples; +i){
randomStandardNormal(i, j) = dist_mvn(GEN);
}
}
return transform * randomStandardNormal;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment