Skip to content

Blog

Beta KDE Software Rollout: Python, R, and Julia

Following the recent acceptance of my paper on Beta Kernel Density Estimation in the Journal of Computational and Graphical Statistics (JCGS), the focus has shifted to making the method immediately accessible to applied researchers.

I am pleased to share that the new closed-form "HS" bandwidth selector is now available across the three major statistical computing languages.

The goal of this research was to provide a fast, rule-of-thumb solution for boundary-corrected density estimation without relying on unstable numerical optimization. To ensure it is a true plug-and-play solution, the method has been rolled out in the following ecosystems:

  • Python: Available via pip install beta-kde (fully API-compatible with scikit-learn). [ GitHub | Documentation ]
  • R: Now integrated as the default bandwidth selector for beta kernels in the standard kdensity CRAN package (v1.2.0+). [ CRAN | GitHub ]
  • Julia: Available via the official package manager using ] add BetaKDE. [ GitHub ]

A preprint detailing the derivation of the HS bandwidth rule is available on arXiv, and the official journal version will be published in JCGS shortly.

Selected for the 13th Heidelberg Laureate Forum

I am very happy to share that I have been invited to participate in the 13th Heidelberg Laureate Forum (HLF) as a Young Researcher.

The HLF is an annual networking conference in Germany where 200 carefully selected young researchers in mathematics and computer science spend a week interacting with the laureates of their disciplines—recipients of the Abel Prize, ACM A.M. Turing Award, ACM Prize in Computing, Fields Medal, and the IMU Abacus Medal (formerly the Nevanlinna Prize).

I am particularly looking forward to discussing my research on the statistical validity of Conformal Prediction under non-exchangeability and the challenges of 'A-cryptic' distribution shifts. It is a tremendous honor to be selected, and I am excited to meet both the laureates and other young researchers from around the world this September.

Stockholm University's Department of Mathematics recently published a short news piece about the upcoming trip: Anna och Johan åker till 13th Heidelberg Laureate Forum (Stockholm University)

Concert: Les Misérables (Jean Valjean)

This weekend, I will be taking on the role of Jean Valjean in Les Misérables in Concert.

Les Misérables Poster

This production is a massive collaborative project bringing together all the choirs of Stenungsund's parish, a dedicated project choir, soloists, and instrumentalists.

At its core, this concert version focuses on the profound human journey at the center of the story:

Follow Jean Valjean's lifelong struggle for redemption. After years as a hardened convict, an unexpected act of mercy transforms him from an embittered outcast into a man dedicated to compassion and helping those he meets along his path. Set against the backdrop of 19th-century France, Les Misérables is a powerful story about the clash between rigid justice and profound empathy, reminding us of the enduring power of the human spirit and what it means to bear one another's burdens.

Event Details

  • Date: Sunday, March 22, 2026
  • Performances: 14:30 and 18:00
  • Location: Ödsmåls kyrka (Ödsmåls kyrkväg 1, Ödsmål)
  • Tickets: Free entry, but limited seating (booking required).

Contribution to Gammerman Festschrift

I am honored to announce a new book chapter in "The Importance of Being Learnable", a volume of essays dedicated to Alexander Gammerman on the occasion of his 80th birthday.

Prof. Gammerman is a foundational figure in AI uncertainty quantification and the co-inventor of the Conformal Prediction algorithm.

Together with Lars Carlsson, Ernst Ahlberg, and James Gammerman, I co-authored the chapter "Application of Confidence and Probabilistic Models to Practical Problems".

Our contribution surveys the transformative impact of the methods Gammerman pioneered, examining their adaptation to real-world challenges in:

  • Drug Discovery: High-stakes decision-making with valid uncertainty.

  • Autonomous Systems: Enhancing safety in self-driving technologies.

  • NLP: Mitigating hallucinations in Large Language Models.

  • Industrial Engineering: Optimizing maintenance schedules and anomaly detection.

