Module pyqt_fit.kde_methods — PyQt-Fit 1.2.3 documentation

### Navigation

- index
- modules |
- next |
- previous |
- PyQt-Fit 1.2.3 documentation »
- Modules of PyQt-Fit »

\[\DeclareMathOperator{\erf}{erf} \DeclareMathOperator{\argmin}{argmin} \newcommand{\R}{\mathbb{R}} \newcommand{\n}{\boldsymbol{n}}\]

# Module `pyqt_fit.kde_methods`

Author: | Pierre Barbier de Reuille <pierre.barbierdereuille@gmail.com>

This module contains a set of methods to compute univariate KDEs. See the objects in the `pyqt_fit.kde` module for more details on these methods.

## References:

[1] | (1, 2) Jones, M. C. 1993. Simple boundary correction for kernel density estimation. Statistics and Computing 3: 135–146.

## Univariate KDE estimation methods

The exact definition of such a method is found in `pyqt_fit.kde.KDE1D.method`

`pyqt_fit.kde_methods.` `generate_grid`(kde, N=None, cut=None)

  Helper method returning a regular grid on the domain of the KDE.

  Parameters: | kde (KDE1D) – Object describing the KDE computation N (int) – Number of points in the grid cut (float) – for unbounded domains, how far past the maximum should the grid extend to, in term of KDE bandwidth
  Returns: | A vector of N regularly spaced points

class `pyqt_fit.kde_methods.` `KDE1DMethod`

  Base class providing a default grid method and a default method for unbounded evaluation.

  static `__call__`(kde, points, output)

    Method to use if there is, effectively, no bounds

  `__str__`()

    Return the name of the method

  `default_grid`(kde, N=None, cut=None)

    Evaluate the method on a grid spanning the whole domain of the KDE and containing N points.

    Parameters: | kde (KDE1D) – KDE object N (int) – Number of points of the grid cut (float) – Cutting points for the unbounded domain (see `generate_grid()`)
    Returns: | A tuple with the grid points and the estimated values on these points

  static `unbounded`(kde, points, output)

    Method to use if there is, effectively, no bounds

### Estimation methods

Here are the methods implemented in pyqt_fit. To access these methods, the simplest is to use the instances provided:

`pyqt_fit.kde_methods.` `renormalization`

  Instance of the `RenormalizationMethod` class.

`pyqt_fit.kde_methods.` `reflection`

  Instance of the `ReflectionMethod` class.

`pyqt_fit.kde_methods.` `linear_combination`

  Instance of the `LinearCombinationMethod` class.

`pyqt_fit.kde_methods.` `cyclic`

  Instance of the `CyclicMethod` class.

### Classes implementing the estimation methods

class `pyqt_fit.kde_methods.` `RenormalizationMethod`

  This method consists in using the normal kernel method, but renormalize to only take into account the part of the kernel within the domain of the density [1].

  The kernel is then replaced with:

  \[\hat{K}(x;X,h,L,U) \triangleq \frac{1}{a_0\left(\frac{L-x}{h}, \frac{U-x}{h}\right)} K\left(\frac{x-X}{h}\right)\]

class `pyqt_fit.kde_methods.` `ReflectionMethod`

  This method consist in simulating the reflection of the data left and right of the boundaries. If one of the boundary is infinite, then the data is not reflected in that direction. To this purpose, the kernel is replaced with:

  \[\hat{K}(x; X, h, L, U) = K\left(\frac{x-X}{h}\right) + K\left(\frac{x+X-2L}{h}\right) + K\left(\frac{x+X-2U}{h}\right)\]

  When computing grids, if the bandwidth is constant, the result is computing using CDT.

class `pyqt_fit.kde_methods.` `LinearCombinationMethod`

  This method uses the linear combination correction published in [1].

  The estimation is done with a modified kernel given by:

  \[K_r(x;X,h,L,U) = \frac{a_2(l,u) - a_1(-u, -l) z}{a_2(l,u)a_0(l,u) - a_1(-u,-l)^2} K(z)\]\[z = \frac{x-X}{h} \qquad l = \frac{L-x}{h} \qquad u = \frac{U-x}{h}\]

class `pyqt_fit.kde_methods.` `CyclicMethod`

  This method assumes cyclic boundary conditions and works only for closed boundaries.

  The estimation is done with a modified kernel given by:

  \[\hat{K}(x; X, h, L, U) = K\left(\frac{x-X}{h}\right) + K\left(\frac{x-X-(U-L)}{h}\right) + K\left(\frac{x-X+(U-L)}{h}\right)\]

  When computing grids, if the bandwidth is constant, the result is computing using FFT.

### Navigation

- index
- modules |
- next |
- previous |
- PyQt-Fit 1.2.3 documentation »
- Modules of PyQt-Fit »