Apr-29-2020, 04:41 PM
Hello everyone
I have an assignment for university which I am having some problems with. We have to define a function which will return the total utility depending on consumption single utilities u_1, u_2 and u_3.
U(sol,parameters) = u_1 + beta * u_2 + beta**2 * u_3. The problem comes in when we have a look how u_2 is defined: u_2 <= (q * n / z). In this case n and z are known(as are y and beta later on) but q isnt.
This is the code I used to define the function but obviously u_3 will be 0. how can I code this an other way?
I have to create a function where I can plug in q and the parameters and get the total Utility U
The first part is the description of the function that my teacher has given me.
I have an assignment for university which I am having some problems with. We have to define a function which will return the total utility depending on consumption single utilities u_1, u_2 and u_3.
U(sol,parameters) = u_1 + beta * u_2 + beta**2 * u_3. The problem comes in when we have a look how u_2 is defined: u_2 <= (q * n / z). In this case n and z are known(as are y and beta later on) but q isnt.
This is the code I used to define the function but obviously u_3 will be 0. how can I code this an other way?
I have to create a function where I can plug in q and the parameters and get the total Utility U
The first part is the description of the function that my teacher has given me.
def U(sol,params): """ Returns the lifetime utility of a young person as a function of his consumption and money holdings (sol) as well as the parameters of the model (params) """ y, z, n, beta = params q = sol u_1 = (y - q) ** (1/2) u_2 = ((n / z) * q) ** (1/2) u_3 = ((n/z)**2 * q - (n/z)**2 * q)** (1/2) return u_1 + beta * u_2 + beta**2 * u_3