Skip to content
Back to formatted view

Raw Message

Message-ID: <f8e6ff050812281127t6071f437s60f3d8aff1571b42@mail.gmail.com>
Date: 2008-12-28T19:27:40Z
From: Hadley Wickham
Subject: Avoiding looping on vector with stochastic dependency
In-Reply-To: <6BFA84D3-914F-45BB-9DA7-095029E2FB85@gmail.com>

On Sun, Dec 28, 2008 at 12:48 PM, Guillaume Chapron
<carnivorescience at gmail.com> wrote:
> Thanks for your reply. In fact my code example was simplified from something
> more general
>
> for (i in 2:length(w[,1])) {
>                w[i,] <- foo( w[i-1,] )
>        }
>
> and I was trying to write this without a loop. I will look at the method you
> describe, but  I'm not sure if it can still be applied if foo() is quite
> complex. (sorry for sending this to the wrong list, I thought this one was
> about everything that can make R running faster!)

In general, it is not possible to write out such recurrence relations
explicitly in closed form - see (e.g.)
http://en.wikipedia.org/wiki/Recurrence_relation for more details.

Hadley

-- 
http://had.co.nz/