AllenDowney / ThinkBayes2

Text and code for the forthcoming second edition of Think Bayes, by Allen Downey.
http://allendowney.github.io/ThinkBayes2/
MIT License
1.81k stars 1.49k forks source link

The correctness of EvalExponentialPdf method in thinkbayes2.py #16

Closed 18fanfan closed 5 years ago

18fanfan commented 5 years ago

Dear professor Downey,

In chapter 7.6, you would like to compute the time between goals and the code in EvalExponentialPdf method is:

return lam*math.exp(-lam*x)

but I think the probability between two events is:

return math.exp(-lam*x)

The first term lam variable should be dropped.

Here comes my justification: Assume T is the time interval between two goals. The Pr(T > x ) means the probability in a certain time interval x should not occur scoring. so we take the k=0 to the Poisson distribution, then we got math.exp(-lam*x).

Although I know the EvalExponentialPdf only be called by MakeExponentialPmf, and the lam variable will be canceled out after Normalize function. so the result stays the same. But I still want to confirm with you the correctness of the method. Thanks in advance!

AllenDowney commented 5 years ago

I believe the function EvalExponentialPdf correctly computes the PDF of the exponential distribution. Please check https://en.wikipedia.org/wiki/Exponential_distribution and let me know if you disagree.

On Wed, May 22, 2019, at 11:42 PM, Szu-Yueh Fan wrote:

Dear professor Downey,

In chapter 7.6, you would like to compute the time between goals and the code in EvalExponentialPdf method is:

return lammath.exp(-lamx)

but I think the probability between two events is:

return math.exp(-lam*x)

The first term lam variable should be ignored

Here comes my justification: Assume T is the time interval between two goals. The Pr(T > x ) means the probability in a certain time interval x should not occur scoring. so we take the k=0 to the Poisson distribution, then we got math.exp(-lam*x).

Although I know the EvalExponentialPdf only be called by MakeExponentialPmf, and the lam variable will be canceled out after Normalize function. so the result stays the same. But I still want to confirm with you the correctness of the method. Thanks in advance!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AllenDowney/ThinkBayes2/issues/16?email_source=notifications&email_token=AAOLP3JBTVT3A7EILRFNXMDPWYHALA5CNFSM4HOZV2ZKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GVLK46A, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOLP3OVQOYAX5NUBWIFB7LPWYHALANCNFSM4HOZV2ZA.

18fanfan commented 5 years ago

Dear professor Downey,

I check the wiki, and it is the right definition. I also read this article https://neurophysics.ucsd.edu/courses/physics_171/exponential.pdf to realize the relation between the Poisson and exponential distribution.

I think I misunderstood the meaning of Pr(T > x) to explain the distribution of two goals.