-
Notifications
You must be signed in to change notification settings - Fork 41
/
bayesnet.h
86 lines (68 loc) · 1.34 KB
/
bayesnet.h
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
/*
* bayesnet.h
* peer
*
* Created by Leopold Parts on 03/11/2010.
* Copyright 2010 __MyCompanyName__. All rights reserved.
*
*/
#ifndef __BAYESNET_H__
#define __BAYESNET_H__
#include "Eigen/Eigen"
#include "array_helper.h"
#include <iostream>
using namespace std;
using namespace Eigen;
class cBayesNet {
public:
int N;
int components;
};
/**
* Abstract base class for all Bayes Net nodes
*/
class cNode {
public:
PMatrix E1;
PMatrix prior;
double bound;
virtual double entropy();
virtual double calcBound(cBayesNet &net);
virtual void update(cBayesNet &net);
#ifndef SWIG
PMatrix getE1();
#endif
};
/**
* Dirichlet Node - simple test node to implement (not used in PEER).
*/
class cDirichletNode : public cNode {
protected:
PVector a0;
PVector a;
PVector lnE;
public:
cDirichletNode(int dim, float prior);
double entropy();
double calcBound(cBayesNet &net);
void update(cBayesNet &net);
};
/**
* Gamma Node - prior for precisions
*/
class cGammaNode : public cNode {
public:
double pa;
double pb;
PMatrix lnE;
PMatrix a;
PMatrix b;
cGammaNode();
cGammaNode(int dim, float prior_val_a, float prior_val_b, PMatrix E1_val);
double entropy();
double calcBound(cBayesNet &net);
void update(cBayesNet &net);
void updateMoments();
void getE1(float64_t** matrix,int32_t* rows,int32_t* cols);
};
#endif