[SciPy-User] implementing recursions
nicky van foreest
vanforeest@gmail....
Tue Mar 30 16:25:16 CDT 2010
Hi,
Just out of curiosity, is there a smarter way to implement the
following recursion?
grid =delta = 0.001
end = 20
np.arange(0,end+delta,delta)
n = len(grid)
gamma = 3*grid
for j in range(n-1, -1, -1):
gamma[j] += dot(gamma[j+1:],G[1:n-j]) # G is a precomputed np.array
I still dislike the remaining for loop, but I do not see an easy way
out. Of course, it is possible to write the above as Ax = b, and use
np.solve, but then I have to build the matrix A, which takes more time
as much more memory is claimed.
(I also realize that I can use Z-transforms, but this appears somewhat
of a hassle, to say the least.)
Thanks
Nicky
More information about the SciPy-User
mailing list