title: Chi-Squared test in Python
body: <p>I've used the following code in <code>R</code> to determine how well observed values (20, 20, 0 and 0 for example) fit expected values/ratios (25% for each of the four cases, for example):</p>
  
  <pre><code>&gt; chisq.test(c(20,20,0,0), p=c(0.25, 0.25, 0.25, 0.25))
  
      Chi-squared test for given probabilities
  
  data:  c(20, 20, 0, 0)
  
  X-squared = 40, df = 3, p-value = 1.066e-08
  </code></pre>
  
  <p>How can I replicate this in Python? I've tried using the <code>chisquare</code> function from <code>scipy</code> but the results I obtained were very different; I'm not sure if this is even the correct function to use. I've searched through the <code>scipy</code> documentation, but it's quite daunting as it runs to 1000+ pages; the <code>numpy</code> documentation is almost 50% more than that.</p>