def optimize_particle(state, index, method='<STR_LIT>', doradius=True):
blocks = state.param_particle(index)<EOL>if not doradius:<EOL><INDENT>blocks = blocks[:-<NUM_LIT:1>]<EOL><DEDENT>g = state.gradloglikelihood(blocks=blocks)<EOL>if method == '<STR_LIT>':<EOL><INDENT>h = state.jtj(blocks=blocks)<EOL><DEDENT>if method == '<STR_LIT>':<EOL><INDENT>h = state.hessloglikelihood(blocks=blocks)<EOL><DEDENT>step = np.linalg.solve(h, g)<EOL>h = np.zeros_like(g)<EOL>for i in range(len(g)):<EOL><INDENT>state.update(blocks[i], state.state[blocks[i]] - step[i])<EOL><DEDENT>return g,h<EOL>
Methods available are
    gn : Gauss-Newton with JTJ (recommended)
    nr : Newton-Rhaphson with hessian

if doradius, also optimize the radius.