title: ks and chisquare test reject equality of distributions for data coming from same DGP
body: <p>I generated two distributions using the following code:</p>
  
  <pre><code>rand_num1 = 2*np.random.randn(10000) + 1
  rand_num2 = 2*np.random.randn(10000) + 1
  stats.ks_2samp(rand_num1, rand_num2)
  </code></pre>
  
  <p><strong>My question is why do both these distributions do not test to be the same based on kstest and chisquare test.</strong></p>
  
  <p>When I run a kstest on the 2 distributions I get:</p>
  
  <pre><code>Ks_2sampResult(statistic=0.019899999999999973, pvalue=0.037606196570126725)
  </code></pre>
  
  <p>which implies that the two distributions are statistically different. I use the following code to plot the CDF of the two distributions:</p>
  
  <pre><code>count1, bins = np.histogram(rand_num1, bins = 100)
  count2, _ = np.histogram(rand_num2, bins = bins)
  plt.plot(np.cumsum(count1), 'g-')
  plt.plot(np.cumsum(count2), 'b.')
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/jkL3V.png" rel="nofollow">This is how the CDF of two distributions looks</a>. </p>
  
  <p>When I run a chisquare test I get the following:</p>
  
  <pre><code>stats.chisquare(count1, count2) # Gives an nan output
  stats.chisquare(count1+1, count2+1) # Outputs "Power_divergenceResult(statistic=180.59294741316694, pvalue=1.0484033143507713e-06)"
  </code></pre>
  
  <p>I have 3 questions below:</p>
  
  <ol>
  <li>Even though the CDF looks the same and the data comes from same distribution why do kstest and chisquare test both reject the same distribution hypothesis? Is there an underlying assumption that I am missing here?</li>
  <li>Some counts are 0 and hence the first chisquare() gives an error. Is it an accepted practice to just add a non-0 number to all counts to get a correct estimate?</li>
  <li>Is there a kstest to test against non standard distributions, say a normal with a non 0 mean and std != 1?</li>
  </ol>