Skip to content

Commit 15d4f05

Browse files
authored
Refactor price_single_beliefs function (#669)
Refactor price_single_beliefs function to improve clarity and efficiency.
1 parent a65c025 commit 15d4f05

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎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)