[01a998]: src / modules / glm / samplers / AMFactory.cc  Maximize  Restore  History

Download this file

77 lines (65 with data), 1.6 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
69
70
71
72
73
74
75
76
#include <config.h>
#include <string>
#include "BinaryFactory.h"
#include "AMFactory.h"
#include "AMMethod.h"
#include "Linear.h"
#include <graph/StochasticNode.h>
#include <graph/LinkNode.h>
#include <distribution/Distribution.h>
using std::string;
using std::vector;
namespace glm {
AMFactory::AMFactory()
: GLMFactory("glm::Auxiliary-Mixture")
{}
bool AMFactory::checkOutcome(StochasticNode const *snode,
LinkNode const *lnode) const
{
string linkname;
if (lnode) {
linkname = lnode->linkName();
}
switch(GLMMethod::getFamily(snode)) {
case GLM_BERNOULLI: case GLM_BINOMIAL:
return linkname=="logit";
case GLM_POISSON:
return linkname=="log";
/*
case GLM_NORMAL:
return lnode == 0;
*/
default:
return false;
}
}
GLMMethod *
AMFactory::newMethod(GraphView const *view,
vector<GraphView const *> const &sub_views,
unsigned int chain) const
{
/*
If we have a pure guassian linear model then make a
conjugate linear sampler instead.
*/
bool linear = true;
vector<StochasticNode const*> const &children =
view->stochasticChildren();
for (unsigned int i = 0; i < children.size(); ++i) {
if (GLMMethod::getFamily(children[i]) != GLM_NORMAL) {
linear = false;
break;
}
}
if (linear) {
return new Linear(view, sub_views, chain, false);
}
else {
return new AMMethod(view, sub_views, chain);
}
}
bool AMFactory::canSample(StochasticNode const *snode) const
{
return !isBounded(snode);
}
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks