Skip to content

Commit f62b10a

Browse files
suda-yugammcky
andauthored
Replace np.sum(a * b) with a @ b (#209)
Co-authored-by: Matt McKay <mmcky@users.noreply.github.com>
1 parent 313f825 commit f62b10a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lectures/arellano.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def T_d(y_idx, v_c, v_d, params, arrays):
432432
433433
current_utility = u(def_y[y_idx], γ)
434434
v = np.maximum(v_c[B0_idx, :], v_d)
435-
cont_value = np.sum((θ * v + (1 - θ) * v_d) * P[y_idx, :])
435+
cont_value = (θ * v + (1 - θ) * v_d) @ P[y_idx, :]
436436
437437
return current_utility + β * cont_value
438438
@@ -457,7 +457,7 @@ def T_c(B_idx, y_idx, v_c, v_d, q, params, arrays):
457457
c = y + B - q[Bp_idx, y_idx] * Bp
458458
if c > 0:
459459
v = np.maximum(v_c[Bp_idx, :], v_d)
460-
val = u(c, γ) + β * np.sum(v * P[y_idx, :])
460+
val = u(c, γ) + β * (v @ P[y_idx, :])
461461
if val > current_max:
462462
current_max = val
463463
Bp_star_idx = Bp_idx

0 commit comments

Comments
 (0)