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

Download this file

LinearGibbsFactory.cc    47 lines (36 with data), 1.1 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
#include <config.h>
#include "LinearGibbsFactory.h"
#include "Linear.h"
#include "NormalLinear.h"
#include <graph/StochasticNode.h>
#include <distribution/Distribution.h>
#include <sampler/SingletonGraphView.h>
using std::vector;
namespace jags {
namespace glm {
LinearGibbsFactory::LinearGibbsFactory()
: GLMFactory("glm::LinearGibbs")
{
}
bool LinearGibbsFactory::checkOutcome(StochasticNode const *snode) const
{
return NormalLinear::canRepresent(snode);
}
GLMMethod*
LinearGibbsFactory::newMethod(GraphView const *view,
vector<SingletonGraphView const *> const &sub_views,
unsigned int chain) const
{
vector<Outcome*> outcomes;
for (vector<StochasticNode *>::const_iterator p = view->stochasticChildren().begin();
p != view->stochasticChildren().end(); ++p)
{
outcomes.push_back(new NormalLinear(*p, chain));
}
return new Linear(view, sub_views, outcomes, chain, true);
}
bool LinearGibbsFactory::canSample(StochasticNode const *snode) const
{
return snode->length() == 1;
}
}}