import math


def binomial_distribution(x, n, p):
    """
    Evaluate the binomial distribution b(x; n, p) as defined in the textbook.

    Equivalent to finding the probability of getting x heads when flipping
    a coin n times and the likeliness of getting heads on any one flip is p.

    The equation used is nCx * p ^ x * (1-p) ^ (n-x).
    """
    return math.comb(n, x) * (p ** x) * ((1 - p) ** (n - x))