comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Help needed!!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Help needed!! [message #70499 is a reply to message #70498] Fri, 16 April 2010 12:11 Go to previous messageGo to previous message
bala murugan is currently offline  bala murugan
Messages: 23
Registered: April 2010
Junior Member
On Apr 16, 12:59 pm, "R.G. Stockwell" <noem...@please.com> wrote:
> "bala murugan" <bala2...@gmail.com> wrote in message
>
> news:63998232-09c5-4bf3-a795-b85c5c03b954@r27g2000yqn.google groups.com...
> ...
> CODE:
>
> FUNCTION poissondist,fLambda,N
> FOR i=1,N,1 DO BEGIN
>  a = FLTARR(N)
>  r = RANDOMU(SEED,1)
>  FOR j=1,N,1 DO BEGIN
>    x=poisson(j,fLambda)
>    if abs(x-r) lt 0.0001 THEN a[i]=j
>   ENDFOR
> ENDFOR
> RETURN,a
> END
> *****************************************
>
> when i becomes equal to N you will get an error
> trying to access a[i].
> Also, your a[0] is equal to zero.
>
> And,  your function is
> FUNCTION poissondist, fLambda, N
> and you call it like:
> x=poisson(j,fLambda)
>
> Note that flambda is in the wrong position.

FIRST:
This function "x=poisson(j,fLambda)" is different from the
poissondist.

Say I use " x = (fLambda^j)/(exp(fLambda)*factorial(j)) " instead of
the function poisson.

So this problem is now solved.

SECOND:
FUNCTION poissondist,fLambda,N
FOR i=0,N-1,1 DO BEGIN
a = FLTARR(N)
r = RANDOMU(SEED,1)
FOR j=0,N-1,1 DO BEGIN
x = (fLambda^j)/(exp(fLambda)*factorial(j))
if abs(x-r) lt 0.0001 THEN a[i]=j
ENDFOR
ENDFOR
RETURN,a
END


Hope its fine now....
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: GridData Conundrum
Next Topic: Comparison operators and floating-point errors

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 16:08:33 PDT 2025

Total time taken to generate the page: 0.00197 seconds