Skip to content
Back to skills

Stein Kernel Loss

ASecurity

Compute one-dimensional kernel Stein and diffusion kernel Stein losses for unnormalized model recovery experiments.

  • 247 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 9, 2026
testingpython

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill stein_kernel_loss --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Stein Kernel Loss?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Stein Kernel Loss
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-stein-kernel-loss/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-stein-kernel-loss)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: stein_kernel_loss
description: Compute one-dimensional kernel Stein and diffusion kernel Stein losses for unnormalized model recovery experiments.
---

# Stein Kernel Loss

Use this skill when a task needs to evaluate an empirical KSD or scalar diffusion KSD objective for a one-dimensional unnormalized model. It is appropriate for bounded recovery experiments, diagnostics, and cross-checks of minimum Stein discrepancy estimators. Do not use it as a general multidimensional matrix-kernel implementation.

## Inputs

- `samples`: at least two numeric observations.
- `theta`: model parameter used by the score and diffusion functions.
- `score_fn(x, theta)`: derivative of the log unnormalized density with respect to `x`.
- `bandwidth`: positive Gaussian-kernel bandwidth.
- Optional `diffusion_fn(x, theta)` and `diffusion_derivative_fn(x, theta)` for scalar DKSD.

## Outputs

- Pairwise scalar Stein-kernel values.
- U-statistic loss over all ordered distinct pairs.
- Diagnostics containing pair count and finite-value status.

## Workflow

1. Define the model score without using normalizing constants.
2. Choose identity diffusion for vanilla KSD or a scalar diffusion and derivative for DKSD.
3. Call `u_statistic_loss` from `scripts/stein_loss.py` for a candidate parameter.
4. Repeat over candidate parameters or pass the objective to an optimizer skill.
5. Save diagnostics when the value is used as recovery evidence.

## Validation

Run `python -m pytest tests` or validate through the Distiller skill-tree validator with `--run-tests`.

## Limitations

This skill implements the scalar one-dimensional special case used for fast recovery. It intentionally does not implement the full matrix-valued RKHS formula or Riemannian geometry from the paper.

Files in this skill

  • SKILL.md1.7 KB
  • scripts/stein_kernel_loss.py4 KB
  • tests/test_stein_kernel_loss.py782 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.