npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
TruncatedLog.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_TRUNCATEDLOG_HH_
2 #define NPSTAT_TRUNCATEDLOG_HH_
3 
4 /*!
5 // \file TruncatedLog.hh
6 //
7 // \brief Truncated log function useful in maximum likelihood fitting
8 // of densities for which positivity condition is difficult to impose
9 //
10 // Author: I. Volobouev
11 //
12 // March 2023
13 */
14 
15 #include "npstat/nm/Poly1D.hh"
16 
17 namespace npstat {
18  template<class Real>
20  {
21  public:
22  // Note that, typically, the argument "nTaylorTerms"
23  // should be odd. Otherwise, eventually, at large in
24  // magnitude negative values of x, the expansion will
25  // become positive.
26  TruncatedLog(Real truncationX, unsigned nTaylorTerms);
27 
28  inline Real truncationX() const {return tr_;}
29  inline unsigned nTaylorTerms() const
30  {return expansion_.deg()+1U;}
31 
32  Real operator()(Real x) const;
33  Real derivative(Real x) const;
34  Real secondDerivative(Real x) const;
35 
36  // The following returns the integral from 1 to x
37  Real integral(Real x) const;
38 
39  private:
40  long double ltr_;
41  Poly1D expansion_;
42  Poly1D deriv1_;
43  Poly1D deriv2_;
44  Poly1D integ_;
45  Real one_;
46  Real tr_;
47  Real deltaMax_;
48  };
49 }
50 
51 #include "npstat/nm/TruncatedLog.icc"
52 
53 #endif // NPSTAT_TRUNCATEDLOG_HH_
Basic 1-d polynomials in the monomial basis. Various operations with monomials are poorly conditioned...
Definition: Poly1D.hh:21
unsigned deg() const
Definition: Poly1D.hh:96
Definition: TruncatedLog.hh:20
Definition: AbsArrayProjector.hh:14