def _mm(n_items, data, initial_params, alpha, max_iter, tol, mm_fun):
if initial_params is None:<EOL><INDENT>params = np.zeros(n_items)<EOL><DEDENT>else:<EOL><INDENT>params = initial_params<EOL><DEDENT>converged = NormOfDifferenceTest(tol=tol, order=<NUM_LIT:1>)<EOL>for _ in range(max_iter):<EOL><INDENT>nums, denoms = mm_fun(n_items, data, params)<EOL>params = log_transform((nums + alpha) / (denoms + alpha))<EOL>if converged(params):<EOL><INDENT>return params<EOL><DEDENT><DEDENT>raise RuntimeError("<STR_LIT>".format(max_iter))<EOL>
Iteratively refine MM estimates until convergence.

Raises
------
RuntimeError
    If the algorithm does not converge after `max_iter` iterations.