Skip to content

Commit 95cc107

Browse files
authored
[mccall_model] Replace np.sum(a * b) with a @ b (#471)
1 parent bce028b commit 95cc107

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lectures/mccall_model.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ class McCallModel:
404404
# Evaluate value for each state-action pair
405405
# Consider action = accept or reject the current offer
406406
accept = w[i] / (1 - β)
407-
reject = c + β * np.sum(v * q)
407+
reject = c + β * (v @ q)
408408
409409
return np.array([accept, reject])
410410
```
@@ -488,7 +488,7 @@ def compute_reservation_wage(mcm,
488488
489489
# == Now compute the reservation wage == #
490490
491-
return (1 - β) * (c + β * np.sum(v * q))
491+
return (1 - β) * (c + β * (v @ q))
492492
```
493493

494494
The next line computes the reservation wage at default parameters
@@ -622,13 +622,13 @@ def compute_reservation_wage_two(mcm,
622622
623623
# == First compute h == #
624624
625-
h = np.sum(w * q) / (1 - β)
625+
h = (w @ q) / (1 - β)
626626
i = 0
627627
error = tol + 1
628628
while i < max_iter and error > tol:
629629
630630
s = np.maximum(w / (1 - β), h)
631-
h_next = c + β * np.sum(s * q)
631+
h_next = c + β * (s @ q)
632632
633633
error = np.abs(h_next - h)
634634
i += 1

0 commit comments

Comments
 (0)