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
@@ -470,10 +468,8 @@ We have used a look with a few modifications to help with efficiency. To summar
470
468
- replaced the `if` with the ternary interface
471
469
- preallocated a `zp, wp, R` to store intermediate values for the calculations.
472
470
- swapped the `w, z` and `wp, zp` to step forward each period rather than savings all of the simulation paths. This is sufficient since we will only plot statistics of the terminal distribution rather than in the transition.
473
-
- replaced the `randn()` at each simulation step with a draw of random values for all agents, i.e. `randn(N)`. This will make parallelization possible.
474
471
- annotated with the `@turbo` macro uses a package to speed up the inner loop. This is discussed in more detail below.
475
-
476
-
Using this function, we can iterate forward from a distribution of wealth and income
472
+
- replaced the `randn()` at each simulation step with a draw of random values for all agents, i.e. `z_shock, R_shock, w_shock`. This will make parallelization with `@turbo` possible.
477
473
478
474
To use this function, we pass in parameters and can access the resulting wealth distribution and inequality measures.
479
475
@@ -482,7 +478,8 @@ p = wealth_dynamics_model()
482
478
N = 100_000
483
479
T = 500
484
480
res = simulate_panel(N, T, p)
485
-
@show median(res.w), mean(res.w), res.gini;
481
+
@show median(res.w)
482
+
@show res.gini;
486
483
```
487
484
488
485
Now we investigate how the Lorenz curves associated with the wealth distribution change as return to savings varies.
@@ -491,15 +488,18 @@ The code below simulates the wealth distribution, Lorenz curve, and gini for mul
w, z = step_wealth_vectorized(w, z, p) # steps forward
611
614
end
612
615
sort!(w) # sorts the wealth so we can calculate gini/lorenz
613
616
F, L = lorenz(w)
@@ -628,12 +631,12 @@ T = 200
628
631
The results displayed above are done with the server compiling these notes, and is likely not representative. For example, on one of our machines the results are
629
632
630
633
```{code-block} none
631
-
192.621 ms (1218 allocations: 463.90 MiB)
632
-
592.451 ms (18 allocations: 6.10 MiB)
633
-
589.632 ms (6412 allocations: 2.39 GiB)
634
+
282.244 ms (1218 allocations: 463.90 MiB)
635
+
576.120 ms (18 allocations: 6.10 MiB)
636
+
836.909 ms (6412 allocations: 2.39 GiB)
634
637
```
635
638
636
-
The performance will depend on the availability of SIMD and AVX512 on your processor and your number of threads for the `tturbo` version. `LoopVectorization.jl` can also parallelize over threads and multiple processes by replacing with the `@tturbo` macro, but this does not seem to significantly improve performance in this case.
639
+
The performance will depend on the availability of [SIMD](https://en.wikipedia.org/wiki/Single_instruction,_multiple_data) and [AVX512](https://en.wikipedia.org/wiki/AVX-512) on your processor. `LoopVectorization.jl` can also parallelize over threads and multiple processes by replacing with the `@tturbo` macro, but this does not seem to significantly improve performance in this case.
637
640
<!--
638
641
# DECIDED AGAINST INCLUSION AFTER SEEING PERFORMANCE OF LOOPVECTORIZATION VERSION
0 commit comments