import math


def hypergeometric_dist(x, N, n, k):
    """
    Evaluate the hypergeometric distribution h(x; N, n, k) as defined in the textbook.

    Equivalent to the probability of getting x blue socks when picking n socks from a total
    of N socks where a total of k socks are blue.

    Found with the equation kCx * (N-k)C(n-x) / NCn
    """
    return math.comb(k, x) * math.comb(N - k, n - x) / math.comb(N, n)