Sunday, 15 September 2013

python - Random integers from an exponential distribution between min and max -



python - Random integers from an exponential distribution between min and max -

i generate random integers on interval min max. uniform distribution in numpy:

numpy.random.randint(min,max,n)

does want.

however, give distribution of random numbers exponential bias. there number of suggestions e.g. pseudorandom number generator - exponential distribution numpy function numpy.random.randomstate.exponential, these not address how constrain distribution integers between min , max. i'm not sure how this, whilst still ensuring random distribution.

the exponential distribution continuous distribution. want discrete equivalent, geometric distribution. numpy's implementation generates strictly positive integers, i.e, 1,2,3,..., you'll want add together min-1 shift it, , truncate rejecting/throwing away results > max. that, in turn, means generating them one-by-one add together adding non-rejected values list until desired number. (you determine analytically proportion expect rejected, , scale n accordingly, you'll still end few short or few many.)

it's possible without rejection, you'd have create own inversion, determine probability of exceeding max, , generate uniforms between 0 , probability feed inversion algorithm. rejection simpler though it's less efficient.

python numpy random exponential-distribution

No comments:

Post a Comment