def _trunc_logser_solver(bins, b):
if bins == b:<EOL><INDENT>p = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>BOUNDS = [<NUM_LIT:0>, <NUM_LIT:1>]<EOL>DIST_FROM_BOUND = <NUM_LIT:10> ** -<NUM_LIT:15><EOL>m = np.array(np.arange(<NUM_LIT:1>, np.int(b) + <NUM_LIT:1>))<EOL>y = lambda x: np.sum(x ** m / b * bins) - np.sum((x ** m) / m)<EOL>p = optim.bisect(y, BOUNDS[<NUM_LIT:0>] + DIST_FROM_BOUND,<EOL>min((sys.float_info[<NUM_LIT:0>] / bins) ** (<NUM_LIT:1> / b), <NUM_LIT:2>),<EOL>xtol=<NUM_LIT>, maxiter=<NUM_LIT:1000>)<EOL><DEDENT>return p<EOL>
Given bins (S) and b (N) solve for MLE of truncated logseries
parameter p

Parameters
-----------
bins : float
    Number of bins. Considered S in an ecological context
b : float
    Upper truncation of distribution. Considered N in an ecological context

Returns
-------
: float
    MLE estimate of p

Notes
------
Adapted from Ethan White's macroecology_tools