The following methodology is used to fit profiles to binned data by calling the fit method.
Random events occur at different times following a profile P(t) with period T. Dividing the profile by the total number of events results in a periodic probability density function (pdf):
Because the pdf is periodic, it can be expanded into a Fourier series. However, low-frequency approximations of the pdf can result in periods with negative probabilities, violating one of the properties of pdfs. This can be resolved by performing the Fourier series expansion on the logarithm of the pdf, or the log-pdf. Because the pdf is periodic, the log-pdf must be as well.
Because Fourier series converge, they can be sufficiently approximated by a finite number of terms:
The proportion, p, of events between times ta and tb can be obtained by integrating the exponentiated log-pdf from ta to tb:
If one has the proportion of events from multiple time periods, then the Fourier coefficients Lk that minimize the error can be estimated using a nonlinear optimization algorithm. However, such algorithms can be very time consuming. Fortunately, a solution can be quickly approximated by linearizing the problem using Taylor series. To start, the integrand in the previous equation can be expanded in the following way:
Plugging the exponential series expansion into the logarithm series expansion (and replacing tb-ta with Δt) yields:
Rearranging this then results in the following approximation:
Substituting p0 with Δt further simplifies the approximation.
The right side of the previous equation can be expressed as a matrix product between two vectors:
If N time periods are used, then the previous equation can be arranged into a system of linear equations.
If N=2K+1, then the values of Lk can be solved for directly. However, if N>2K+1, then they can be found using ordinary least squares regression. Further, by setting optimize = True
when running the fit method, a nonlinear optimization algorithm will better match the coefficients to the estimation data using the linear solution as an initial guess.