
Tabular Q-learning update (Geron Ch 18, morie.fn hmql)
Source:R/geron_ml2_native.R
morie_geron_q_learning.RdOff-policy TD control: the max over next actions is what biases the
estimate upward. s, a and s_next are 0-based; max_next is
NaN on a terminal transition, matching Python.
Examples
Q <- matrix(c(0, 1, 2, -1), nrow = 2, byrow = TRUE)
morie_geron_q_learning(Q, 0, 1, 0.5, 1, 0.5, 0.9)
#> $Q
#> [,1] [,2]
#> [1,] 0 1.65
#> [2,] 2 -1.00
#>
#> $td_error
#> [1] 1.3
#>
#> $target
#> [1] 2.3
#>
#> $old_value
#> [1] 1
#>
#> $new_value
#> [1] 1.65
#>
#> $max_next
#> [1] 2
#>
#> $estimate
#> [1] 1.65
#>
#> $n
#> [1] 4
#>
#> $method
#> [1] "Tabular Q-learning update (off-policy TD control)"
#>