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

## Measuring Risk Aversion

## Application: Insurance

Risk averse consumers often can reduce risk by purchasing insurance. To
illustrate aspects of insurance, we again use the exponential utility function.
The gamble changes: p1 = 0.1 is the probability of a bad outcome, the loss of 
x1 = $10. The probability of a good outcome, y1 = 0, is 1-p1 = 0.9. W = $25 in 
the absence of a bad outcome. Expected utility and expected wealth appear below.

U1(W,R):=1-%e^(-0.1*W/R)$  W0: 25$  R0:2$ 
EU1(W,R,x,y,p):=p*U1(W-x,R)+(1-p)*U1(W+y,R);
p1:0.1$ x1:10$ y1:0$   print("Expected Utility = ", 
EU1(W0,R0,x1,y1,p1)," and Expected Wealth = ", 
p1*(W0-x1)+(1-p1)*(W0+y1))$

The following figure depicts the lower expected utility that the
gamble imposes. 

wxdraw2d(yrange=[.45,.75],xrange=[10,30],
user_preamble="set key left",
points_joined=true,line_type=dots,
points([[0,U1(W0,R0)],[W0,U1(W0,R0)],[W0,0]]),
points([[(W0-x1),0],[(W0-x1),U1(W0-x1,R0)],
[(W0+y1),U1(W0+y1,R0)],[W0+y1,0]]),
points([[0,EU1(W0,R0,x1,y1,p1)],
[p1*(W0-x1)+(1-p1)*(W0+y1),EU1(W0,R0,x1,y1,p1)],
[p1*(W0-x1)+(1-p1)*(W0+y1),0]]),
line_type=solid,xlabel="Wealth ($)",
ylabel="Utility",key="Utility when R=2", 
explicit(U1(W,R0),W,0,30))$

An actuarially fair insurance premium would be equal 
to the expected loss to the insurer, $1. We dermine how much above 
the actuarially fair rate the consumer would be willing to pay. 

Doing so involves setting a the utility produced by a certain income
of W0 - Pr, where Pr is the premium the consumer would pay, equal to 
the expected utility absent insurance. In this case W0 - 1.2571 or 
a certain wealth of $23.743 would yield utility equal to that of the
consumer's status without insurance. Therefore, the consumer would pay
up to $0.2571 above the actuarially fair premium.

float(solve(((U1(W0-Pr,R0))-
EU1(W0,R0,x1,y1,p1)),Pr));
W0 - rhs(%[1]);

### Insurance with Continuous Probability

In many cases the impact of and adverse event is a random value. One way to 
this sort of situation is to treat the implication of a negative event as having 
possible values that are generated by a probability distribution function,or PDF.

Maxima's distrib module deals with probability distributions. To use distrib,
execute load(distrib). 

We assume that losses follow a Chi-squared distribution that has a mean value 
of $10. This distribution can be accessed using the command pdf_chi2(x,a), 
where x is the variable, a is its degrees of freedom (and its mean).

The graph below shows that, for a = 10, the distribution is 
skewed. The probability that x >= $10 equals 1 - prob(x < $10) =
1 - 0.56 = 0.44. 

load(distrib)$
wxdraw2d(yrange=[0,0.1],xlabel="Loss Value ($)",
 ylabel="f(x,10)", line_width=2,
 explicit(pdf_chi2(x,10),x,0,30), 
 points_joined=true,line_type=dots,line_width=1,
 points([[10,0],[10,pdf_chi2(10,10)]]))$
 print("cdf_chi2(10,10) = ",float(cdf_chi2(10,10)))$

Definite integration produces the consumer's expected utility without
insurance. Integrate the product W - x and the probablity of x for all
values of x (0 < x < infinity). E(U) = 0.515.

assume(x>0)$  
float(integrate(((pdf_chi2(x,10))*U1(W0-x,R0)),x,0,inf));

Determining the premium that the consumer would pay to avoid risk of loss
is determined as in the case of a given probability value.

float(solve(((U1(W0- Pr,R0))-float(
  integrate(((pdf_chi2(x,10))*U1(W0-x,R0)),x,0,inf))),Pr) );

The consumer is willing to pay $0.536, or 5.36%, above the actuarially 
fair premium.