1 REM UTILITY  
5 CLEAR  1000  
10 CLS:PRINT  TAB(10);"PERSONAL UTILITY FUNCTION":PRINT   
20 PRINT "UTILITY THEORY HAS TO DO WITH ONE'S PREFERENCE FOR VARIOUS  
25 PRINT "DECISION ALTERNATIVES. SUPPOSE EVERY DECISION ONE CAN MAKE  
30 PRINT "LEADS TO A KNOWN MONETARY PAYOFF. THEN THAT PERSON WILL  
35 PRINT "CHOOSE THE DECISION WITH THE HIGHEST PAYOFF. HOWEVER, IF THERE  
40 PRINT "IS SOME UNCERTAINTY IN THE RESULT OF A DECISION THE CORRECT  
45 PRINT "DECISION IS NOT SO OBVIOUS. UTILITY THEORY PERMITS US TO  
50 PRINT "ASSIGN A NUMBER TO EACH PAYOFF, ITS 'UTILITY'. HIGHER PAYOFFS  
55 PRINT "LEAD TO HIGHER UTILITIES BUT A UTILITY OF 2  FOR $5000 DOES  
60 PRINT "DOES NOT NECESSARILY MEAN A UTILITY OF 4 FOR $10000. ONCE  
65 PRINT "UTILITIES ARE DETERMINED DECISIONS ARE MADE BASED UPON HIGHEST  
70 PRINT "EXPECTED UTILITY.  
75 PRINT :GOSUB  10100  
80 CLS  
90 PRINT "UTILITIES ARE DETERMINED IN THE FOLLOWING WAY: THE POSSIBLE  
95 PRINT "PAYOFFS ARE RANKED FROM HIGHEST TO LOWEST. THE HIGHEST PAYOFF  
100 PRINT "IS ASSIGNED SOME ARBITRARY UTILITY, SAY 1. THE LOWEST PAYOFF  
105 PRINT "IS ASSIGNED SOME LOWER ARBITRARY UTILITY, SAY 0. WE DETERMINE   
110 PRINT "THE UTILITIES OF THE OTHER PAYOFFS BY SETTING UP A GAMBLE   
115 PRINT "WE ARE GIVEN THE CHOICE OF HAVING THIS PAYOFF FOR SURE OR OF  
120 PRINT "GETTING THE HIGHEST PAYOFF WITH PROBABILITY P AND THE LOWEST  
125 PRINT "WITH PROBABILITY 1-P. WITH P BEING DETERMINED THE UTILITY OF  
130 PRINT "THIS MIDDLE PAYOFF IS COMPUTED. AS THE PAYOFFS GO UP SO MUST P.  
132 PRINT "WE LOOK FOR THE P SO THAT WE ARE INDIFFERENT BETWEEN THE SURE  
134 PRINT "THING AND THE GAMBLE. UTILITY THEORY SAYS THERE IS SUCH A P.  
135 PRINT :GOSUB  10100:CLS  
138 PRINT "FOR EXAMPLE IF THE LOWEST PAYOFF WAS $0 AND THE HIGHEST WAS  
140 PRINT "$100000 THEN FOR AN INTERMEDIATE PAYOFF OF $50000 WE WOULD ASK  
145 PRINT "WOULD WE PREFER $50000 FOR SURE OR $100000 WITH PROBABILITY P  
150 PRINT "AND $0 WITH PROBABILITY 1-P. KEEP ADJUSTING P UNTIL WE ARE  
155 PRINT "INDIFFERENT TO THE SURE THING AND THE BET. THIS IS P.  
160 PRINT   
165 PRINT "DIFFERENT PEOPLE HAVE DIFFERENT UTILITY FUNCTIONS. THUS UNDER  
170 PRINT "IDENTICAL CIRCUMSTANCES DIFFERENT PEOPLE MAY MAKE DIFFERENT  
175 PRINT "DECISIONS AND BOTH STILL MAXIMIZE EXPECTED UTILITY. THE   
180 PRINT "PROGRAM WILL ASSIGN UTILITIES TO DOLLAR AMOUNTS BETWEEN  
185 PRINT "$0 AND $100000 WITH THE UTILITY OF $0 BEING SET TO 0 AND THAT  
190 PRINT "OF $100000 BEING SET TO 10.  
200 PRINT :INPUT "PRESS ENTER TO BEGIN";Z9$  
300 DIM  A(20),P(20),U(20)  
310 DATA  0,100,1000,3000,5000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000  
320 FOR I=1 TO 15:READ A(I):NEXT : REM AMOUNTS FOR COMPUTATION  
330 P(1)=0:P(15)=1  
335 U(1)=0:U(15)=10  
340 CLS  
350 FOR  I=2  TO  14  
355 PRINT   
360 PRINT "WITH WHAT PROBAILITY(P) WOULD YOU BE INDIFFERENT TO $";A(I);"FOR  
370 PRINT "SURE OR $";A(15);"WITH PROBABILITY P AND"; A(1);"WITH PROBABILITY  
380 PRINT "1 - P. THIS PROBABILITY MUST BE AT LEAST EQUAL TO";P(I-1)  
390 PRINT :INPUT "ENTER THE PROBABILITY";P(I)  
400 IF  P(I)<P(I-1) OR P(I)>1  THEN  PRINT :PRINT "PROBABILITY MUST BE BETWEEN";A(I-1);"AND";A(15):PRINT :GOTO  360  
410 NEXT  I  
430 REM COMPUTE UTILITIES  
440 FOR  I=2  TO  15:U(I)=P(I)*U(15)+(1-P(I))*U(1):NEXT   
500 CLS:INPUT "IS PRINTED OUTPUT DESIRED(Y/N)";Z2$  
510 IF  Z2$<>"Y"  AND  Z2$<>"N"  THEN  GOSUB  10000:GOTO  500  
520 F$(1)="  PAYOFF        UTILITY    "  
530 F$(2)="  ######          ##.## "  
540 CLS:PRINT  F$(1):IF  Z2$="Y"  THEN  LPRINT  F$(1):LPRINT " "  
550 FOR  I=1  TO  15  
560 PRINT USING  F$(2);A(I),U(I)  
570 IF  Z2$="Y"  THEN  LPRINT  USING  F$(2);A(I),U(I)  
575 IF  I=10  THEN  PRINT :GOSUB  10100:PRINT  F$(1)  
580 NEXT  I  
590 END  
10000 PRINT "INPUT ERROR!TRY AGAIN!":FOR  JJ=1 TO 300:NEXT :RETURN   
10100 INPUT "PRESS ENTER TO CONTINUE";Z9$:RETURN   

