
Reparameterization trick (Geron Ch 17, morie.fn grrep)
Source:R/geron_train_native.R
morie_geron_reparameterization_trick.Rdz = mu + exp(0.5 logvar) eps; the 0.5 is load-bearing. The LCG normal stream here CLAMPS u1 at 1e-12 before the log, unlike the grhei / grgrp / grdpmf streams, and always fills whole Box-Muller pairs.
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_geron_reparameterization_trick(V, V)
#> $z
#> [1] 3.327226 4.372061 3.806142 11.630776 21.826247 10.512573 37.898967
#> [8] 54.920096
#>
#> $sigma
#> [1] 1.648721 2.718282 4.481689 7.389056 12.182494 20.085537 33.115452
#> [8] 54.598150
#>
#> $eps
#> [1] 1.4115336 0.8726326 0.1798745 1.0327133 1.3811824 0.2246678 0.9330679
#> [8] 0.8593715
#>
#> $dz_dmu
#> [1] 1 1 1 1 1 1 1 1
#>
#> $dz_dlogvar
#> [1] 1.1636128 1.1860306 0.4030708 3.8153882 8.4131234 2.2562866 15.4494834
#> [8] 23.4600478
#>
#> $sample_mean
#> [1] 0.8618805
#>
#> $sample_variance
#> [1] 0.1846673
#>
#> $estimate
#> [1] 3.327226 4.372061 3.806142 11.630776 21.826247 10.512573 37.898967
#> [8] 54.920096
#>
#> $n
#> [1] 8
#>