Skip to contents

Computes the mode (most likely value) of the marginal distribution of \(K_J\).

Usage

mode_K_marginal(J, a, b, logS, M = .QUAD_NODES_DEFAULT)

Arguments

J

Integer; sample size.

a

Numeric; shape parameter of Gamma prior (> 0).

b

Numeric; rate parameter of Gamma prior (> 0).

logS

Matrix; pre-computed log-Stirling matrix.

M

Integer; number of quadrature nodes (default: 80).

Value

Integer; the value \(k\) that maximizes \(P(K_J = k \mid a, b)\).

Details

The mode is always >= 1 since \(P(K_J = 0) = 0\).

Examples

logS <- compute_log_stirling(50)
mode_K_marginal(50, 1.5, 0.5, logS)
#> [1] 6