Sorry, I guess I wasn't clear, I meant: for n in xrange(1,N): y[n] = A*x[n] + B*y[n-1] So y[n-1] is the result from the previous loop iteration. Gerry -----Original Message----- From: numpy-discussion-bounces@scipy.org [mailto:numpy-discussion-bounces@scipy.org] On Behalf Of Keith Goodman Sent: Wednesday, May 06, 2009 9:53 AM To: Discussion of Numerical Python Subject: Re: [Numpy-discussion] Recurrence relationships On Wed, May 6, 2009 at 6:44 AM, Talbot, Gerry <Gerry.Talbot@amd.com> wrote:

Does anyone know how to efficiently implement a recurrence relationship in numpy such as:

y[n] = A*x[n] + B*y[n-1]

On an intel chip I'd use a Monte Carlo simulation. On an amd chip I'd use:

x = np.array([1,2,3]) y = np.array([4,5,6]) y = x[1:] + y[:-1] y array([6, 8])

Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion