I am trying to sample from a Dirichlet distribution, where some of the
shape parameters are very small.  To do so, the algorithm samples each
component individually from a Gamma(k,1) distribution where k is the shape
parameter for that component of the Dirichlet.  In principle, this should
always return a positive number (as the Dirichlet is defined).  However, if
k is very small, it will return zero:

In [157]: np.random.gamma(1e-1)
Out[157]: 4.863866491339177e-06

In [158]: np.random.gamma(1e-2)
Out[158]: 2.424451829710714e-57

In [159]: np.random.gamma(1e-3)
Out[159]: 5.1909861689757784e-197

In [160]: np.random.gamma(1e-4)
Out[160]: 0.0

In [161]: np.random.gamma(1e-5)
Out[161]: 0.0

What is the best way to deal with this?

Thanks!
Uri



...................................................................................
Uri Laserson
Graduate Student, Biomedical Engineering
Harvard-MIT Division of Health Sciences and Technology
M +1 917 742 8019
laser...@mit.edu
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to