It is a test for simulation of search model in the labor market.
Sorry if it has bugs or misunderstanding of the actual model in economics.
In the simulation, a unemployed worker searching a satisfied job in labor market, holding reservation wage in mind.
Companies offer various wage to the worker.
If an offered wage surpasses the reservation wage, the worker receive the offer and determine the wage as his salary.
A basic search in labor market:
In the first simulation, companies’ offer is stochastic value from normal distribution.
Through the offered wage list, if an offer surpass the reservation wage, the element in the list is chosen as determined wage. Otherwise determined wage remains reservation wage.
In the bar chart, red line is reservation wage, green line is determined wage.
import numpy as np from scipy.stats import norm from matplotlib.pylab import plt %matplotlib inline offer_mean = 5 offer_std = 1 search_limit = 15 reservation_wage = 6 # Make offered-wage list with normal distribution. offers = norm.rvs(offer_mean, offer_std, size=search_limit) # Append reservation-wage in case any offered-wages don't reach it. offers = np.append(offers, reservation_wage) # Receive the offer if offered-wage goes beyond reservation-wage. determined_wage = offers[offers>=reservation_wage] # Get search time until the laborer receives wage. search_attempt = np.where(offers == determined_wage) # bar chart. # Red is reservation wage; Green line is determined wage. plt.bar(left=[i for i in range(len(offers))] ,height=offers, width=1, color="skyblue") plt.axhline(y=reservation_wage, linewidth=1, color='r') # horizonal line for reservation wage. plt.axvline(x=search_attempt+1, linewidth=1, color='g') # vertical line for determined wage. plt.xlabel("Search Attempt") plt.ylabel("Offered Wage")
Changing reservation wage:
It is extension of basic search model above.
In the code, averages of determined wage in changing reservation value are calculated. To smooth the probabilistic noise, number of trial is set to 1000 for each average.
# Determine wage with a reservation wage. def determineWage(reservation_wage): determined_wage_list =  search_attempt_list =  for n in range(1000): offers = norm.rvs(offer_mean, offer_std, size=search_limit) offers = np.append(offers, reservation_wage) determined_wage = offers[offers>=reservation_wage] search_attempt = np.where(offers == determined_wage) determined_wage_list.append(determined_wage) search_attempt_list.append(search_attempt) return (determined_wage_list, search_attempt_list) offer_mean = 5 offer_std = 1 search_limit = 15 reservation_wages = np.linspace(0,10,50) # Various reservation wage. determined_wage_means =  search_attempt_means =  # Change reservation wage: for wage in reservation_wages: reservation_wage = wage # Repeat for determine wage in the same reservation wage. determined_wage_list, search_attempt_list = determineWage(reservation_wage) # Store mean of determined wage. determined_wage_means.append(np.mean(determined_wage_list)) search_attempt_means.append(np.mean(search_attempt_list))
As reservation wage goes up, the determined wage moves up as well.
plt.plot(reservation_wages, determined_wage_means) plt.xlabel("Reservation Wage") plt.ylabel("Mean of Determined Wage")
The relationship between reservation wage and searching attempt(receiving timing in 15 searching time) is different from the chart above.
In lower reservation wage until 5, offered wage is received at very early time. But in higher reservation wage than 6, receiving timing is prolonged at steep rate.
plt.plot(reservation_wages, search_attempt_means) plt.xlabel("reservation Wage") plt.ylabel("Mean of Search Attempt")