Skip to contents

Safe accessor for the log-Stirling matrix with automatic bounds checking. Returns -Inf for invalid indices (k > J, k < 1).

Usage

get_log_stirling(J, k, logS)

Arguments

J

Sample size (non-negative integer).

k

Number of clusters (integer).

logS

Pre-computed log-Stirling matrix from compute_log_stirling.

Value

The value \(\log|s(J,k)|\), or -Inf if k > J or k < 1.

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