BayesianAnalysisToolkit
0.9.3
Main Page
Namespaces
Classes
Files
File List
File Members
src
BCSummaryPriorModel.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2007-2013, the BAT core developer team
3
* All rights reserved.
4
*
5
* For the licensing terms see doc/COPYING.
6
* For documentation see http://mpp.mpg.de/bat
7
*/
8
9
// ---------------------------------------------------------
10
11
#include "
BCSummaryPriorModel.h
"
12
13
#include "
BCH1D.h
"
14
#include "
BCLog.h
"
15
#include "
BCParameter.h
"
16
17
#include <TH1D.h>
18
19
// ---------------------------------------------------------
20
BCSummaryPriorModel::BCSummaryPriorModel
()
21
:
BCModel
()
22
, fTestModel(0)
23
{
24
}
25
26
// ---------------------------------------------------------
27
BCSummaryPriorModel::BCSummaryPriorModel
(
const
char
* name)
28
:
BCModel
(name)
29
, fTestModel(0)
30
{
31
}
32
33
// ---------------------------------------------------------
34
BCSummaryPriorModel::~BCSummaryPriorModel
()
35
{}
36
37
// ---------------------------------------------------------
38
void
BCSummaryPriorModel::SetModel
(
BCModel
* model)
39
{
40
fTestModel
= model;
41
42
// copy parameters
43
int
npar =
fTestModel
->
GetNParameters
();
44
for
(
int
i = 0; i < npar; ++i) {
45
BCParameter
* par =
const_cast<
BCParameter
*
>
(
fTestModel
->
GetParameter
(i));
46
AddParameter
(par);
47
}
48
49
// set default histogram binning to the one of the original model
50
for
(
int
i = 0; i < npar; ++i) {
51
// this construct has to go here, because otherwise there is a
52
// warning from BCEngineMCMC:: MCMCGetH1Marginalized
53
if
(
fTestModel
->
GetBestFitParameters
().size() > 0){
54
BCH1D
* hist =
fTestModel
->
GetMarginalized
(
fTestModel
->
GetParameter
(i) );
55
if
(hist) {
56
int
nbins = hist->
GetHistogram
()->GetNbinsX();
57
fTestModel
->
GetParameter
(i)->
SetNbins
(nbins);
58
}
59
}
60
}
61
62
// set default MCMC setup to the one of the original model
63
MCMCSetNChains
(
fTestModel
->
MCMCGetNChains
() );
64
MCMCSetNLag
(
fTestModel
->
MCMCGetNLag
() );
65
MCMCSetNIterationsMax
(
fTestModel
->
MCMCGetNIterationsMax
() );
66
MCMCSetNIterationsRun
(
fTestModel
->
MCMCGetNIterationsRun
() );
67
MCMCSetNIterationsPreRunMin
(
fTestModel
->
MCMCGetNIterationsPreRunMin
() );
68
MCMCSetNIterationsUpdate
(
fTestModel
->
MCMCGetNIterationsUpdate
() );
69
MCMCSetNIterationsUpdateMax
(
fTestModel
->
MCMCGetNIterationsUpdateMax
() );
70
MCMCSetRValueCriterion
(
fTestModel
->
MCMCGetRValueCriterion
() );
71
MCMCSetRValueParametersCriterion
(
fTestModel
->
MCMCGetRValueParametersCriterion
() );
72
73
}
74
75
// ---------------------------------------------------------
76
double
BCSummaryPriorModel::LogLikelihood
(
const
std::vector<double> & parameters)
77
{
78
return
fTestModel
->
LogAPrioriProbability
(parameters);
79
}
80
81
// ---------------------------------------------------------
82
double
BCSummaryPriorModel::LogAPrioriProbability
(
const
std::vector<double> &
/*parameters*/
)
83
{
84
return
0;
85
}
Generated by
1.8.4