Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9070617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:43:36+00:00 2026-06-16T17:43:36+00:00

After reading a recent blog post about an application of the Poisson distribution, I

  • 0

After reading a recent blog post about an application of the Poisson distribution, I tried reproducing its findings using Python’s ‘scipy.stats’ module, as well as Excel/LibreOffice ‘POISSON’ and ‘CHITEST’ functions.

For the expected values shown in the article, I simply used:

import scipy.stats
for i in range(8):
    print(scipy.stats.poisson.pmf(i, 2)*31)

This reproduces the table shown in the blog post – and I also recreated it from within LibreOffice, using a first column A that has values 0 to 7 in cells A1, A2, …, A8, and the simple formula ‘=POISSON(A1, 2, 0)*31’ repeated in the first 8 lines of column B.

So far so good – now for the chi-squared p-test value:

Under LibreOffice, I just wrote down the observed values in cells C1-C8, and used ‘=CHITEST(C1:C8, B1:B8)’ to reproduce the article’s reported p-value of 0.18. Under scipy.stats however, I can’t seem to reproduce this value:

import numpy as np
import scipy.stats

obs = [4, 10, 7, 5, 4, 0, 0, 1]
exp = [scipy.stats.poisson.pmf(i, 2)*31 for i in range(8)]

# we only estimated one variable (the rate of 2 killings per year via 62/31) 
# so dof will be N-1-estimates
estimates = 1
print(scipy.stats.chisquare(np.array(obs), np.array(exp), ddof=len(obs)-1-estimates))
# (10.112318133864241, 0.0014728159441179519)
# the p-test value reported is 0.00147, not 0.18...
#
# Maybe I need to aggregate categories with observations less than 5 
# (as suggested in many textbooks of statistics for chi-squared tests)?
observedAggregateLessThan5 = [14, 7, 5, 5]
expectedAggregateLessThan5 = [exp[0]+exp[1], exp[2], exp[3], sum(exp[4:])]
print(scipy.stats.chisquare(np.array(observedAggregateLessThan5), np.array(expectedAggregateLessThan5), ddof=len(observedAggregateLessThan5)-1-estimates))
# (0.53561749342466913, 0.46425467595930309)
# Again the p-test value computed is not 0.18, it is 0.46...

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:43:37+00:00Added an answer on June 16, 2026 at 5:43 pm

    You are not using the ddof argument correctly. ddof is the change to make to the default degrees of freedom. The default is one less than the length. So you do not have to specify ddof at all:

    In [21]: obs
    Out[21]: [4, 10, 7, 5, 4, 0, 0, 1]
    
    In [22]: exp
    Out[22]: 
    [4.1953937803349941,
     8.3907875606699882,
     8.3907875606699882,
     5.5938583737799901,
     2.796929186889995,
     1.1187716747559984,
     0.37292389158533251,
     0.10654968331009501]
    
    In [23]: chisquare(obs, f_exp=array(exp))
    Out[23]: (10.112318133864241, 0.1822973566091409)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading many post on StackOverflow about the cons of using automatic reference counting
After reading Jeff's blog post on Protecting Your Cookies: HttpOnly . I'd like to
After reading the Bash man pages and with respect to this post , I
After reading the MSDN article ( http://msdn.microsoft.com/en-us/magazine/2009.01.genevests.aspx ) on implementing a Custom STS using
After reading this recent question by @Mehrdad on which classes should be made non-movable
After reading the recent smashing magazine article on optimisation, I ran some tests to
After reading on appFog website that I could use APScheduler to make a python
EDIT: after reading this http://projects.scipy.org/numpy/ticket/1322 it seems that the NumPy version I am using
In a recent Hacker Newsletter issue, this very useful article about decorators in Python
After reading Practical Common Lisp I finally understood what the big deal about macros

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.