Kolmogorov-Smirnov test for PDF

Hello!
I have probability density function(PDF) for my data. I need use Kolmogorov-Smirnov test to check which distribution corresponds PDF.
I have not dealt with statistics before, is it possible to throw off some example for my case?

Link on my data: data - Google Drive
Image with log scale:


Code for image:

sel_1 = load("sel_presentation.jld")["data"]
pdf_1 = load("pdf_presentation.jld")["data"];
EE_mapcopy = pdf_1;
EE_mapcopy = [ iszero(x) ? NaN : x for x in EE_mapcopy ];

f = Figure(resolution = (600, 600))

ax = Axis(f[1, 1], yscale = log10,
xlabel = L"|x_{||}|n", ylabel = L"PDF",
xlabelsize = 35, ylabelsize = 35,
xticklabelsize = 30, yticklabelsize = 30  )

ax.xgridvisible = false
ax.ygridvisible = false

lines!(sel_1, EE_mapcopy, linewidth = 3.0, color = :blue)

display(f)

You can do it with HypothesisTests.jl, but for that you have to choose a distribution to compare your data with. Do you have any idea what that might be?

Thank you
I am trying to reproduce the result of the article. There is dragon king. That is, several distributions. The first should be power law

Image from article:
image
Link on article: Phys. Rev. E 97, 062311 (2018) - Dragon-king-like extreme events in coupled bursting neurons

As long as you find your target distribution here you should be fine: Univariate Distributions · Distributions.jl

Please note, all that the K-S test can do is tell you which distributions probably Do NOT correspond to your PDF (ie. a small p value means probably not that pdf). A large p value does not mean “yes this pdf” it means “this is one of the ones that might work”. It’s also fairly sensitive so with a lot of data it will say no to pretty much anything because no data is actually from a given PDF (only simulated data would work perfectly).

1 Like

The KS test is not suitable for detecting dragon kings.

Have a look a look at these three papers for different methods for detecting DKs:

Janczura, J.; Weron, R. (2012). “Black swans or dragon-kings? A simple test for deviations from the power law”. The European Physical Journal Special Topics. 205 (1): 79–93.

Robust statistical tests of Dragon-Kings beyond power law distributions
Eur. Phys. J. Special Topics 205, 95-115 (2012)

Wheatley, Spencer and Sornette, Didier, Multiple Outlier Detection in Samples with Exponential & Pareto Tails: Redeeming the Inward Approach & Detecting Dragon Kings (August 17, 2015). Swiss Finance Institute Research Paper No. 15-28

R had package “dragonking” which implements these methods.