[4634c7]: src / modules / glm / samplers / IWLSFactory.cc  Maximize  Restore  History

Download this file

73 lines (59 with data), 1.8 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
#include <config.h>
#include "IWLSFactory.h"
#include "IWLS.h"
#include "Linear.h"
#include "NormalLinear.h"
#include "IWLSOutcome.h"
#include <graph/StochasticNode.h>
#include <sampler/GraphView.h>
using std::vector;
using std::string;
namespace jags {
namespace glm {
IWLSFactory::IWLSFactory()
: GLMFactory("glm::IWLS")
{}
bool IWLSFactory::checkOutcome(StochasticNode const *snode) const
{
return NormalLinear::canRepresent(snode) ||
IWLSOutcome::canRepresent(snode);
}
GLMMethod *
IWLSFactory::newMethod(GraphView const *view,
vector<SingletonGraphView const *> const &sub_views,
unsigned int chain) const
{
bool linear = true;
vector<Outcome*> outcomes;
for (vector<StochasticNode *>::const_iterator p = view->stochasticChildren().begin();
p != view->stochasticChildren().end(); ++p)
{
Outcome *outcome = 0;
if (NormalLinear::canRepresent(*p)) {
outcome = new NormalLinear(*p, chain);
}
else if (IWLSOutcome::canRepresent(*p)) {
outcome = new IWLSOutcome(*p, chain);
linear = false;
}
outcomes.push_back(outcome);
}
if (linear) {
return new Linear(view, sub_views, outcomes, chain, false);
}
return new IWLS(view, sub_views, outcomes, chain);
}
bool IWLSFactory::canSample(StochasticNode const *snode) const
{
vector<Node const *> const &parents = snode->parents();
for (unsigned int i = 0; i < parents.size(); ++i) {
if (!parents[i]->isFixed())
return false;
}
return !isBounded(snode);
}
bool IWLSFactory::fixedDesign() const
{
return true;
}
}}

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

Sign up for the SourceForge newsletter:





No, thanks