% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/statistics.R
\name{hypergeometric_p_value}
\alias{hypergeometric_p_value}
\title{One-sided hypergeometric p-value (over-representation)}
\usage{
hypergeometric_p_value(N, K, n, k)
}
\arguments{
\item{N}{Population size (total items in the universe). Integer >= 1.}

\item{K}{Number of success states in the population (e.g. inclusive |A|). Integer >= 0.}

\item{n}{Number of draws (e.g. inclusive |B|). Integer >= 0.}

\item{k}{Observed successes (e.g. |A intersection B|). Integer >= 0.}
}
\value{
Numeric in [0, 1].
}
\description{
Computes P(X >= k) where X ~ Hypergeometric(N, K, n). Returns 1.0 for
invalid inputs so the metric is safe to feed into BH-FDR without filtering.
}
\details{
Maps to R's `phyper(k - 1, K, N - K, n, lower.tail = FALSE)`. Note that R's
phyper parameter convention differs from Python's scipy: R uses `m` for
success-in-population and `n` for failure-in-population (= N - K), where
Python uses `N` for total population.
}
\examples{
hypergeometric_p_value(20000, 138, 581, 126)
}
