38 void set(
int i,
double v) {
50 if(std::all_of(can_propose.begin(), can_propose.end(), [](
bool v) {
return not v; })) {
51 assert(
false &&
"*** Cannot set everything to no-propose or else Vector[Half]NormalHypothesis breaks! (loops infinitely on propose)");
57 value = Vector::Zero(n);
58 can_propose.resize(n,
true);
69 for(
auto i=0;i<value.size();i++) {
82 virtual std::optional<std::pair<self_t,double>>
propose()
const override {
90 }
while(not this->can_propose[i]);
104 return std::make_pair(out, f-b);
109 for(
auto i=0;i<value.size();i++) {
117 virtual size_t hash()
const override {
118 if(value.size() == 0)
return 0;
120 size_t output = std::hash<double>{}(
value(0));
121 for(
auto i=1;i<value.size();i++) {
122 hash_combine(output, std::hash<double>{}(
value(i)));
128 return value.size() == h.
value.size() and value == h.
value;
131 virtual std::string
string(std::string prefix=
"")
const override {
132 std::string out = prefix+
"NV<";
133 for(
auto i=0;i<value.size();i++) {
136 if(value.size()>0) out.erase(out.length()-1);
T myrandom(T max)
Definition: Random.h:176
virtual double compute_prior() override
Definition: VectorHalfNormalHypothesis.h:65
virtual double compute_likelihood(const data_t &data, const double breakout=-infinity) override
Compute the likelihood of a collection of data, by calling compute_single_likelihood on each...
Definition: VectorHalfNormalHypothesis.h:77
VectorHalfNormalHypothesis()
Definition: VectorHalfNormalHypothesis.h:30
Definition: MCMCable.h:14
virtual self_t restart() const override
Definition: VectorHalfNormalHypothesis.h:107
double MEAN
Definition: VectorHalfNormalHypothesis.h:20
double operator()(int i) const
Definition: VectorHalfNormalHypothesis.h:33
void set_can_propose(size_t i, bool b)
Set whether we can propose to each element of b or not.
Definition: VectorHalfNormalHypothesis.h:46
double prior
Definition: Bayesable.h:42
virtual bool operator==(const self_t &h) const override
Definition: VectorHalfNormalHypothesis.h:127
double SD
Definition: VectorHalfNormalHypothesis.h:21
std::string str(BindingTree *t)
Definition: BindingTree.h:195
VectorHalfNormalHypothesis(int n)
Definition: VectorHalfNormalHypothesis.h:31
virtual std::string string(std::string prefix="") const override
Definition: VectorHalfNormalHypothesis.h:131
double PROPOSAL_SCALE
Definition: VectorHalfNormalHypothesis.h:22
double random_normal(double mu=0, double sd=1.0)
Definition: Random.h:39
virtual std::optional< std::pair< self_t, double > > propose() const override
Definition: VectorHalfNormalHypothesis.h:82
constexpr double infinity
Definition: Numerics.h:20
T logplusexp(const T a, const T b)
Definition: Numerics.h:131
const double LOG2
Definition: Numerics.h:18
virtual size_t hash() const override
Definition: VectorHalfNormalHypothesis.h:117
std::vector< Args... > data_t
Definition: Bayesable.h:39
Vector value
Definition: VectorHalfNormalHypothesis.h:24
std::vector< bool > can_propose
Definition: VectorHalfNormalHypothesis.h:28
Definition: VectorHalfNormalHypothesis.h:13
void set_size(size_t n)
Definition: VectorHalfNormalHypothesis.h:56
A class is MCMCable if it is Bayesable and lets us propose, restart, and check equality (which MCMC d...
T normal_lpdf(T x, T mu=0.0, T sd=1.0)
Definition: Random.h:45
Eigen::VectorXf Vector
Definition: EigenLib.h:17
size_t size() const
Definition: VectorHalfNormalHypothesis.h:61