Safe accessor for the log-Stirling matrix with automatic bounds checking.
Returns -Inf for invalid indices (k > J, k < 1).
Arguments
- J
Sample size (non-negative integer).
- k
Number of clusters (integer).
- logS
Pre-computed log-Stirling matrix from
compute_log_stirling.
See also
compute_log_stirling for matrix computation
Examples
logS <- compute_log_stirling(10)
# Valid access
get_log_stirling(4, 2, logS)
#> [1] 2.397895
# Invalid access returns -Inf
get_log_stirling(4, 5, logS)
#> [1] -Inf
get_log_stirling(4, 0, logS)
#> [1] -Inf