The volume recognizes Gammerman's long-lasting impact as a researcher, educator, and mentor, celebrating a career that spans from pioneering mathematical models of plant photoreceptors to advancing the formal treatment of uncertainty in AI.

Concert: Stainer's The Crucifixion

On Good Friday, I will be performing the Tenor part in John Stainer's oratorio "The Crucifixion" with Kammarkören Cantastoria.

The Crucifixion: A Meditation on the Sacred Passion of the Holy Redeemer was composed by John Stainer in 1887. It is described as a meditation on the final days of Jesus and his seven last words on the cross, with a text that stays very close to the biblical narrative.

I will be singing the Tenor role, joined by Bass soloist, choir, and organ.

Event Details

  • Date: Good Friday, April 3rd, 2026
  • Time: 18:00
  • Location: Ljungs kyrka
  • Ensemble: Kammarkören Cantastoria

New Preprint: A Fast Rule for Beta Kernel Density Estimation

If you have ever tried to estimate a probability density for data bounded in [0, 1] (like percentages, probabilities, or Gini coefficients) using a standard Gaussian KDE, you know the pain: Boundary Bias. The Gaussian kernel "leaks" probability mass below 0 and above 1, ruining the estimate at the edges.

The theoretical solution—the Beta Kernel—has existed since 1999, but it has been held back by a major practical flaw: it lacked a simple "rule-of-thumb" bandwidth selector, forcing users to rely on slow, unstable numerical optimization.

In my latest preprint, "A Fast, Closed-Form Bandwidth Selector for the Beta Kernel Density Estimator", I solve this computational bottleneck.

I derive the Beta Reference Rule, a closed-form analytical formula for the optimal bandwidth. By eliminating the need for iterative optimization, this new rule matches the accuracy of the "gold standard" methods while delivering a computational speedup of over 35,000x.

This turns the Beta Kernel from a theoretical curiosity into a practical, drop-in replacement for the Gaussian KDE for bounded data.

Key Contributions

  • Derivation: A closed-form bandwidth rule based on the asymptotic mean integrated squared error (AMISE).
  • Heuristic Fallback: A principled heuristic for "hard" (U-shaped and J-shaped) distributions where standard asymptotics fail.
  • Software: A fully documented Python package, beta-kde, that is API-compatible with scikit-learn.

You can now fit a boundary-corrected density estimator in $\mathcal{O}(1)$ time:

from beta_kde import BetaKDE
import numpy as np

# Fits instantly, no boundary bias
data = np.random.beta(2, 5, 1000)
est = BetaKDE(bandwidth='beta-reference').fit(data.reshape(-1, 1))

New Preprint: Conformal Blindness

We typically assume that if a data distribution shifts drastically, our Conformal Test Martingales (CTMs) will explode and warn us. The standard logic is simple: exchangeability implies uniform p-values; therefore, non-uniform p-values imply a break in exchangeability.

But what if the p-values stay uniform while the data moves?

In my new note, "Conformal Blindness: A Note on A-Cryptic change-points", I demonstrate that this is possible.

By constructing a specific counter-example using bivariate Gaussian distributions and an oracle conformity measure, I identify a trajectory (an "A-cryptic line") along which the data can shift arbitrarily far without triggering any CTM. In this specific setting, the p-values remain perfectly uniform, and the CTM remains flat.

This finding serves as a proof-of-concept for a fundamental "blind spot" in conformal testing: we only detect shifts that are distinguishable by our specific conformity measure. If the shift aligns with the measure's blind spot, we are flying blind.

Upcoming Performance: Christmas Concert in Ljungskile

I am happy to announce the annual Christmas concert at Cirkuskvarnen in Ljungskile will take place this year as well

Date: December 20, 2025

Location: Cirkuskvarnen, Buddeberg 113, 451 91, Uddevalla

Time: 18:30

I will be performing alongside Kinga Szabadváry, Julia Svensson, Elinor Josefsson, and Johanna Abrahamsson in a Christmas concert for the whole family.

This serves as a nice break from my current work on Conformal Prediction.

Download Concert Poster