-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiHonest.cpp
More file actions
68 lines (58 loc) · 1.99 KB
/
Copy pathMultiHonest.cpp
File metadata and controls
68 lines (58 loc) · 1.99 KB
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
#include "MultiHonest.h"
#include<iostream>
ReachAndMarginMultiHonest::ReachAndMarginMultiHonest(
const int N, const int R,
const DoubleVector& advFractions,
const double fracUniqueHonest)
: ReachAndMargin(N, R, advFractions) {
prUniqueH = new double[NFRACS];
prMultiH = new double[NFRACS];
for (int i = 0; i < NFRACS; i++) {
prUniqueH[i] = prDown[i] * fracUniqueHonest;
prMultiH[i] = prDown[i] - prUniqueH[i];
}
}
ReachAndMarginMultiHonest::~ReachAndMarginMultiHonest() {
DELETE_ARR(prUniqueH);
DELETE_ARR(prMultiH);
}
void ReachAndMarginMultiHonest::probMassIncomingToReachZeroMarginZero() {
const int r = 0, m = 0;
// from (r+1, m) using downstep,
// from (r+1, m+1) using downstep
auto right = get(prevMat, time - 1, r + 1, m);
auto diagonallyUp = get(prevMat, time - 1, r + 1, m + 1);
add(tempA, diagonallyUp, right);
mult(tempB, prDown, tempA);
// from (r, m) using multihonest downstep
auto same_cell = get(prevMat, time - 1, r, m);
mult(tempA, prMultiH, same_cell);
// finally
auto newValue = get(curMat, time, r, m);
add(newValue, tempA, tempB);
}
void ReachAndMarginMultiHonest::probMassIncomingToReachZeroMarginNegOne() {
const int r = 0, m = -1;
// from (r, m+1) using uniquely honest downstep
auto up = get(prevMat, time - 1, r, m + 1);
auto newValue = get(curMat, time, r, m);
mult(newValue, prUniqueH, up);
}
void ReachAndMarginMultiHonest::calcNewValue(const int r, const int m) {
// initialize to zero
//for (int a = 0; a < NFRACS; a++)
// newValue[a] = 0;
if (r >= 1 || (m <= -2 || m >= 1) )
// not a multihonest case
ReachAndMargin::calcNewValue(r, m);
else if (r == 0 && m == 0) {
// this is a special multihonest case
// margin stays the same with prMultiH,
probMassIncomingToReachZeroMarginZero();
}
else if (r == 0 && m == -1) {
// this is a special multihonest case
// it can be reached from (r = 0, m = 0) with prUniqueH
probMassIncomingToReachZeroMarginNegOne();
}
}