Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating a binomial distribution around zero

I'm looking to generate a binomial-esque distribution. I want a binomial distribution but I want it centred around zero (I know this doesn't make much sense with respect to the definition of binomial distributions but still, this is my goal.)

The only way I have found of doing this in python is:

def zeroed_binomial(n,p,size=None):
    return numpy.random.binomial(n,p,size) - n*p

Is there a real name for this distribution? Does this code actually give me what I want (and how can I tell)? Is there a cleaner / nicer / canonical / already implemented way of doing this?

like image 620
jhoyla Avatar asked Nov 01 '25 14:11

jhoyla


1 Answers

What you're doing is fine if you want a "discretized" normal distribution centered around 0. If you want integer values, you should round n*p before subtracting.

But the limit of the binomial distribution is just the normal distribution when n becomes large and with p bounded away from 0 or 1. since n*p is not going to be an integer except for certain values, why not just use the normal distribution?

like image 159
Andrew Mao Avatar answered Nov 03 '25 06:11

Andrew Mao