load(draw)$ 
set_draw_defaults(draw_realpart=false)$
fpprintprec:5$ ratprint:false$  kill(all)$

# Uncertainty

This chapter considers the making of decisions under conditions
of uncertainty. 

## Risk Preferences

Bernoulli formalized the discussion of risk and preferences in 1738. A casino 
offers a game of in which a fair coin is tossed at each stage. The pot starts at 
$1 and doubles each time a head appears. The first time a tail appears, the game 
ends and the player wins the contents of the pot, which is $2^(i-1) if the coin is 
tossed i times until the first tail results.

In this game, the expected value of the game exceeds what gamblers would pay to 
play. This must be the case, because the expected value if infinte.

The expected value of this opportunity equals one half of the maximum number 
of coin flips that the gambler is allowed to take (not of the number of heads that
actually results).

matrix(
["Expected value, 4 flips    ", "Limit as the number of flips grows"],
[sum(2^(i-1)*(1/2)^i,i,1,4), sum(2^(i-1)*(1/2)^i,i,1,inf)]);

The next cell (not in the text) shows the expected value of a game
in which 50 flips are allowed ($25), the value if 50 heads occur, and
the probability that 50 heads will occur. As in all other tosses, the
probability of 50 heads times the payoff from 50 heads equals 1/2.

n: 50$
1.0e-0*[sum(2^(i-1)*(1/2)^i,i,1,n), 2^(n-1), (.5)^n];
2^(n-1)*(.5)^n;

Bernoulli and analysts following him, explain the refusal to pay the
expected value,  or risk aversion, in terms of diminishing marginal utility 
of wealth. We illustrate this approach to risk preferences by examining a 
specific utility function. 

### An Example: The Exponential Utility Function}

Suppose that U1(W,R) = 1-exp(-0.1*W/R)$ is a consumer's utility function. 
In this exponential function W is wealth and R is a positive constant. 
We begin with a consumer whose wealth, absent a gamble, is given, W = $25. 
Set R = 2. The graph depicts the consumer's utility function . 

U1(W,R):=1-%e^(-0.1*W/R)$  W0: 25$  R0:2$ 
wxdraw2d(yrange=[0,1],xlabel="Wealth ($)", 
 ylabel="Utility",user_preamble="set key bottom",
 points_joined=true,line_type=dots, key=concat(
"Utility when R= ",string(R0)," and W = ",string(W0)),
 points([[0,U1(W0,R0)],[W0,U1(W0,R0)],[W0,0]]),
 line_type=solid, key="U(W,2)", 
 explicit(U1(W,R0),W,0,50))$

The graph shows that this utility function exhibits diminishing
marginal utility of wealth. The cell below shows that U(25,2) = 0.713. 

U1(W0,R0);

Face this consumer with a lottery or gamble. The expected utility of 
this gamble is the probability-weighted sum of the utility levels associated 
with the the outcomes. Let p be the probability that the consumer loses x 
and (1-p) be the probability that the consumer gains y. Then expected utility 
is as shown below.

EU1(W,R,x,y,p):=p*U1(W-x,R)+(1-p)*U1(W+y,R);

Suppose that x = $ = $10, and that p = 0.5. The expected utility is 
0.677.

x0:10$ y0:10$ p0:0.5$
EU1(W0,R0,x0,y0,p0);

Even though the expected payoff of this gamble is $0, the consumer's 
expected utility is less than the expected utility of getting W0 with 
100% probability.  

On the graph below, the straight diagonal dotted line represents 
weighted averages) of the utility levels associated with the two outcomes. 
The expected utility level occurs at W0, where the two
weights are 0.5 and lies on this diagonal dotted line. Its value is below 
U(W0) due to the concavity of the utility function. This risk averse 
consumer would not choose to take this gamble.

wxdraw2d(yrange=[0,1],points_joined=true,line_type=dots,
points([[0,U1(W0,R0)],[W0,U1(W0,R0)],[W0,0]]),
points([[(W0-x0),0],[(W0-x0),U1(W0-x0,R0)],[(W0+y0),U1(W0+y0,R0)],
[W0+y0,0]]),
points([[0,EU1(W0,R0,x0,y0,p0)],[W0,EU1(W0,R0,x0,y0,p0)]]),
line_width=2,line_type=solid,xlabel="Wealth ($)",ylabel="Utility",
key="Utility when R=2", explicit(U1(W,R0),W,0,50))$

The shape of the utility function reflects risk preferences. 
Larger R values reduce the utility level at each wealth level, 
and they reduce the function's concavity. Let R = 6. We truncate
the vertical axis relative to the presentation in the text.

wxdraw2d(yrange=[0.1,0.5],points_joined=true,line_type=dots,
points([[0,U1(W0,6)],[W0,U1(W0,6)],[W0,0]]),
points([[(W0-x0),0],[(W0-x0),U1(W0-x0,6)],[(W0+y0),U1(W0+y0,6)],
[W0+y0,0]]),
points([[0,EU1(W0,6,x0,y0,p0)],[W0,EU1(W0,6,x0,y0,p0)]]),
line_type=solid,xlabel="Wealth ($)",ylabel="Utility",
key="Utility when R=6", explicit(U1(W,6),W,0,50))$

An increase in R straightens out the utility function, reducing
the difference between the utility of a certain $25 and the gamble 
that results in an income of either $15 or $35, with an expected 
wealth level of $25. A higher R represents a less risk-averse consumer. 

### Inducing Risk Taking Behavior

We can alter the terms of the lottery and induce the risk averse consumer 
to prefer it to the certain wealth level. One way to do this is to adjust 
the probabilities of the payoffs. Let p fall until the consumer becomes 
indifferent between the certain $25 and the lottery. Label the resulting 
value p1. 

The first line below generates p1 = 0.378. The table shows that E(U) now
equals U(W0,R0). It also shows that E(W) > W0.

 float(solve(U1(W0,R0)-EU1(W0,R0,x0,y0,p),p))$ p1: rhs(%[1])$
matrix(["W0 ","U(W0,R0) ","p1 ","EU1(W0,R0,x0,y0,p1)","Expected W"],
[W0, U1(W0,R0), p1, EU1(W0,R0,x0,y0,p1), p1*(W0-x0)+(1-p1)*(W0+y0 ) ] );

The graph below shows that the range of expected income levels for
which EU1(W0,R0,x0,p) > U(W0,R0) consists of values above 27.4992. 

wxdraw2d(xtics_rotate=true,yrange=[0,1], 
user_preamble="set xlabel right; set key left",
xtics={W0-x0,W0,p1*(W0-x0)+(1-p1)*(W0+y0),W0+y0},
points_joined=true,line_type=dots,
points([[0,U1(W0,R0)], [W0,U1(W0,R0)],[W0,0]]),
points([[(W0-x0),0],[(W0-x0),U1(W0-x0,R0)],[(W0+y0),U1(W0+y0,R0)],[W0+y0,0]]),
points([[0,EU1(W0,R0,x0,y0,0.378)],[(.3780*(W0-x0)+(1-.3780)*(W0+y0)),
 EU1(W0,R0,x0,y0,0.378)],[(.3780*(W0-x0)+(1-.3780)*(W0+y0)),0]]),
line_width=2,line_type=solid,xlabel="Wealth ($)",ylabel="Utility",
key="Utility when R=2", explicit(U1(W,R0),W,0,50),
dimensions=[480,480])$