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

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+5 =



Original Message (ID '98671') By Bill Simpson:
In Response To 'Re: Utility_Function' --------- Ah, much more helpful. Here is one way. In[16]:= w=5.;c=3.; toss=gain=probability=rewards=changeInWealth=utility=Table[0,{11}]; For[i=1,i≤11,i++, toss[[i]]=i; gain[[i]]=2^(toss[[i]]-1); probability[[i]]=.5^toss[[i]]; rewards[[i]]=If[i==1,gain[[i]]*probability[[i]],gain[[i]]*probability[[i]]+rewards[[i-1]]]; changeInWealth[[i]]=Log[w+gain[[i]]-c]-Log[w]; utility[[i]]=Total[Take[changeInWealth,i]*Take[probability,i]] ]; Transpose[{toss,gain,probability,rewards,changeInWealth,utility}] Out[20]= {{1, 1, 0.5, 0.5, -0.5108, -0.2554}, {2, 2, 0.25, 1., -0.2231, -0.3112}, {3, 4, 0.125, 1.5, 0.1823, -0.2884}, {4, 8, 0.0625, 2., 0.6931, -0.2451}, {5, 16, 0.0313, 2.5, 1.2809, -0.2051}, {6, 32, 0.0156, 3., 1.9169, -0.1751}, {7, 64, 0.0078, 3.5, 2.5802, -0.1549}, {8, 128, 0.0039, 4., 3.2581, -0.1422}, {9, 256, 0.0020, 4.5, 3.9435, -0.1345}, {10, 512, 0.0010, 5., 4.6328, -0.1300}, {11, 1024, 0.0005, 5.5, 5.3240, -0.1274}} There are at least a dozen different ways of doing anything in Mathematica.