<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Lake Model Solutions
Excercise 1
We begin by initializing the variables and import the necessary modules
Step1:  Now construct the class containing the initial conditions of the problem
Step2:  New legislation changes $\lambda$ to $0.2$
Step3:  Now plot stocks
Step4:  And how the rates evolve
Step5:  We see that it takes 20 periods for the economy to converge to it's new steady state levels
Exercise 2
This next exercise has the economy expriencing a boom in entrances to the labor market and then later returning to the original levels.  For 20 periods the economy has a new entry rate into the labor market
Step6:  We simulate for 20 periods at the new parameters
Step7:  Now using the state after 20 periods for the new initial conditions we simulate for the additional 30 periods
Step8:  Finally we combine these two paths and plot
Step9:  And the rates
<ASSISTANT_TASK:>
Python Code:
%pylab inline
import LakeModel
alpha = 0.012
lamb = 0.2486
b = 0.001808
d = 0.0008333
g = b-d
N0 = 100.
e0 = 0.92
u0 = 1-e0
T = 50
Explanation: Lake Model Solutions
Excercise 1
We begin by initializing the variables and import the necessary modules
End of explanation
LM0 = LakeModel.LakeModel(lamb,alpha,b,d)
x0 = LM0.find_steady_state()# initial conditions
print "Initial Steady State: ", x0
Explanation: Now construct the class containing the initial conditions of the problem
End of explanation
LM1 = LakeModel.LakeModel(0.2,alpha,b,d)
xbar = LM1.find_steady_state() # new steady state
X_path = vstack(LM1.simulate_stock_path(x0*N0,T)) # simulate stocks
x_path = vstack(LM1.simulate_rate_path(x0,T)) # simulate rates
print "New Steady State: ", xbar
Explanation: New legislation changes $\lambda$ to $0.2$
End of explanation
figure(figsize=[10,9])
subplot(3,1,1)
plot(X_path[:,0])
title(r'Employment')
subplot(3,1,2)
plot(X_path[:,1])
title(r'Unemployment')
subplot(3,1,3)
plot(X_path.sum(1))
title(r'Labor Force')
Explanation: Now plot stocks
End of explanation
figure(figsize=[10,6])
subplot(2,1,1)
plot(x_path[:,0])
hlines(xbar[0],0,T,'r','--')
title(r'Employment Rate')
subplot(2,1,2)
plot(x_path[:,1])
hlines(xbar[1],0,T,'r','--')
title(r'Unemployment Rate')
Explanation: And how the rates evolve:
End of explanation
bhat = 0.003
T_hat = 20
LM1 = LakeModel.LakeModel(lamb,alpha,bhat,d)
Explanation: We see that it takes 20 periods for the economy to converge to it's new steady state levels
Exercise 2
This next exercise has the economy expriencing a boom in entrances to the labor market and then later returning to the original levels.  For 20 periods the economy has a new entry rate into the labor market
End of explanation
X_path1 = vstack(LM1.simulate_stock_path(x0*N0,T_hat)) # simulate stocks
x_path1 = vstack(LM1.simulate_rate_path(x0,T_hat)) # simulate rates
Explanation: We simulate for 20 periods at the new parameters
End of explanation
X_path2 = vstack(LM0.simulate_stock_path(X_path1[-1,:2],T-T_hat+1)) # simulate stocks
x_path2 = vstack(LM0.simulate_rate_path(x_path1[-1,:2],T-T_hat+1)) # simulate rates
Explanation: Now using the state after 20 periods for the new initial conditions we simulate for the additional 30 periods
End of explanation
x_path = vstack([x_path1,x_path2[1:]]) # note [1:] to avoid doubling period 20
X_path = vstack([X_path1,X_path2[1:]]) # note [1:] to avoid doubling period 20
figure(figsize=[10,9])
subplot(3,1,1)
plot(X_path[:,0])
title(r'Employment')
subplot(3,1,2)
plot(X_path[:,1])
title(r'Unemployment')
subplot(3,1,3)
plot(X_path.sum(1))
title(r'Labor Force')
Explanation: Finally we combine these two paths and plot
End of explanation
figure(figsize=[10,6])
subplot(2,1,1)
plot(x_path[:,0])
hlines(x0[0],0,T,'r','--')
title(r'Employment Rate')
subplot(2,1,2)
plot(x_path[:,1])
hlines(x0[1],0,T,'r','--')
title(r'Unemployment Rate')
Explanation: And the rates:
End of explanation
<END_TASK>