def _nbinom_ztrunc_p(mu, k_agg):
p_eq = lambda p, mu, k_agg: (k_agg * p) / (<NUM_LIT:1> - (<NUM_LIT:1> + p)**-k_agg) - mu<EOL>p = optim.brentq(p_eq, <NUM_LIT>, <NUM_LIT>, args=(mu, k_agg))<EOL>return p<EOL>
Calculates p parameter for truncated negative binomial

    Function given in Sampford 1955, equation 4

    Note that omega = 1 / 1 + p in Sampford