import math


def monobit_frequency(bit_str: str):
    """Frequency (Monobit) Test

    Determine whether the number of ones and zeros in a sequence are
    approximately the same as would be expected for a truly random sequence.

    See section 2.1 in this NIST publication:
    https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=906762
    """
    obs_sum = 0
    n = len(bit_str)
    for i in range(n):
        obs_sum += 1 if bit_str[i] == '1' else -1
    obs_stat = abs(obs_sum) / math.sqrt(n)
    p = math.erfc(obs_stat / math.sqrt(2))
    return p