Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

I have a list of RandomReal:

delta = RandomReal[{-0.01, 0.01}, 1000]

I want to add each element of the list to the corresponding result of a function iteration in my NestList, but I need some sort of index in the NestList.

I can't do it this way:

NestList[g[#, 3] + RandomReal[{-0.01, 0.01}] &, .5, 1000]

because the RandomReal list has to be predefined before calculating iterations.

What are my choices?

share|improve this question

marked as duplicate by Kuba, Artes, rasher, m_goldberg, Silvia Apr 1 at 23:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
So FoldList seems the function you need. –  Kuba Apr 1 at 17:37

1 Answer 1

As Kuba said, FoldList is what I need:

FoldList[g[#1, 3] + #2 &, .5, delta]
share|improve this answer
2  
Perhaps you would rather use Fold instead of FoldList. –  Artes Apr 1 at 17:49
    
Fold gives me the last item of FoldList if I understand correctly which is not what I need, because I have to ListPlot the thing after. –  Egor N Apr 1 at 20:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.