@@ -13,21 +13,6 @@ namespace ml
1313namespace maths
1414{
1515
16- // ! Compute the expectation of the specified function w.r.t. to the marginal
17- // ! likelihood.
18- // !
19- // ! This computes the expectation using order three Gauss-Legendre quadrature
20- // ! in \p numberIntervals subdivisions of a high confidence interval for the
21- // ! marginal likelihood.
22- // !
23- // ! \param f The function to integrate.
24- // ! \param numberIntervals The number intervals to use for integration.
25- // ! \param result Filled in with the result if the expectation could be calculated.
26- // !
27- // ! \tparam F This must conform to the function type expected by
28- // ! CIntegration::gaussLegendre.
29- // ! \tparam T The return type of the function F which must conform to the type
30- // ! expected by CIntegration::gaussLegendre.
3116template <typename F, typename T>
3217bool CPrior::expectation (const F &f,
3318 std::size_t numberIntervals,
@@ -43,16 +28,16 @@ bool CPrior::expectation(const F &f,
4328
4429 result = T ();
4530
46- double n = static_cast <double >(numberIntervals);
47- TDoubleDoublePr interval =
31+ double n{ static_cast <double >(numberIntervals)} ;
32+ TDoubleDoublePr interval{
4833 this ->marginalLikelihoodConfidenceInterval (100.0 - 1.0 / (100.0 * n),
4934 weightStyles,
50- weight);
51- double x = interval.first ;
52- double dx = (interval.second - interval.first ) / n;
35+ weight)} ;
36+ double x{ interval.first } ;
37+ double dx{ (interval.second - interval.first ) / n} ;
5338
54- double normalizationFactor = 0.0 ;
55- TDouble4Vec1Vec weights ( 1 , weight) ;
39+ double normalizationFactor{ 0.0 } ;
40+ TDouble4Vec1Vec weights{ weight} ;
5641 CPrior::CLogMarginalLikelihood logLikelihood (*this , weightStyles, weights);
5742 CCompositeFunctions::CExp<const CPrior::CLogMarginalLikelihood&> likelihood (logLikelihood);
5843 for (std::size_t i = 0u ; i < numberIntervals; ++i, x += dx)
0 commit comments