def est_fpos_rate(token, trace=None, stats=None):
    "\n    Estimate false positive rate of a single-token signature.\n    \n    Estimates using the 'tokensplit' and trace-modeling methods,\n    and returns the higher (most pessimistic of the two). Note that both\n    of these estimates are strictly equal to or higher than the actual \n    fraction of streams that 'token' occurs in within the trace.\n    "
    global estd_fpos_rate
    if (not (estd_fpos_rate.has_key(trace) and estd_fpos_rate[trace].has_key(token))):
        if (not estd_fpos_rate.has_key(trace)):
            estd_fpos_rate[trace] = {}
        import polygraph.sigprob.tokensplit as tokensplit
        import polygraph.sigprob.sigprob as sigprob
        if trace:
            split_prob = tokensplit.mpp(token, trace, minlen=3)[0]
            stat_prob = tokensplit.maxcontextprob(token, trace)[0]
            estd_fpos_rate[trace][token] = max(split_prob, stat_prob)
        else:
            estd_fpos_rate[trace][token] = sigprob.token_prob(token, 1000, stats=stats)[(- 1)]
    rv = estd_fpos_rate[trace][token]
    if (len(token) > 20):
        del estd_fpos_rate[trace][token]
    if (len(estd_fpos_rate[trace].keys()) > 200):
        estd_fpos_rate[trace].clear()
    return rv
Estimate false positive rate of a single-token signature.

Estimates using the 'tokensplit' and trace-modeling methods,
and returns the higher (most pessimistic of the two). Note that both
of these estimates are strictly equal to or higher than the actual 
fraction of streams that 'token' occurs in within the trace.
def est_fpos_rate(token, trace=None, stats=None):
    "\n    Estimate false positive rate of a single-token signature.\n    \n    Estimates using the 'tokensplit' and trace-modeling methods,\n    and returns the higher (most pessimistic of the two). Note that both\n    of these estimates are strictly equal to or higher than the actual \n    fraction of streams that 'token' occurs in within the trace.\n    "
    global estd_fpos_rate
    if (not (estd_fpos_rate.has_key(trace) and estd_fpos_rate[trace].has_key(token))):
        if (not estd_fpos_rate.has_key(trace)):
            estd_fpos_rate[trace] = {}
        import polygraph.sigprob.tokensplit as tokensplit
        import polygraph.sigprob.sigprob as sigprob
        if trace:
            split_prob = tokensplit.mpp(token, trace, minlen=3)[0]
            stat_prob = tokensplit.maxcontextprob(token, trace)[0]
            estd_fpos_rate[trace][token] = max(split_prob, stat_prob)
        else:
            estd_fpos_rate[trace][token] = sigprob.token_prob(token, 1000, stats=stats)[(- 1)]
    rv = estd_fpos_rate[trace][token]
    if (len(token) > 20):
        del estd_fpos_rate[trace][token]
    if (len(estd_fpos_rate[trace].keys()) > 200):
        estd_fpos_rate[trace].clear()
    return rv