
Categorical Bias Score (Kamath Eq 6.9)
Source:R/kamath_llm2_native.R
morie_kamath_ch6_cbs_variance.RdMean over template words of the variance over groups of log(p / prior).
ddof = 0 is numpy's POPULATION variance.
Examples
morie_kamath_ch6_cbs_variance(c("w1", "w2"), c("g1", "g2"), matrix(c(0.6,
0.3, 0.4, 0.7), 2), matrix(0.5, 2, 2))
#> $estimate
#> [1] 0.1102895
#>
#> $per_word
#> [1] 0.04110049 0.17947842
#>
#> $log_ratios
#> [,1] [,2]
#> [1,] 0.1823216 -0.2231436
#> [2,] -0.5108256 0.3364722
#>
#> $ddof
#> [1] 0
#>
#> $n
#> [1] 2
#>
#> $method
#> [1] "Categorical Bias Score (Kamath Eq 6.9)"
#>