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

Post Reply:
Name:
Email Address:

Please send email when my message is replied to.

Url (optional):
Subject:
Message: view original message?
Attachment (optional):
Please answer this:1+3 =



Original Message (ID '191410') By yehuda:
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