how to get an array with "varying" poisson distribution
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.]] Thanks, Sebastian Haase
Sebastian Haase 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.
I'm afraid that at this point in time, the distributions only accept scalar values for the parameters. I've thought about reimplementing the distribution functions as ufuncs, but that's a hefty chunk of work that won't happen for 1.0. I'm afraid that, for now, you're stuck with iterating over the values. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
On Monday 24 July 2006 14:20, Robert Kern wrote:
Sebastian Haase 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.
I'm afraid that at this point in time, the distributions only accept scalar values for the parameters. I've thought about reimplementing the distribution functions as ufuncs, but that's a hefty chunk of work that won't happen for 1.0.
I'm afraid that, for now, you're stuck with iterating over the values.
Thanks for the reply - maybe this my time to get into weave ;-) Question about distributing and/or making "python-only-changes". How can one distribute modules using weave to other people who might NOT have a C compiler installed ? And further: when I change parts of that module that should not require a recompiling of the C part - is weave smart enough to recognise this ? Thanks, Sebastian (Oops, I just realized that this would be a question maybe for the SciPy list ... I'll assume that it's OK)
Robert Kern wrote:
Sebastian Haase 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.
I'm afraid that at this point in time, the distributions only accept scalar values for the parameters. I've thought about reimplementing the distribution functions as ufuncs, but that's a hefty chunk of work that won't happen for 1.0.
FWIW, I've had enquires about the availability, or not, of this functionality in NumPy as well, so when someone does have time to work on it, it will be very much appreciated. -- "You see stars that clear have been dead for years But the idea just lives on..." -- Bright Eyes
Hi Sebastian,
On 7/24/06, Sebastian Haase
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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Sebastian Haase wrote:
Hi, Essentially I'm looking for the equivalent of what was in numarray: from numarray import random_array random_array.poisson(arr)
I've just updated the mtrand library to allow this. It will be in 1.0b2 So, if you have latest SVN you can do from numpy import random random.poisson(arr) to do what you want. -Travis
On Tuesday 25 July 2006 15:09, Travis Oliphant wrote:
Sebastian Haase wrote:
Hi, Essentially I'm looking for the equivalent of what was in numarray: from numarray import random_array random_array.poisson(arr)
I've just updated the mtrand library to allow this. It will be in 1.0b2
So, if you have latest SVN you can do
from numpy import random random.poisson(arr)
to do what you want.
-Travis Great - thanks - you are awesome !! -Seb.
participants (5)
-
Charles R Harris
-
James Graham
-
Robert Kern
-
Sebastian Haase
-
Travis Oliphant