Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5989 > unrolled thread

delay evaluation inside RecurrencTable?

Started byAlan <alan.isaac@gmail.com>
First post2011-10-29 11:08 +0000
Last post2011-10-31 11:56 +0000
Articles 4 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  delay evaluation inside RecurrencTable? Alan <alan.isaac@gmail.com> - 2011-10-29 11:08 +0000
    Re: delay evaluation inside RecurrencTable? "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-10-30 09:30 +0000
      Re: delay evaluation inside RecurrencTable? Alan <alan.isaac@gmail.com> - 2011-10-31 11:50 +0000
    Re: delay evaluation inside RecurrencTable? DrMajorBob <btreat1@austin.rr.com> - 2011-10-31 11:56 +0000

#5989 — delay evaluation inside RecurrencTable?

FromAlan <alan.isaac@gmail.com>
Date2011-10-29 11:08 +0000
Subjectdelay evaluation inside RecurrencTable?
Message-ID<j8gms1$53k$1@smc.vnet.net>
My first attempt to simulate an AR(1) process was
RecurrenceTable[{a[n] == 0.8*a[n - 1] + RandomReal[{-1, 1}], 
  a[0] == 100}, a, {n, 1, 20}]
which of course failed because RandomReal was only evaluated once.

Is there some way to get a new evaluation of RandomReal for each n (*inside* RecurrenceTable)?

Thanks,
Alan Isaac

PS Sorry if this repeats. I posted this question days ago and it has not yet appeared.

[toc] | [next] | [standalone]


#6031

From"Dr. Wolfgang Hintze" <weh@snafu.de>
Date2011-10-30 09:30 +0000
Message-ID<j8j5fe$f7v$1@smc.vnet.net>
In reply to#5989
"Alan" <alan.isaac@gmail.com> schrieb im Newsbeitrag 
news:j8gms1$53k$1@smc.vnet.net...
> My first attempt to simulate an AR(1) process was
> RecurrenceTable[{a[n] == 0.8*a[n - 1] + RandomReal[{-1, 1}],
>  a[0] == 100}, a, {n, 1, 20}]
> which of course failed because RandomReal was only evaluated once.
>
> Is there some way to get a new evaluation of RandomReal for each n 
> (*inside* RecurrenceTable)?
>
> Thanks,
> Alan Isaac
>
> PS Sorry if this repeats. I posted this question days ago and it has 
> not yet appeared.
>

What about this?

a[0] = 100; Table[a[k] = 0.8*a[k - 1] + RandomReal[{-1, 1}] , {k, 1, 
20}]

Each time you call the Table new random numbers are taken taken.

--- Wolfgang

[toc] | [prev] | [next] | [standalone]


#6064

FromAlan <alan.isaac@gmail.com>
Date2011-10-31 11:50 +0000
Message-ID<j8m220$rlb$1@smc.vnet.net>
In reply to#6031
On Oct 30, 5:30 am, "Dr. Wolfgang Hintze" <w...@snafu.de> wrote:
> a[0] = 100; Table[a[k] = 0.8*a[k - 1] + RandomReal[{-1, 1}] , {k, 1,
> 20}]
>
> Each time you call the Table new random numbers are taken taken.



Now I am really puzzled.  Why does Table behave as I want,
but not RecurrenceTable?  Are both behaviors intentional?

Thanks,
Alan Isaac

[toc] | [prev] | [next] | [standalone]


#6068

FromDrMajorBob <btreat1@austin.rr.com>
Date2011-10-31 11:56 +0000
Message-ID<j8m2dh$rv1$1@smc.vnet.net>
In reply to#5989
Very good, Wolfgang; of what use is RecurrenceTable in the first place?

Bobby

On Sun, 30 Oct 2011 04:23:31 -0500, Dr. Wolfgang Hintze <weh@snafu.de>  
wrote:

>
> "Alan" <alan.isaac@gmail.com> schrieb im Newsbeitrag
> news:j8gms1$53k$1@smc.vnet.net...
>> My first attempt to simulate an AR(1) process was
>> RecurrenceTable[{a[n] == 0.8*a[n - 1] + RandomReal[{-1, 1}],
>>  a[0] == 100}, a, {n, 1, 20}]
>> which of course failed because RandomReal was only evaluated once.
>>
>> Is there some way to get a new evaluation of RandomReal for each n
>> (*inside* RecurrenceTable)?
>>
>> Thanks,
>> Alan Isaac
>>
>> PS Sorry if this repeats. I posted this question days ago and it has
>> not yet appeared.
>>
>
> What about this?
>
> a[0] = 100; Table[a[k] = 0.8*a[k - 1] + RandomReal[{-1, 1}] , {k, 1,
> 20}]
>
> Each time you call the Table new random numbers are taken taken.
>
> --- Wolfgang
>
>


-- 
DrMajorBob@yahoo.com

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web