dimanche 15 juillet 2018

2 Sample KS-Test. CDF or PDF as input?

I implemented the KS-Test to test which Distributions are better fitting together. At this moment, I gave the CDFs as input, because the standard KS-Test involves computing the maximum difference between the CDFs of the function. I just wanted to know if this is the right way to do it. Or should I use the PDFS as input? The statistics values and p-values seem good for me. With the critical value of the KS-Test i can chose which Hypothesis tests I should not reject.

Code example

gammafit = stats.gamma.fit(h4)  
pdf_gamma = stats.gamma.pdf(lnspc, *gammafit)  
cdf_gamma = stats.gamma.cdf(lnspc, *gammafit) 
plt.plot(lnspc, pdf_gamma, label="Gamma")

gamma_kstest999 = stats.ks_2samp(np.cumsum(n4), cdf_gamma)

Aucun commentaire:

Enregistrer un commentaire