import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import math # 用math.mathfunction:non vectorized function
from numpy.random import default_rng
# 8.8 randon number generator
g_rv = default_rng() # to initiate a generator object
from scipy.linalg import inv, solve, det, eig
請完成一個CobbDouglas class定義,它必需包含至少下面提到的6個methods(q, mpl, mpk, cost, ld, mc), 程式答案寫在此大題最後的 qI code chunk:
class CobbDouglas:
which represents a class of firms equipped with Cobb-Douglas production function like: \[q_t = \phi[k_t^{\beta} l_t^{1-\beta}]\exp(\mu_t);\]
The detail of its definition is to provide the following usages:
cd1=CobbDouglas(0.5,1)
cd1.q(l=2,k=3,mu=0.3)
The marginal productivity of labor (mpl) and of capital (mpk) are defined as:
\[\begin{eqnarray}
mpl &=&\frac{\partial q_t}{\partial l_t}\\
mpk &=&\frac{\partial q_t}{\partial k_t}
\end{eqnarray}\]
cd1.mpl(l=2,k=3,mu=0.3)
cd1.mpk(l=2,k=3,mu=0.3)
Given \(r_t\) and \(w_t\) as the rental price of capital \(k_t\) and the wage of labor \(l_t\), the cost of a firm’s production will be \[w_tl_t+r_tk_t.\] Under cost minimization, for a firm to produce \(q_t\) under technology level \(\mu_t\), its inputs must satisfy the following two conditions:
cd1.cost(q=10, w=2,r=5,mu=0.3)
cd1.ld(q=10, w=2,r=5, mu=0.3)
The marginal cost of production is defined as \[mc_t\equiv\frac{\partial cost_t}{\partial q_t},\] where \(cost_t\) is the cost function of the firm.
cd1.mc(q=10, w=2,r=5, mu=0.3)
Assume there are infinitely many Cobb-Douglas firms (aka CD firms) with different labor intensity, i.e. different \(\beta\) values, and difference technology levels, i.e. different \(\mu\) values. Assume:
\(\beta \in (0,1)\) follows \(beta(a=2, b=5)\) distribution.
\(\mu\) follows standard normal distribution.
The following questions should be applied to all those 500 firms.
The cost method in part I is a long-run cost function in which capital level is free to choose. In the short-run, capital \(k\) is fixed for each firm; only \(l\) is free to choose. In this case the optimal short-run labor demand should satisfy: \[mpl=w\ \mbox{and} \ q=f(l,k)\]
Add a k attribute to each firm where k’s value is randomly drawn from a uniform(0.5, 1.5) distribution.
Add a short-run labor demand method, srld, to each instance, so that, the following method will produce its labor demand under $q=10, w=2, $ where \(\mu\) is from question 1’s random drawn outcome (therefore you need to add mu attribute to each instance):
cd1.srld(q=10, w=2, mu)
In the short-run, the marginal cost of production is the marginal change of \(q\) to its cost \(wl+rk\). Since \(r\) and \(k\) are not up to the firm’s choice in the short-run, the short-run marginal cost of the firm is: \[ w \frac{\partial srld}{\partial q}, \] where srld is the short-run labor demand method as a function.