Thanks for your interest. An issue that recently came up in the Probability 
module is sampling from a Poisson distribution 
<https://en.wikipedia.org/wiki/Poisson_distribution>. It used to not work 
at all, and now it does but the algorithm is not efficient when the 
parameter lamda is large. For example:

from sympy.stats import *
sample(Poisson('x', 1000))

can take a while to return. 

Usually one can sample by generating a Uniform(0, 1) random number u, and 
then apply the inverse of the cumulative distribution function (CDF) to u. 
But there isn't a formula for the inverse of the of a Poisson random 
variable. The current algorithm 
<https://github.com/sympy/sympy/blob/master/sympy/stats/drv_types.py#L31> 
simply 
goes over all integers looking for the first one where CDF(n) >= u. There 
ought to be a better way of doing this. 

The first idea that comes to mind is to make giant steps (in power of 2) 
until CDF(n) >= u is reached, and then refine by bisection. But perhaps 
it's better to do research first, there is probably an algorithm out there 
that we can use. Maybe R has it? https://www.r-project.org/ 


 

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/8f337698-5ba7-40dc-9273-3dc47207acd3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to