Re: Fast way to calculate sum of discrete poisson distribution [message #52724] |
Sat, 24 February 2007 15:12 |
Jonathan Dursi
Messages: 9 Registered: November 2006
|
Junior Member |
|
|
On Feb 24, 4:10 pm, b...@kaifler.net wrote:
> I have been struggeling with this for a while. Basically I need to
> calculate the quadratic sum of the discrete poisson distribution:
>
> k = INDGEN(8)
>
> sum = TOTAL( p^k / FACTORIAL(k) * EXP(-p) * k^2 )
>
> This workes fine for a scalar p. Is there a way to calculate the
> quadratic sum for every element of an array p without using a loop?
So something like this seems to work:
IDL> k = rebin(indgen(8),8,3)
IDL> p = transpose(rebin([.1,.4,.9],3,8))
IDL> print, k
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7
IDL> print, p
0.100000 0.100000 0.100000 0.100000 0.100000
0.100000 0.100000 0.100000
0.400000 0.400000 0.400000 0.400000 0.400000
0.400000 0.400000 0.400000
0.900000 0.900000 0.900000 0.900000 0.900000
0.900000 0.900000 0.900000
IDL> sum = total(p^k/factorial(k)*exp(-p)*k^2,1)
IDL> print, sum
0.11000000 0.55999927 1.7096826
- Jonathan
--
ljdursi@gmail.com
http://www.cita.utoronto.ca/~ljdursi.
|
|
|