| Author |
Comment/Response |
jf
|
12/21/12 12:59pm
In Response To 'Additional questions' --------- 1. a) The documentation on Count talks about patterns, so you need to read up on patterns. The first few sections of
http://reference.wolfram.com/mathematica/tutorial/PatternsOverview.html
should help.
1. b)
In[1]:= data10 = RandomReal[{-1, 1}, {10}]
This pattern says to match one of anything, so long as it is a negative number.
In[3]:= Count[data10, _?Negative]
Out[3]= 3
If the values you are looking for are deeper than the first level, use a "level specification" to say how deep to drill.
In[4]:= Count[Table[data10, {100}], _?Negative, 2]
Out[4]= 300
2)
Coefficient for first iteration.
dat = Pension;
The ":=" (SetDelayed) is not needed because the whole line will be evaluated each iteration.
Do[
dat = dat*(Risky*Exp[mu + sigma* RandomReal[NormalDistribution[0, 1]]] +
Riskless*Exp[riskfree]) - draw, {10}]
"dat" will have the final value after the loop finishes.
Starting user-variable names with capital letters risks conflict with current or future built-in names.
Attachment: sf179210.nb, URL: , |
|