Unit Disk and 2D Bounded KDE. How to extend Bounded Kernel Density… | by Thomas Rouch | Jul, 2024


Photo by SpaceX on Unsplash

KDE in transformed space

The transformation trick maps the bounded data to an unbounded space, where the vanilla KDE can be safely applied. This results in using a different kernel function for each input sample.

However, as seen in previous article Bounded Kernel Density Estimation, , when the density is non-zero at the boundary and does not tend to infinity, it often results in unwanted artifacts.

Transformation

Building upon our approach from the previous section, we will again use central symmetry and choose a transformation f that alters only the radius. Transformed variables will be indicated with a tilde ~.

However, unlike the reflection case, where we preserved the unit disk and used the transformation solely to add new points, here we directly transform and use the points from within the unit disk.

Thus the boundary conditions are different and enforce instead to left the origin untouched and to dilate the disk to infinity.

Density Transformation

When applying a transformation T to a multi-dimensional random variable U, the resulting density is found by dividing by the absolute value of the determinant of the Jacobian matrix of T.

For instance, the polar transformation gives us the following density.

Based on the two previous properties, we can derive the relationship between the density before and after the transformation. This will enable us to recover the true density from the density estimated on the transformed points.

Which transformation to choose? Log, Inverse ?

There are plenty of functions that start from zero and increase to infinity as they approach 1. There is no one-size-fits-all answer.

The figure below showcases potential candidate functions created using logarithmic and inverse transformations to introduce a singularity at r=-1 and r=1.

Examples of functions that equal zero at the origin and tend to infinity as they approach +/-1 — Figure by the author

Based on the equation describing the transformed density, we aim to find a transformation that maps the uniform distribution to a form easily estimable by vanilla KDE. If we have a uniform distribution p(x,y), the density in transformed space is thus proportional to the function g below.

Logarithmic and inverse candidates give the following g functions.

They’re both equivalent when r approaches zero and only converge to a meaningful value when α is equal to one.

The figure below illustrates the three cases, with each column corresponding to the log transform with alpha values of 0.5, 1 and 2.

The first row shows the transformed space, comparing the density along the diagonal as estimated by the KDE on the transformed points (blue) against the expected density profile corresponding to the uniform distribution in the original space (red). The second row displays these same curves, but mapped back to the original space.

Keep in mind that the transformation and KDE are still performed in 2D on the disk. The one-dimensional curves shown below are extracted from the 2D results.



Source link

Be the first to comment

Leave a Reply

Your email address will not be published.


*