-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdates.hpp
97 lines (78 loc) · 4.35 KB
/
updates.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <vector>
#include <iostream>
#include <cmath>
#include <random>
#include <iomanip>
#include "modelfunctions.hpp"
#include "calculate_accept_prob.hpp"
#include "function_evaluation.hpp"
using namespace std;
#ifndef UPDATES_HPP
#define UPDATES_HPP
/*Sample the proposal, calculate the acceptance probability and update process accordingly*/
void update_process(const int &k, const int &ip,
vector<vector<vector<vector<double> > > > &processes,
const vector<vector<int> > &ind, const vector<vector<double> > &covariates_k,
vector<double> &assigned_level_current, const double &baseline_k,
const vector<double> &response_k, const vector<int> &number_trials_k,
const double ¶m_k, const string &set, const vector<int> &neighbours,
const vector<double> &weights,
const vector<vector<double> > & sample_boundaries,
const vector<vector<vector<double> > > &A_k,
const vector<vector<int> > &low_sets, const vector<vector<int> > &upp_sets,
const vector<vector<vector<int> > > &pos_cov,
const double &volume_sample_space,
const double &DELTA_MIN, const double &DELTA_MAX,
const double &omega, const int &dim, const double &p, const double &q,
const double &eta, const double &p_birth, const double &p_death,
double &sum_levels, int &number_jumps, int &number_jumps_subprocess,
const int & maximum_jumps, mt19937 &generator,
void (*model_log_like)(const double &, const double &, const double &,
const double &, const int &, const double &, double &));
/*Update the random effects for all K regions*/
void update_baseline(vector<double> &baseline, const int&K,const vector<vector<double> > &response,
const vector<vector<int> > &number_trials,
const vector<vector<double> > &assigned_level,
const vector<vector<int> > &neighbours,const vector<vector<double> > &weights,
const vector<double> &sum_weights, vector<double> &mean,
const vector<double> ¶m, const double &tau, mt19937 &generator,
void (*model_log_like)(const int &, const vector<double> &, const double &,
const double &, const vector<double> &,
const vector<int> &, const double &, double &));
/*Update the spatial smoothing parameter for the random effects*/
void update_tau(double &tau, const vector<double> &sum_weights,
const vector<double> &random_effects, const vector<vector<double> > weights,
const vector<vector<int> > neighbours, const int &K,
const double &alpha_tau, const double &beta_tau, mt19937 &generator);
/*Update additional parameter in the distribution*/
void update_param(const string &model, vector<double> ¶m, const int &K,
const vector<vector<double> > &level, const vector<double> &random_effect,
const vector<vector<double> > &number_claims, const double &alpha_param,
const double &beta_param, mt19937 &generator);
/*Sample proposed support point and associated level for a subprocess*/
vector<vector<double> > sample_proposal_birth(const int &ip,
const vector<vector<vector<double> > > &process,
const vector<vector<int> > &ind,
const vector<vector<double> >&sample_boundaries,
const double &DELTA_MIN, const double &DELTA_MAX,
const vector<int> &low, const vector<int> &upp,
const vector<vector<vector<int > > > &pos_cov,
mt19937 &generator);
/*Sample support point and associated level to be proposed for being removed from the subprocess*/
vector<vector<double> > sample_proposal_death(const int &ip,
vector<vector<vector<double> > > &process,
const vector<vector<int> > &ind,
const double &DELTA_MIN, const double &DELTA_MAX,
const vector<int> &low, const vector<int> &upp,
const vector<vector<vector<int > > > &pos_cov,
mt19937 &generator);
/*Sample proposed support point and associated level for a subprocess for a shift being proposed*/
vector<vector<double> > sample_proposal_shift(const int &ip,
vector<vector<vector<double> > > &process,
const vector<vector<int> > &ind,
const vector<vector<double> > &sample_boundaries,
const double &DELTA_MIN, const double &DELTA_MAX,
const vector<int> &low, const vector<int> &upp,
const vector<vector<vector<int > > > &pos_cov,
double &sum_levels, mt19937 &generator);
#endif