Lena is out of work in the port town of Sarn. At the start of each period she holds one wage offer w, drawn at random: wages[i] comes up with probability probs[i], independently every period. She can
- accept: she earns w in this period and in every period after, forever, worth w + \beta w + \beta^2 w + \ldots = \frac{w}{1 - \beta} today;
- reject: she collects unemployment benefit
bthis period, and next period she holds a fresh offer.
The discount factor \beta (beta, 0 < \beta < 1) weighs the future. Write V(w) for the value of holding offer w when she chooses well. Then
where h is the value of rejecting and searching on, the same for every offer. Her reservation wage \bar w = (1 - \beta)\,h is the wage whose value of accepting equals h: she accepts every offer with w \ge \bar w (when she is indifferent she accepts) and rejects the rest.
Write reservation_wage(wages, probs, b, beta) that returns a tuple (w_bar, p_accept, mean_accepted): the reservation wage, the probability that one period's offer is accepted, and the average wage of an accepted offer (the probability-weighted mean of the accepted wages), or None if she accepts no offer at all.
Examples
Input: wages = [10, 20, 30, 40, 50], probs = [0.2, 0.2, 0.2, 0.2, 0.2], b = 15, beta = 0.9
Output: (38.47826087, 0.4, 45.0)
Explanation: a patient searcher turns down 30 and waits for 40 or 50.
Input: the same offers and benefit, beta = 0.5
Output: (24.375, 0.6, 40.0)
Explanation: an impatient one takes 30 as well.
Input: wages = [10, 20], probs = [0.5, 0.5], b = 25, beta = 0.9
Output: (25.0, 0, None)
Explanation: every offer pays less than the benefit, so she never accepts.
Constraints
probshas the length ofwagesand adds up to 1- no wage is within
1e-6of the reservation wage, so rounding never decides a choice - numbers are compared with a tolerance of
1e-6
Goals
- Write the value of an offer as the better of accepting it and searching on
- Find the value of searching on by iterating its equation to a fixed point
- Turn that value into a reservation wage and the chance that an offer is accepted