freealg.FreeForm.fit#
- FreeForm.fit(method='jacobi', K=10, alpha=0.0, beta=0.0, reg=0.0, projection='gaussian', kernel_bw=None, damp=None, force=False, pade_p=0, pade_q=1, odd_side='left', pade_reg=0.0, optimizer='ls', plot=False, latex=False, save=False)#
Fit model to eigenvalues.
- Parameters:
- method{
'jacobi'
,'chebyshev'
}, default='jacobi'
Method of approximation, either by Jacobi polynomials or Chebyshev polynomials of the second kind.
- Kint, default=10
Highest polynomial degree
- alphafloat, default=0.0
Jacobi parameter \(\alpha\). Determines the slope of the fitting model on the right side of interval. This should be greater then -1. This option is only applicable when
method='jacobi'
.- betafloat, default=0.0
Jacobi parameter \(\beta\). Determines the slope of the fitting model on the left side of interval. This should be greater then -1. This option is only applicable when
method='jacobi'
.- regfloat, default=0.0
Tikhonov regularization coefficient.
- projection{
'sample'
,'gaussian'
,'beta'
}, default='beta'
The method of Galerkin projection:
'sample'
: directly project samples (eigenvalues) to the orthogonal polynomials. This method is highly unstable as it treats each sample as a delta Dirac function.'gaussian'
: computes Gaussian-Kernel KDE from the samples and project a smooth KDE to the orthogonal polynomials. This method is stable.'beta'
: computes Beta-Kernel KDE from the samples and project a smooth KDE to the orthogonal polynomials. This method is stable.
- kernel_bwfloat, default=0.001
Kernel band-wdth. See scipy.stats.gaussian_kde. This argument is relevant if
projection='kernel'
is set.- damp{
'jackson'
,'lanczos'
,'fejer
,'exponential'
,'parzen'
}, default=None Damping method to eliminate Gibbs oscillation.
- forcebool, default=False
If True, it forces the density to have unit mass and to be strictly positive.
- pade_pint, default=0
Degree of polynomial \(P(z)\) is \(q+p\) where \(p\) can only be
-1
,0
, or1
. See notes below.- pade_qint, default=1
Degree of polynomial \(Q(z)\) is \(q\). See notes below.
- odd_side{
'left'
,'right'
}, default='left'
In case of odd number of poles (when \(q\) is odd), the extra pole is set to the left or right side of the support interval, while all other poles are split in half to the left and right. Note that this is only for the initialization of the poles. The optimizer will decide best location by moving them to the left or right of the support.
- pade_regfloat, default=0.0
Regularization for Pade approximation.
- optimizer{
'ls'
,'de'
}, default='ls'
Optimizer for Pade approximation, including:
'ls'
: least square (local, fast)'de'
: differential evolution (global, slow)
- plotbool, default=False
If True, the approximation coefficients and Pade approximation to the Hilbert transform are plotted.
- latexbool, default=False
If True, the plot is rendered using LaTeX. This option is relevant only if
plot=True
.- savebool, default=False
If not False, the plot is saved. If a string is given, it is assumed to the save filename (with the file extension). This option is relevant only if
plot=True
.
- method{
- Returns:
- psi(K+1, ) numpy.ndarray
Coefficients of fitting Jacobi polynomials
Notes
The Pade approximation for the glue function \(G(z)\) is
\[G(z) = \frac{P(z)}{Q(z)},\]where \(P(z)\) and \(Q(z)\) are polynomials of order \(p+q\) and \(q\) respectively. Note that \(p\) can only be -1, 0, or 1, effectively making Pade approximation of order \(q-1:q\), \(q:q\), or \(q-1:q\).
Examples
>>> from freealg import FreeForm