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 8999145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:08:28+00:00 2026-06-16T00:08:28+00:00

I am comparing two distributions, such as: group1 = [ 0, 0, 0, 1,

  • 0

I am comparing two distributions, such as:

group1 = [ 0, 0, 0, 1, 11, 11, 13, 12]

group2 = [ 0, 0, 0, 0, 5, 11, 18, 14]

My distributions don’t have a lot of elements, and I am not sure if chi-square is the best approach, but from what I read I think it is still the best of those tests which I have seen.

The problem is, that whichever chi-square I try, I am getting different results:

so that if I use:

import numpy as np

import scipy.stats.mstats as mst
mst.chisquare(np.array(group1), np.array(group2))

the answer will be: (8.874603174603175, 0.26178489290758555)

If I use:

import scipy.stats as stat
stat.chisquare(np.array(group1), np.array(group2))

I will get: (nan, nan)

And if I remove all the elements which are 0 in both groups so that my groups will now look as such:

group1 = [ 1, 11, 11, 13, 12]

group2 = [ 0, 5, 11, 18, 14]

using:

mst.chisquare(np.array(group1), np.array(group2))

will give me: (8.874603174603175, 0.06431137995249224)

I am very confused with this ambiguity. What is the true p-value for my distributions?

  • 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-16T00:08:29+00:00Added an answer on June 16, 2026 at 12:08 am

    I guess it is a bug in the scipy.stats.mstats module. mstats is supposed to handle masked arrays (arrays with invalid values) better than stats. However it seems that in this case it does not count correctly the number of degrees of freedom (DOF): The chi-square statistics (the first return value of chisquare) is the same before and after removing the zeros, so only DOF could change.

    Note that after removing the 0s in both arrays you will still get infinities because to calculate chi-square statistics you have to divide by frequencies in group2 (group2 in you array, see Wikipedia). mstat removes these invalid values, but it won’t adapt the DOF accordingly (because there is less elements the dof should be decreased by the difference of elements).

    I hope it clarifies it a bit. Please consider sending a bug report to scipy discussion list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible duplicate : comparing-two-arrays I have two NSArray and I'd like to create a
Possible Duplicate: Comparing Two Arrays Using Perl I am trying to find elements that
Hey I have a problem comparing the value of a CGPoint (struct with two
I am comparing two binary arrays. I have an array where values can either
I have been tasked with comparing two oracle schema with a large number of
I am comparing two folders using a diff tool. I have tried a few
i have an if statement comparing two NSStrings, one is user input from a
Possible Duplicate: Comparing two arrays & get the values which are not common I
Possible Duplicate: Comparing two collections for equality I have two lists List<int> Foo =
I have a problem with comparing two arraylist, my first arraylist looks like this:

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.