Commit ff17222a authored by chbauman's avatar chbauman
Browse files

positive prior

parent 30892135
......@@ -69,7 +69,7 @@ Eigen::Matrix<numeric_t, N_DIM - 1, 1> get_exact_solution() {
constexpr numeric_t var_mean = (POTENTIAL == Potential::LENNARD_JONES? 4.823: 1.26075);
static std::normal_distribution<numeric_t> normal_prior(1.0, NORMAL_PRIOR_STDDEV); // 0.2 * 0.2
static std::gamma_distribution<numeric_t> var_dist(var_mean * var_mean, var_mean);
static std::uniform_real_distribution<numeric_t> unif_dist(-1.,1.);
static std::uniform_real_distribution<numeric_t> unif_dist(0.,1.);
inline static PopMatrix prior_sample(const index_t n_samples){
PopMatrix prior(N_DIM, n_samples);
......@@ -78,7 +78,7 @@ inline static PopMatrix prior_sample(const index_t n_samples){
for(index_t i = 0; i < N_DIM - 1; ++i){
prior(i,j) = unif_dist(GEN) * BOUND;
}
prior(N_DIM - 1, j) = std::abs(unif_dist(GEN)) * BOUND;
prior(N_DIM - 1, j) = unif_dist(GEN) * BOUND;
}
#else
const auto exact_solution = get_exact_solution();
......@@ -143,7 +143,7 @@ inline static PopMatrix mcmc(const ThetaVector & theta, const index_t rck, const
numeric_t particle_prop_likelihood;
particle_prop = sample_mvn(1, particle, sample_cov_mat);
#ifdef UNIF_PRIOR
if(particle_prop.cwiseAbs().maxCoeff() < BOUND && particle_prop(N_DIM - 1) > 0){
if(particle_prop.cwiseAbs().maxCoeff() <= BOUND && particle_prop.minCoeff() >= 0){
particle_prop_likelihood = likelihood(particle_prop);
if(acc_dist(GEN) <= std::pow(particle_prop_likelihood / particle_likelihood, rho_curr)){
particle = particle_prop;
......@@ -163,7 +163,7 @@ inline static PopMatrix mcmc(const ThetaVector & theta, const index_t rck, const
#else
new_thetas.col(i) = particle;
#endif
/*
/*
std::cout << "Cov mat " << sample_cov_mat << "\n"
<< "cur part " << particle << "\n"
<< "prop part " << particle_prop << "\n"
......@@ -187,5 +187,6 @@ Eigen::Matrix<numeric_t, N_DIM - 1, 1> relative_error_to_exact_solution(const Th
ThetaVector get_most_likely_theta(const PopMatrix& thetas, const WeightVector& weights) {
int index_of_max;
weights.maxCoeff(&index_of_max);
std::cout << thetas.col(index_of_max).transpose() << "<- best theta\n";
return thetas.col(index_of_max);
}
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