You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
data = generate_cross_section_lax(firm).block_until_ready()
@@ -339,14 +334,27 @@ ax.set_ylabel("log size")
339
334
340
335
plt.show()
341
336
342
-
#
343
-
# If the time horizon is not too large, we can also try generating all shocks at
344
-
# once.
345
-
#
346
-
# Note, however, that this approach consumes more memory, as we need to have to
347
-
# store large matrices of random draws
348
-
#
349
-
# Hence the code below will fail due to out-of-memory errors when `T` and `M` are large.
337
+
```
338
+
339
+
## Exercises
340
+
341
+
```{exercise-start}
342
+
:label: kp_ex1
343
+
```
344
+
345
+
Try writing an alternative version of `generate_cross_section_lax()` where the entire sequence of random draws is generated at once, so that all of `a`, `b`, and `e` are of shape `(T, M)`.
346
+
347
+
(The `update_cross_section()` function should not generate any random numbers.)
348
+
349
+
Does it improve the runtime?
350
+
351
+
What are the pros and cons of this approach.
352
+
353
+
```{exercise-end}
354
+
```
355
+
356
+
```{solution-start} kp_ex1
357
+
:class: dropdown
350
358
```
351
359
352
360
```{code-cell} ipython3
@@ -393,6 +401,11 @@ data = generate_cross_section_lax(firm).block_until_ready()
393
401
toc()
394
402
```
395
403
396
-
This second method might be slightly faster in some cases but in general the
404
+
This method might be faster in some cases but in general the
397
405
relative speed will depend on the size of the cross-section and the length of
0 commit comments