perf: optimize Greenwood Laplace statistic with Numba#128
Open
tahmazidik wants to merge 5 commits into
Open
Conversation
tahmazidik
marked this pull request as ready for review
July 20, 2026 10:57
Contributor
|
That's cool! Further experimentation is needed. |
f1i3g3
requested changes
Jul 20, 2026
Contributor
There was a problem hiding this comment.
С Numba создаётся новый массив или там уже всё оптимизировано? Иначе может получиться, что для образца ещё и сборщик мусора считается.
Contributor
There was a problem hiding this comment.
Сортировку можно вынести отдельно и вызывать до замеров.
Comment on lines
+384
to
+385
| if rvs_array.ndim != 1: | ||
| raise ValueError("Sample must be one-dimensional.") |
| KolmogorovSmirnovLaplaceGofStatistic, | ||
| KuiperLaplaceGofStatistic, | ||
| WatsonLaplaceGofStatistic, | ||
| _greenwood_laplace_statistic, |
Contributor
There was a problem hiding this comment.
Если метод выносится в паблик, лучше именовать его в CamelCase.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Optimize the Greenwood Laplace goodness-of-fit statistic using Numba to reduce execution time and avoid unnecessary intermediate arrays
Part of #122
Quick changelog
What’s new?
The Greenwood Laplace statistic is now calculated in a Numba-compiled function
The implementation sorts the input sample, calculates the Laplace cumulative distribution function directly, and accumulates squared spacings in a single loop. This reduces Python overhead and avoids creating unnecessary intermediate arrays with np.concatenate and np.diff
The implementation now also validates that the input sample is one-dimensional and raises a clear ValueError for multidimensional input
Regression tests were added to compare the optimized implementation with the previous SciPy-based formula. The tests cover a single observation, unsorted samples, repeated values, different location and scale parameters, and integer NumPy arrays
A benchmark was added for a sample of 10,000 values and 1,000 executions. The Numba function is called once before measurement so that JIT compilation time is not included in the benchmark
Benchmark results: