kolmogorov-smirnov

Why did my p-value equals 0 and statistic equals 1 when I use ks test in python?

我的未来我决定 提交于 2021-01-29 10:05:22
问题 Thanks to anyone who have a look first. My codes are : import numpy as np from scipy.stats import kstest data=[31001, 38502, 40842, 40852, 43007, 47228, 48320, 50500, 54545, 57437, 60126, 65556, 71215, 78460, 81299, 96851, 106472, 108398, 118495, 130832, 141678, 155703, 180689, 218032, 222238, 239553, 250895, 274025, 298231, 330228, 330910, 352058, 362993, 369690, 382487, 397270, 414179, 454013, 504993, 518475, 531767, 551032, 782483, 913658, 1432195, 1712510, 2726323, 2777535, 3996759,

Kolmogorov Smirnov test for the fitting goodness in python

て烟熏妆下的殇ゞ 提交于 2021-01-29 05:35:27
问题 i am trying to fit distributions. The fitting is finished, but i need a measurement, to choose the best model. Many papers are using the Kolomogorov-Smirnov (KS) test. I tried to implement that, and i am getting very low p-value results. The implementation: #Histigram plot binwidth = np.arange(0,int(out_threshold1),1) n1, bins1, patches = plt.hist(h1, bins=binwidth, normed=1, facecolor='#023d6b', alpha=0.5, histtype='bar') #Fitting gevfit4 = gev.fit(h1) pdf_gev4 = gev.pdf(lnspc, *gevfit4) plt

How to calculate the Kolmogorov-Smirnov statistic between two weighted samples

你说的曾经没有我的故事 提交于 2020-01-13 03:31:26
问题 Let's say that we have two samples data1 and data2 with their respective weights weight1 and weight2 and that we want to calculate the Kolmogorov-Smirnov statistic between the two weighted samples. The way we do that in python follows: def ks_w(data1,data2,wei1,wei2): ix1=np.argsort(data1) ix2=np.argsort(data2) wei1=wei1[ix1] wei2=wei2[ix2] data1=data1[ix1] data2=data2[ix2] d=0. fn1=0. fn2=0. j1=0 j2=0 j1w=0. j2w=0. while(j1<len(data1))&(j2<len(data2)): d1=data1[j1] d2=data2[j2] w1=wei1[j1]

Applying function (ks.test) between two data frames colum-wise in R

你说的曾经没有我的故事 提交于 2019-12-30 07:06:10
问题 My simple question is: How do you do a ks.test between two data frames column by column? Eg. We have two data frames: D1 <- data.frame(D$Ag, D$Al, D$As, D$Ba, D$Be, D$Ca, D$Cd, D$Co, D$Cu, D$Cr) D2 <- data.frame(S$Ag, S$Al, S$As, S$Ba, S$Be, S$Ca, S$Cd, S$Co, S$Cu, S$Cr) Note: this is just an example - real case would include much more columns and they contain concentrations of a certain element in a specific location. Now i would like to run a ks.test between the two data frames : ks.test(D

Kolmogorov Smirnov Test in Spark (Python) not working?

*爱你&永不变心* 提交于 2019-12-10 16:19:09
问题 I was doing a normality test in Python spark-ml and saw what I think is an bug. Here is the setup, i have a data-set that is normalized (range -1, to 1). When I do a histogram, i can clearly see that the data is NOT normal: >>> prices_norm.histogram(10) ([-1.0, -0.8, -0.6, -0.4, -0.2, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0], [226, 269, 119, 95, 52, 26, 8, 2, 2, 5]) When I run the Kolmgorov-Smirnov test I get the following results: >>> testResults = Statistics.kolmogorovSmirnovTest(prices_norm, "norm")

Discrete Kolmogorov-Smirnov testing: getting wrong value when using rpy2 compared to pure R

喜欢而已 提交于 2019-12-06 15:24:38
问题 I am trying to use the dgof module from R, in Python 3 via rpy2 . I use it inside python as so: # import rpy2's package module import rpy2.robjects.packages as rpackages # Import R's utility package utils = rpackages.importr('utils') # Select a mirror for R packages utils.chooseCRANmirror(ind=1) # select the first mirror in the list # R vector of strings from rpy2.robjects.vectors import StrVector # Install R package name: 'dgof' (discrete goodness-of-fit) is what we're interested in if