Comparing distribution with KS-test

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:

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

The documentation (Nonparametric tests · HypothesisTests.jl) 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.

3 Likes