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

  • Home
  • SEARCH
  • 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 870367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:27:44+00:00 2026-05-15T10:27:44+00:00

I need to do a binomial test in Python that allows calculation for ‘n’

  • 0

I need to do a binomial test in Python that allows calculation for ‘n’ numbers of the order of 10000.

I have implemented a quick binomial_test function using scipy.misc.comb, however, it is pretty much limited around n = 1000, I guess because it reaches the biggest representable number while computing factorials or the combinatorial itself. Here is my function:

from scipy.misc import comb
def binomial_test(n, k):
    """Calculate binomial probability
    """
    p = comb(n, k) * 0.5**k * 0.5**(n-k)
    return p

How could I use a native python (or numpy, scipy…) function in order to calculate that binomial probability? If possible, I need scipy 0.7.2 compatible code.

Many thanks!

  • 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-05-15T10:27:45+00:00Added an answer on May 15, 2026 at 10:27 am

    Edited to add this comment: please note that, as Daniel Stutzbach mentions, the “binomial test” is probably not what the original poster was asking for (though he did use this expression). He seems to be asking for the probability density function of a binomial distribution, which is not what I’m suggesting below.

    Have you tried scipy.stats.binom_test?

    rbp@apfelstrudel ~$ python
    Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39) 
    [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from scipy import stats
    >>> print stats.binom_test.__doc__
    
        Perform a test that the probability of success is p.
    
        This is an exact, two-sided test of the null hypothesis
        that the probability of success in a Bernoulli experiment
        is `p`.
    
        Parameters
        ----------
        x : integer or array_like
            the number of successes, or if x has length 2, it is the
            number of successes and the number of failures.
        n : integer
            the number of trials.  This is ignored if x gives both the
            number of successes and failures
        p : float, optional
            The hypothesized probability of success.  0 <= p <= 1. The
            default value is p = 0.5
    
        Returns
        -------
        p-value : float
            The p-value of the hypothesis test
    
        References
        ----------
        .. [1] http://en.wikipedia.org/wiki/Binomial_test
    
    
    >>> stats.binom_test(500, 10000)
    4.9406564584124654e-324
    

    Small edit to add documentation link: http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.binom_test.html#scipy.stats.binom_test

    BTW: works on scipy 0.7.2, as well as on current 0.8 dev.

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

Sidebar

Ask A Question

Stats

  • Questions 441k
  • Answers 441k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Javascript is the right way to do this. The other… May 15, 2026 at 5:29 pm
  • Editorial Team
    Editorial Team added an answer After closely examining the request in Fiddler it appeared that… May 15, 2026 at 5:29 pm
  • Editorial Team
    Editorial Team added an answer Lazy loading and Deferred are pretty synonymous (AFAIK, please correct… May 15, 2026 at 5:29 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.