Optimization module

Optimization module for PCM toolbox with main functionality for model fitting. @author: jdiedrichsen

optimize.best_algorithm(M, algorithm=None)
Parameters:
  • M (List of pcm.Model) –

  • algorithm (string) – Overwrite for algorithm

optimize.mcmc(th0, likelihood_fcn, proposal_sd=0.1, burn_in=100, n_samples=1000, verbose=1)

Implement Markov Chain Monte Carlo sampling for PCM models Metropolis-Hastings algorithm with adaptive proposal distribution

optimize.newton(theta0, lossfcn, max_iter=80, thres=0.0001, hess_reg=0.0001, regularization='sEig', verbose=0, fit_param=None)

Minimize a loss function using Newton-Raphson with automatic regularization

Parameters:
  • theta (np.array) – Vector of parameter starting values

  • lossfcn (fcn) – Handle to loss function that needs to return a) Loss (Negative log-likelihood) b) First derivative of the Loss c) Expected second derivative of the loss

  • max_iter (int) – Maximal number of iterations (default: 80)

  • thres (float) – Threshold for change in Loss function (default: 1e-4)

  • hess_reg (float) – starting regulariser on the Hessian matrix (default 1e-4)

  • regularization (string) – ‘L’: Levenberg ‘LM’: Levenberg-Marquardt ‘sEig’:smallest Eigenvalue (default)

  • verbose (int) – 0: No feedback, 1:Important warnings 2:full feedback regularisation

  • fit_param (Logical) – If provided, it will only fit the parameters indicated

Returns:
  • theta (np.array) – theta at minimum

  • loss (float) – minimal loss

  • info (dict) – Dictionary with more information abuot the fit