mardi 14 juin 2016

RuntimeWarning: invalid value encountered in power while plotting poisson distribution


I want to run this piece of code

def poisson(k, lamb):
return (lamb**k/factorial(k)) * np.exp(-lamb)

x_plot = np.linspace(0, 10, 100)
plt.plot(x_plot, poisson(x_plot, parameters), 'r-', lw=2) 
plt.show()

in which parameters = 0.00213553

But every time this warning occurs:

 RuntimeWarning: invalid value encountered in power
 return (lamb**k/factorial(k)) * np.exp(-lamb)

and just a horizontal line appears.

I've checked similar problems but they didn't really help. I've also tried to cast the function return value to float128 which didn't work either. (using Python 2.7.6 64-bit)


Aucun commentaire:

Enregistrer un commentaire