[Numpy-discussion] how to get an array with "varying" poisson distribution

Charles R Harris charlesr.harris at gmail.com
Mon Jul 24 23:42:31 EDT 2006


Hi Sebastian,

On 7/24/06, Sebastian Haase <haase at msg.ucsf.edu> wrote:
>
> Hi,
> Essentially I'm looking  for the equivalent of what was in numarray:
>     from numarray import random_array
>     random_array.poisson(arr)
>
> That is: if for example arr is a 256x256 array of positive integers, then
> this
> returns a new array of random numbers than are drawn according to the
> poisson
> statistics  where arr's value at coordinate y,x  determines the mean of
> the
> poisson distribution used  to generate  a new value for y,x.
>
> [[This is needed e.g. to simulate quantum noise in CCD images. Each pixel
> has
> different amount of noise depending of what it's (noise-free) "input"
> value
> was.]]


How accurate do you want the distribution to be and what sort of  offset is
there? If the number of counts is greater that about 10 and you don't care
too much about the poisson tail then a gaussian will work fine. If you have
very large counts (>1e6), which I doubt, the  accuracy of the poisson
distribution becomes a tricky matter because it needs care to compute the
factorial to the needed accuracy. The factorial turns up in the rejection
methods used in the algorithms. Most of the algorithms also compute special
constants that depend on the mean of the distribution, so while efficient
for a fixed mean they are less so for varying means like you want.

I tend to just go with gaussian noise most of the time.

Thanks,
> Sebastian Haase
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060724/73773cf7/attachment-0001.html>


More information about the NumPy-Discussion mailing list