title: Kolmogorov-Smirnov Test in Python for Goodness of fit
body: <p>I am trying to get the best distributions for my data.  The fitting is finished as shown in below figure, but i need a measurement, to choose the best model. I compared goodness of fit with a chi-squared value, and test for significant difference between observed and fitted distribution with a Kolmogorov-Smirnov (KS) test. I searched for some of potential solutions <a href="https://stackoverflow.com/questions/7903977/implementing-a-kolmogorov-smirnov-test-in-python-scipy">1</a>,<a href="https://stackoverflow.com/questions/51305126/kolmogorov-smirnov-test-for-the-fitting-goodness-in-python">2</a>,<a href="https://stackoverflow.com/questions/43093264/very-low-p-values-in-python-kolmogorov-smirnov-goodness-of-fit-test?rq=1">3</a> but I didn't get my answer.From the results in below figure:</p>
  <ol>
  <li><p>If the <code>p-value</code> is higher than <code>k-statistic</code>, does it means we can accept the hypothesis or data fits the distribution well?</p>
  </li>
  <li><p>Alternatively, is it ok to compare <code>level of significance(a=0.005)</code> with <code>p-value</code> and decide the acceptance or rejection of hypothsis ? If <code>p-value</code> is lower than <code>a</code>, then it is very probable that the two distributions are different.</p>
  </li>
  <li><p>For <code>Kolmogorov-Smirnov test</code>, is it essential to standardised the data (-1,1) ?</p>
  </li>
  <li><p>Judging from the KS statistic and P-values, the <code>exponnorm</code> fits best in the data. Is that correct?</p>
  </li>
  </ol>
  <p><a href="https://i.stack.imgur.com/ni1Wp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ni1Wp.png" alt="enter image description here" /></a></p>
  <p>I calculated the P-value in following way:</p>
  <pre><code>for distribution in dist_names:
      # Set up distribution and get fitted distribution parameters
      dist = getattr(scipy.stats, distribution)
      param = dist.fit(y_std)   
      p = scipy.stats.kstest(y_std, distribution, args=param)[1]
      p = np.around(p, 5)
      p_values.append(p) 
  </code></pre>