Skip to content

Commit deca896

Browse files
authored
Refactor price_single_beliefs function
Refactor price_single_beliefs function to improve clarity and efficiency.
1 parent 7b01350 commit deca896

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lectures/harrison_kreps.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,14 @@ def price_single_beliefs(transition, dividend_payoff, β=.75):
276276
"""
277277
Function to Solve Single Beliefs
278278
"""
279-
# First compute inverse piece
280-
imbq_inv = la.inv(np.eye(transition.shape[0]) - β * transition)
279+
# First compute (I - βQ)
280+
A = np.eye(transition.shape[0]) - β * transition
281281
282-
# Next compute prices
283-
prices = β * imbq_inv @ transition @ dividend_payoff
282+
# Next compute βQd
283+
b = β * (transition @ dividend_payoff)
284+
285+
# Solve linear system
286+
prices = la.solve(A, b)
284287
285288
return prices
286289
```

0 commit comments

Comments
 (0)