Nov-17-2021, 12:38 PM
Hello, can you help me figure out what is the problem in this code?
In a model of supply and demand,
the supply is:
Qs = P**a + P + 1
And the demand is:
Qd = 1/(0.5*P**2 + P)
I want to draw a sample of 1000 values for a assuming that a is a random variable which is uniformly distributed within interval [0.2,2.0]. Then I want to solve the equilibrium price for each by numerically finding the root of the excess demand function.
This is my code:
This is the output:
In a model of supply and demand,
the supply is:
Qs = P**a + P + 1
And the demand is:
Qd = 1/(0.5*P**2 + P)
I want to draw a sample of 1000 values for a assuming that a is a random variable which is uniformly distributed within interval [0.2,2.0]. Then I want to solve the equilibrium price for each by numerically finding the root of the excess demand function.
This is my code:
import numpy as np a= np.linspace(0.2,2.0, num=1000) z = 0.5 excess_demand = lambda W: 1/(z*P**2 +P) - (P**(a) +P + 1) W, res = optimize.brentq(excess_demand, 1e-8, 1000.0, full_output=True) assert res.converged == True print(res) print(W)It appears to me an error? Can you tell me why?
This is the output:
Output: excess_demand = lambda W: 1/(z*P**2 +P) - (P**(b) +P + 1)
^
IndentationError: unexpected indent