@@ -22,21 +22,6 @@ namespace ml
22
22
namespace maths
23
23
{
24
24
25
- // ! Compute the expectation of the specified function w.r.t. to the marginal
26
- // ! likelihood.
27
- // !
28
- // ! This computes the expectation using order three Gauss-Legendre quadrature
29
- // ! in \p numberIntervals subdivisions of a high confidence interval for the
30
- // ! marginal likelihood.
31
- // !
32
- // ! \param f The function to integrate.
33
- // ! \param numberIntervals The number intervals to use for integration.
34
- // ! \param result Filled in with the result if the expectation could be calculated.
35
- // !
36
- // ! \tparam F This must conform to the function type expected by
37
- // ! CIntegration::gaussLegendre.
38
- // ! \tparam T The return type of the function F which must conform to the type
39
- // ! expected by CIntegration::gaussLegendre.
40
25
template <typename F, typename T>
41
26
bool CPrior::expectation (const F &f,
42
27
std::size_t numberIntervals,
@@ -52,16 +37,16 @@ bool CPrior::expectation(const F &f,
52
37
53
38
result = T ();
54
39
55
- double n = static_cast <double >(numberIntervals);
56
- TDoubleDoublePr interval =
40
+ double n{ static_cast <double >(numberIntervals)} ;
41
+ TDoubleDoublePr interval{
57
42
this ->marginalLikelihoodConfidenceInterval (100.0 - 1.0 / (100.0 * n),
58
43
weightStyles,
59
- weight);
60
- double x = interval.first ;
61
- double dx = (interval.second - interval.first ) / n;
44
+ weight)} ;
45
+ double x{ interval.first } ;
46
+ double dx{ (interval.second - interval.first ) / n} ;
62
47
63
- double normalizationFactor = 0.0 ;
64
- TDouble4Vec1Vec weights ( 1 , weight) ;
48
+ double normalizationFactor{ 0.0 } ;
49
+ TDouble4Vec1Vec weights{ weight} ;
65
50
CPrior::CLogMarginalLikelihood logLikelihood (*this , weightStyles, weights);
66
51
CCompositeFunctions::CExp<const CPrior::CLogMarginalLikelihood&> likelihood (logLikelihood);
67
52
for (std::size_t i = 0u ; i < numberIntervals; ++i, x += dx)
0 commit comments