Computes the score function \(s_b(\alpha) = \partial/\partial b \log g_{a,b}(\alpha)\) for the Gamma(a, b) distribution.
Details
For the Gamma(shape = a, rate = b) distribution, the score function with
respect to b is:
$$s_b(\alpha) = \frac{a}{b} - \alpha.$$
A fundamental property of score functions is that their expectation is zero: $$E_{\alpha \sim g_{a,b}}[s_b(\alpha)] = 0.$$
Unlike score_a, this function is linear in \(\alpha\), so its
expectation converges very quickly with quadrature.
See also
score_a for the score with respect to a
Examples
# Evaluate score at several points
alpha_vals <- c(0.5, 1.0, 2.0, 5.0)
score_b(alpha_vals, a = 2.0, b = 1.0)
#> [1] 1.5 1.0 0.0 -3.0