Commit a4ad14f4 authored by stefanow's avatar stefanow
Browse files

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

parents b9b8cc76 3838c275
......@@ -88,6 +88,7 @@ int main(){
/// MCMC
index_t ct = 0;
normal_random_variable sample {sample_cov_mat};
#pragma omp parallel shared(sample_mean, sample_cov_mat, rho_curr, thetas)
{
#pragma omp single
......@@ -96,7 +97,7 @@ int main(){
if(rck > 0){
#pragma omp task firstprivate(ct, rck)
{
thetas_new.middleCols(ct, rck) = mcmc(thetas.col(k), rck,
thetas_new.middleCols(ct, rck) = mcmc(sample, thetas.col(k), rck,
sample_mean, sample_cov_mat, rho_curr, likelihoods, likelihoods_old, likelihood, k, ct);
}
ct += rck;
......
......@@ -127,7 +127,7 @@ inline static void resample(const WeightVector & weights, CountVector & resample
/// Do 'rck' steps of MCMC rck times
template <typename Likelihood>
inline static PopMatrix mcmc(const ThetaVector & theta, const index_t rck, const ThetaVector & sample_mean,
inline static PopMatrix mcmc(const normal_random_variable & sample, const ThetaVector & theta, const index_t rck, const ThetaVector & sample_mean,
const CovMat & sample_cov_mat, const numeric_t rho_curr, WeightVector & new_likelihoods,
const WeightVector & likelihoods, const Likelihood & likelihood, const index_t k, const index_t ct){
PopMatrix new_thetas(N_DIM, rck);
......@@ -141,7 +141,7 @@ inline static PopMatrix mcmc(const ThetaVector & theta, const index_t rck, const
for(index_t i = 0; i < rck; ++i){
#endif
numeric_t particle_prop_likelihood;
particle_prop = sample_mvn(1, particle, sample_cov_mat);
particle_prop = particle + sample();
#ifdef UNIF_PRIOR
if(particle_prop.cwiseAbs().maxCoeff() <= BOUND && particle_prop.minCoeff() >= 0){
particle_prop_likelihood = likelihood(particle_prop);
......
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