def Akmaev_adjustment(theta, q, beta, n_k, theta_k, s_k, t_k):
L = q.size  <EOL>k = <NUM_LIT:1><EOL>n_k[k-<NUM_LIT:1>] = <NUM_LIT:1><EOL>theta_k[k-<NUM_LIT:1>] = theta[k-<NUM_LIT:1>]<EOL>l = <NUM_LIT:2><EOL>while True:<EOL><INDENT>n = <NUM_LIT:1><EOL>thistheta = theta[l-<NUM_LIT:1>]<EOL>while True:<EOL><INDENT>if theta_k[k-<NUM_LIT:1>] <= thistheta:<EOL><INDENT>k += <NUM_LIT:1><EOL>break  <EOL><DEDENT>else:<EOL><INDENT>if n <= <NUM_LIT:1>:<EOL><INDENT>s = q[l-<NUM_LIT:1>]<EOL>t = s*thistheta<EOL><DEDENT>if n_k[k-<NUM_LIT:1>] <= <NUM_LIT:1>:<EOL><INDENT>s_k[k-<NUM_LIT:1>] = q[l-n-<NUM_LIT:1>]<EOL>t_k[k-<NUM_LIT:1>] = s_k[k-<NUM_LIT:1>] * theta_k[k-<NUM_LIT:1>]<EOL><DEDENT>n += n_k[k-<NUM_LIT:1>]<EOL>s += s_k[k-<NUM_LIT:1>]<EOL>t += t_k[k-<NUM_LIT:1>]<EOL>s_k[k-<NUM_LIT:1>] = s<EOL>t_k[k-<NUM_LIT:1>] = t<EOL>thistheta = t/s<EOL>if k==<NUM_LIT:1>:<EOL><INDENT>break  <EOL><DEDENT>k -= <NUM_LIT:1><EOL><DEDENT><DEDENT>if l == L:  <EOL><INDENT>break  <EOL><DEDENT>l += <NUM_LIT:1><EOL>n_k[k-<NUM_LIT:1>] = n<EOL>theta_k[k-<NUM_LIT:1>] = thistheta<EOL><DEDENT>while True:<EOL><INDENT>while True:<EOL><INDENT>if n==<NUM_LIT:1>: <EOL><INDENT>break  <EOL><DEDENT>while True:<EOL><INDENT>theta[l-<NUM_LIT:1>] = thistheta<EOL>if n==<NUM_LIT:1>:<EOL><INDENT>break<EOL><DEDENT>l -= <NUM_LIT:1><EOL>n -= <NUM_LIT:1><EOL><DEDENT><DEDENT>if k==<NUM_LIT:1>:<EOL><INDENT>break<EOL><DEDENT>k -= <NUM_LIT:1><EOL>l -= <NUM_LIT:1><EOL>n = n_k[k-<NUM_LIT:1>]<EOL>thistheta = theta_k[k-<NUM_LIT:1>]<EOL><DEDENT>return theta<EOL>
Single column only.