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

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
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: ,

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 Comment | Next Comment >Help | Reply To Comment | Reply To Topic