Aug-16-2019, 01:50 AM
Not sure about how to interpret this, but at least it is better to drop using recursion in such cases; It might be quite slow, and even cause sys/recursion/limit exception. Take a look at slightly modified code, it should help you to get what you want. It seems that bisect method works as expected.
import sympy import numpy as np import math from scipy.optimize import fsolve,bisect from functools import partial @np.vectorize def PoissonEqs(p, m, alpha): result = list() for j in range(m + 1): if j == 0: result.append(math.exp(-p)-alpha) continue result.append(math.exp(m*math.log(p)-p-math.log(math.gamma(m+1)))+result[-1]) return result.pop() def func2(p): m=1; alpha=0.05 return PoissonEqs(p,m,alpha) from pylab import * plot(np.linspace(0.1,10,100), func2(np.linspace(0.1,10,100)), 'r') show() bisect(func2, 0.0000000001, 10)