Skip to contents

Computes the cumulative distribution function \(P(K_J \leq k \mid a, b)\) for \(k = 0, 1, \ldots, J\).

Usage

cdf_K_marginal(
  J,
  a,
  b,
  logS,
  M = .QUAD_NODES_DEFAULT,
  M_verify = NULL,
  abs_tol = 1e-10,
  rel_tol = 1e-08,
  strict = FALSE
)

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).

M_verify

Optional independent order satisfying the package verification rule (at least max(2*M, M+40)).

abs_tol, rel_tol

Non-negative selected-versus-verification tolerances.

strict

Logical; require successful higher-order verification.

Value

Numeric vector of length \(J+1\) containing \(P(K_J \leq k \mid a, b)\) for \(k = 0, 1, \ldots, J\). The vector carries the PMF's "marginal_metadata" attribute.

Details

The CDF satisfies:

  • \(F(0) = 0\) (since \(P(K_J = 0) = 0\))

  • \(F(J) = 1\)

  • \(F(k)\) is non-decreasing in \(k\)

Examples

logS <- compute_log_stirling(50)
cdf <- cdf_K_marginal(50, 1.5, 0.5, logS)

# Verify CDF ends at 1
cdf[51]
#> [1] 1

# P(K <= 10)
cdf[11]
#> [1] 0.7009381