title: Using Scipy's stats.kstest module for goodness-of-fit testing
body: <p>I've read through existing posts about this module (and the Scipy docs), but it's still not clear to me how to use Scipy's kstest module to do a goodness-of-fit test when you have a data set and a callable function.</p>
  
  <p>The PDF I want to test my data against isn't one of the standard scipy.stats distributions, so I can't just call it using something like:</p>
  
  <pre><code>kstest(mydata,'norm')
  </code></pre>
  
  <p>where mydata is a Numpy array. Instead, I want to do something like:</p>
  
  <pre><code>kstest(mydata,myfunc)
  </code></pre>
  
  <p>where 'myfunc' is the callable function. This doesn't work—which is unsurprising, since there's no way for kstest to know what the abscissa for the 'mydata' array is in order to generate the corresponding theoretical frequencies using 'myfunc'. Suppose the frequencies in 'mydata' correspond to the values of the random variable is the array 'abscissa'. Then I thought maybe I could use stats.ks_2samp:</p>
  
  <pre><code>ks_2samp(mydata,myfunc(abscissa))
  </code></pre>
  
  <p>but I don't know if that's statistically valid. (Sidenote: do kstest and ks_2samp expect frequency arrays to be normalized to one, or do they want the absolute frequencies?)</p>
  
  <p>In any case, since the one-sample KS test is supposed to be used for goodness-of-fit testing, I have to assume there's some way to do it with kstest directly. How do you do this?</p>