Commit ffc82a4c authored by chbauman's avatar chbauman
Browse files

save to change branch

parent 340f05c6
......@@ -12,10 +12,10 @@ struct normal_random_variable {
CovMat transform;
ThetaVector operator()(index_t n_samples) const {
ThetaVector operator()(const 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){
for(index_t i = 0; i < n_samples; ++i){
randomStandardNormal(i, j) = dist_mvn(GEN);
}
}
......
......@@ -54,7 +54,6 @@ static inline Data parse_data(const char* filename) {
Eigen::Map<RowMajorData> mapped_data(raw_data.data(), raw_data.size()/2, 2);
return Data(std::move(mapped_data));
}
static inline decltype(auto) get_likelihood_function_from_data(const char* filename) {
......
......@@ -75,7 +75,8 @@ int main(){
best_thetas.push_back(get_most_likely_theta(thetas, weights));
/// Resampling
resample(weights, resample_count);
resample(weights, resample_count);
#ifdef USE_FOR_VERSION
/// Precomputing indices for mcmc chains
......@@ -112,7 +113,7 @@ int main(){
sample_cov_mat += 0.001 * CovMat::Identity();
sample_cov_mat *= BETA * BETA;
/// MCMC
/// MCMC
normal_random_variable sample {sample_cov_mat};
#ifdef USE_FOR_VERSION
#pragma omp parallel for schedule(static)
......@@ -142,7 +143,7 @@ int main(){
}
#endif
assert(likelihoods.minCoeff() >= 0);
/// Prepare next iteration
std::cout << "Step " << step_count++ << " done.\n";
thetas.swap(thetas_new);
......
......@@ -46,7 +46,7 @@ struct PotentialName<Potential::BUCKINGHAM> {
};
constexpr index_t POP_SIZE = 1000000;
constexpr index_t POP_SIZE = 100000;
constexpr index_t N_DIM = (POTENTIAL == Potential::LENNARD_JONES? 2: 3) + 1;// + 1 for the unknown standard deviation
constexpr index_t MAX_POP_SIZE_FOR_STACK = 5000;
......@@ -56,7 +56,7 @@ typedef Eigen::Matrix<numeric_t, EIGEN_NUM_ROWS_FOR_POP, 1> WeightVector;
typedef Eigen::Matrix<index_t, EIGEN_NUM_ROWS_FOR_POP, 1> CountVector;
typedef Eigen::Matrix<numeric_t, N_DIM, N_DIM> CovMat;
typedef Eigen::Matrix<numeric_t, N_DIM, EIGEN_NUM_ROWS_FOR_POP> PopMatrix;
typedef Eigen::Matrix<numeric_t, N_DIM, EIGEN_NUM_ROWS_FOR_POP> PartPopMatrix;
typedef Eigen::Matrix<numeric_t, N_DIM, -1> PartPopMatrix;
typedef numeric_t (*PotentialFunction)(const numeric_t r, const ThetaVector& theta);
......@@ -75,8 +75,8 @@ extern XoroshiroRandomNumberEngine GEN;
/// Defines
//#define UNIF_PRIOR
//#define USE_BRENTS_METHOD
#define USE_FOR_VERSION
#define USE_BRENTS_METHOD
//#define USE_FOR_VERSION
#define BURNIN 10
#pragma omp threadprivate(GEN)
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