Skip to content

Fix ks normal params - #162

Open
KubEF wants to merge 2 commits into
PySATL:mainfrom
KubEF:fix/ks-normal-params
Open

KubEF wants to merge 2 commits into
PySATL:mainfrom
KubEF:fix/ks-normal-params

Conversation

@KubEF

@KubEF KubEF commented Nov 18, 2026

Copy link
Copy Markdown

Summary

Make KolmogorovSmirnovNormalityGofStatistic use its mean and var instead of always testing against $N(0, 1)$.

Quick changelog

  • Fix: pass loc=mean, scale=sqrt(var) to norm.cdf.
  • Test: statistic must change when mean/var differ from defaults.
  • Test: the mean = 11 case in test_ks_normality_criterion used an $N(0, 1)$ sample with default parameters; the sample is now shifted by 11 and tested against $N(11, 1)$.

What's new?

Reproduce:

import numpy as np
from pysatl_criterion import GoodnessOfFitTest
from pysatl_criterion.statistics.goodness_of_fit.normal import KolmogorovSmirnovNormalityGofStatistic

norm_11_1: list[float] = list(np.random.default_rng().normal(11, 1, 50))

rej = (
    GoodnessOfFitTest(KolmogorovSmirnovNormalityGofStatistic(mean=11, var=1))
    .test(norm_11_1, 0.05)
    .rejected
)

print(f"N(11, 1) is {'rejected' if rej else 'not rejected'}")

Prints rejected before the fix, not rejected after.

KubEF and others added 2 commits November 18, 2026 19:06
KolmogorovSmirnovNormalityGofStatistic stores mean and var but evaluates
the standard normal CDF, so the statistic ignores them.

- Add a test that the statistic changes when mean and/or var differ
  from the defaults on the same sample.
- Pass mean and var in test_ks_normality_criterion. The case labelled
  "mean = 11" used an N(0, 1) sample with the default N(0, 1)
  hypothesis; shift the sample by 11 and test it against N(11, 1).
  The expected value is unchanged since KS is shift-invariant
  (cross-checked with scipy.stats.kstest).

These tests are expected to fail until the statistic is fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KolmogorovSmirnovNormalityGofStatistic evaluated the standard normal CDF
and ignored the mean and var it was constructed with. Use them as loc
and scale; var is a variance, so scale is its square root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@f1i3g3

f1i3g3 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Спасибо за реквест!

@f1i3g3
f1i3g3 requested review from f1i3g3 and quepum November 18, 2026 19:36
@f1i3g3 f1i3g3 added bug Something isn't working python Pull requests that update python code 1.1.0 labels Nov 18, 2026
@f1i3g3

f1i3g3 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Надо только подправить под актуальное состояние репозитория
Если есть вопросы (они наверняка появятся), можно написать в группу/личные сообщения в Telegram

@f1i3g3
f1i3g3 requested review from alex98247 and faux66 November 21, 2026 23:26

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.1.0 bug Something isn't working python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants