forked from sibyl-team/sib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
params.cpp
59 lines (52 loc) · 1.48 KB
/
params.cpp
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
#include "params.h"
#include <iterator>
#include <algorithm>
using namespace std;
Params::Params(shared_ptr<Proba> const & pi,
shared_ptr<Proba> const & pr,
real_t pseed,
real_t psus,
real_t fp_rate,
real_t fn_rate,
real_t pautoinf,
real_t learn_rate) :
prob_i(pi),
prob_r(pr),
pseed(pseed),
psus(psus),
fp_rate(fp_rate),
fn_rate(fn_rate),
pautoinf(pautoinf),
learn_rate(learn_rate)
{
if (pseed + psus > 1)
throw std::domain_error("pseed and psus are exclusive events but pseed+psus>1");
if (!pi || !pr)
throw std::invalid_argument("invalid probability definition");
}
PriorDiscrete::PriorDiscrete(Proba const & pr, int T) : Proba(T)
{
for (int t = 0; t < T; ++t) {
theta[t] = pr(t);
}
}
std::ostream & operator<<(std::ostream & ost, Params const & p)
{
return ost << "Params("
<< "prob_i=" << *p.prob_i
<< ",prob_r=" << *p.prob_r
<< ",pseed=" << p.pseed
<< ",psus=" << p.psus
<< ",fp_rate=" << p.fp_rate
<< ",fn_rate=" << p.fn_rate
<< ",pautoinf=" << p.pautoinf << ")"
<< ",learn_rate=" << p.learn_rate << ")";
}
std::ostream & operator<<(std::ostream & ost, Proba const & p) { p.print(ost); return ost; }
std::ostream & operator<<(std::ostream & ost, RealParams const & p)
{
ost << "RealParams([";
for (size_t i = 0; i < p.size(); ++i)
ost << (i ? ",":"") << p[i];
return ost << "])";
}