Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'List' topicStudent Support Forum > General > "List"

< Previous CommentHelp | Reply To Comment | Reply To Topic
Author Comment/Response
yehuda
12/28/12 4:05pm

In Response To 'Loop doesn't work'
---------
This is rather simple matter.
In the first case Pension was not effected by the calculation so all started from the same initial value of 1,000,000
In the second case you wrote pension = pension... inside the Do loop. It does not effect the first round but the remaining 99 values are each start from a different initial value (which is the final value if the first iteration)

This code changes that, and also avoids Do loop (use Nest)
yehuda



pension = 1000000;
Risky = 0.6;
Riskless = 0.4;
riskfree = 0.04;
mu = 0.12;
sigma = 0.3;
draw = 150000;
temp := Nest[#*(Risky*
Exp[mu + sigma*RandomVariate[NormalDistribution[]]] +
Riskless*Exp[riskfree]) - draw &, pension, 10];
Count[{Table[temp, {100}]}, _?NonNegative, 2]/100.0



URL: ,

Subject (listing for 'List')
Author Date Posted
List Student0002012 12/20/12 5:43pm
Re: List jf 12/20/12 7:11pm
Additional questions Student0002012 12/20/12 9:29pm
Re: Additional questions jf 12/21/12 12:59pm
Loop doesn't work Student0002012 12/21/12 6:09pm
Loop doesn't work Student0002012 12/21/12 11:19pm
Re: Loop doesn't work yehuda 12/28/12 4:05pm
< Previous CommentHelp | Reply To Comment | Reply To Topic