# Comparing distribution with KS-test

**URL:** <https://discourse.julialang.org/t/comparing-distribution-with-ks-test/131589>\
**Category:** Statistics\
**Created:** [August 13, 2025, 4:32pm UTC](https://discourse.julialang.org/t/comparing-distribution-with-ks-test/131589 "2025-08-13T16:32:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sergey\_Novak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergey_novak/32/37716_2.png) [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Post date:** [August 13, 2025, 4:32pm UTC](https://discourse.julialang.org/t/comparing-distribution-with-ks-test/131589/1 "2025-08-13T16:32:11Z")

</div>

Hello all!

I have a vector of local maximum spikes extracted from a time series. I also have the probability density function (PDF) for these local maxima. I need to compare my distribution with the Weibull distribution.

I know about the function HypothesisTests.ExactOneSampleKSTest, but I don’t understand whether I need to compute the empirical distribution function (EDF) for my data and then pass it to the function, or if it handles that internally.

At the moment, my code looks like this:

```julia-auto
using JLD2, Distributions, HypothesisTests, Statistics

path_to_save_PDF = "/home/sergey/work/data/3Rulkov_chemical/EEs/"
name_PDF = "PDFok g1 = 4.7; g2 = 5.0.jld2"
name_thresholds = "ampl_spikes g1 = 4.7; g2 = 5.0.jld2"

PDF_EEs = load(path_to_save_PDF*name_PDF)["PDF_ok"]
ampl_spikes = load(path_to_save_PDF*name_thresholds)["ampl_spikes"]

data = abs.(ampl_spikes)
weibull_dst = fit(Weibull, abs.(ampl_spikes))

ks_test = ExactOneSampleKSTest(data, weibull_dst)

println("K-S statistic: ", ks_test.δ)
println("p-value: ", pvalue(ks_test))

```

Thank you for your helps!

Link to the data: [data for KS-test - Google Drive](https://drive.google.com/drive/folders/1T79VHaL-As9RrYzQeCWcS4wO_HyMuosx?usp=sharing)

---

<div class="post-metadata">

**Author:** ![ForceBru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/forcebru/32/21389_2.png) [@ForceBru](https://discourse.julialang.org/u/ForceBru)\
**Post date:** [August 13, 2025, 4:53pm UTC](https://discourse.julialang.org/t/comparing-distribution-with-ks-test/131589/2 "2025-08-13T16:53:24Z")

</div>

The documentation ([Nonparametric tests · HypothesisTests.jl](https://juliastats.org/HypothesisTests.jl/dev/nonparametric/#HypothesisTests.ExactOneSampleKSTest)) says:

> Perform a one-sample exact Kolmogorov–Smirnov test of the null hypothesis that the _data in vector `x`_ comes from the distribution `d`

So the first argument is supposed to be the data.
