| Original Message (ID '182417') By Bill Simpson: |
| Code: Short-Version doesn't work:
...
pension = pension*(Risky* Exp[mu + sigma*RandomReal[NormalDistribution[0, 1]]] + Riskless*Exp[riskfree]) - draw
Long-Version Works:
...
year10 := year9*(Risky*Exp[mu + sigma*RandomReal[NormalDistribution[0, 1]]] + Riskless*Exp[riskfree]) - draw
The difference between not working and working is = versus :=
= calculates one number now and uses that same number 100 times in your Table.
:= saves then definition of year10 and calculates a new number each time you use year10 in your Table.
Study this and then think how to modify your code.
http://reference.wolfram.com/mathematica/tutorial/ImmediateAndDelayedDefinitions.html |
|