Holding Out for a Better Offer

job search · reservation wage · Bellman equation · fixed-point iteration · expected value

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 b this 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

V(w) = \max\left(\frac{w}{1 - \beta},\; h\right), \qquad h = b + \beta \sum_i \text{probs}[i]\; V(\text{wages}[i])

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

  • probs has the length of wages and adds up to 1
  • no wage is within 1e-6 of 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
Starting Python…