Skip to content
Back to skills

Ks 1samp

ASecurity

Compute the ks_1samp metric — provided by scipy.stats. Use when the user has predictions and ground-truth and needs to compute ks_1samp, or asks how to score with ks_1samp.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 11, 2026
documentationpythongo

Security analysis

A100/100

Scanned September 11, 2026

npx -y skills add qhjqhj00/research-skills-pool --skill ks-1samp --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ks 1samp?

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

Security grade badge for Ks 1samp
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/qhjqhj00-ks-1samp/badge)](https://www.skillsdirectory.com/skills/qhjqhj00-ks-1samp)

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: ks-1samp
description: Compute the ks_1samp metric — provided by scipy.stats. Use when the user has predictions and ground-truth and needs to compute ks_1samp, or asks how to score with ks_1samp.
metadata:
  skill_kind: metric
  source_lib: scipy.stats
  import_path: scipy.stats.ks_1samp
  source: library_introspection
---

# ks-1samp

> Metric `ks_1samp` from `scipy.stats` (scipy.stats.ks_1samp)

## When to invoke this skill

The user has predictions + ground truth and asks to evaluate with ks_1samp, or
mentions `scipy.stats.ks_1samp` directly, or wants the standard scipy.stats implementation.

## Reference signature

```python
from scipy.stats import ks_1samp

# ks_1samp(x, cdf, args=(), alternative='two-sided', method='auto', *, axis=0, nan_policy='propagate', keepdims=False)
```

## Library docstring

```
Performs the one-sample Kolmogorov-Smirnov test for goodness of fit.

This test compares the underlying distribution F(x) of a sample
against a given continuous distribution G(x). See Notes for a description
of the available null and alternative hypotheses.

Parameters
----------
x : array_like
    a 1-D array of observations of iid random variables.
cdf : callable
    callable used to calculate the cdf.
args : tuple, sequence, optional
    Distribution parameters, used with `cdf`.
alternative : {'two-sided', 'less', 'greater'}, optional
    Defines the null and alternative hypotheses. Default is 'two-sided'.
    Please see explanations in the Notes below.
method : {'auto', 'exact', 'approx', 'asymp'}, optional
    Defines the distribution used for calculating the p-value.
    The following options are available (default is 'auto'):

      * 'auto' : selects one of the other options.
      * 'exact' : uses the exact distribution of test statistic.
      * 'approx' : approximates the two-sided probability with twice
        the one-sided probability
      * 'asymp': uses asymptotic distribution of test statistic
axis : int or None, default: 0
    If an int, the axis of the input along which to compute the statistic.
    The statistic of each axis-slice (e.g. row) of the input will appear in a
    corresponding element of the output.
    If ``None``, the input will be raveled before computing the statistic.
nan_policy : {'propagate', 'omit', 'raise'}
    Defines how to handle input NaNs.

    - ``propagate``: if a NaN is present in the axis slice (e.g. row) along
      which the  statistic is computed, the corresponding entry of the output
      will be NaN.
    - ``omit``: NaNs will be omitted when performing the calculation.
      If insufficient data remains in the axis slice along which the
      statistic is computed, the corresponding entry of the output will be
      NaN.
    - ``raise``: if a NaN is present, a ``ValueError`` will be raised.
keepdims : bool, default: False
    If this is set to True, the axes which are reduced are left
    in the result as dimensions with size one. With this option,
    the result will broadcast correctly against the input 
```

## Quick recipe

```python
import scipy.stats as _m
score = _m.ks_1samp(y_true, y_pred)
```

## Don'ts

- Don't reimplement when the library version handles edge cases (NaN, ties, empty inputs) better than a hand-rolled formula.
- Always check the library version's argument order — sklearn is `(y_true, y_pred)` while torchmetrics is `(preds, target)`.

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.