epraya.Nelder#

Nelder(Hamer, Expe, Vara, exper, eps=1e-10, maximal=5000, datype='data', mode='p')#

Implementation of the Nelder Mead algorithm for fitting data, based on the code by Hadrien Crassous. Uses the 4 classic possibilities reflection, expansion, contraction and shrink with their respective constants, alpha, gamma, rho and sigma, defined depending in the number of parameters to vary (nparams). With that, their definitions are:

alpha=1

gamma=1+(2/nparams)

rho=0.75-(1/(2*nparams))

sigma=1-(1/nparams)

The algorithm also has a restart function, if the points converge to a local minimun and a heat up function, changing one of the parameters in order to vary the cost.

Parameters:
  • Hamer (Class) – Container for the hamiltonian parameters.

  • Expe (Class) – Container for the experimental conditions.

  • Vara (Class) – Container for the range and parameters to vary.

  • exper (np.array) – Experimental spectrum data to fit.

  • eps (float) – Tolerance value for the error. Default is 1e-10

  • maximal (int) – Max. number of iterations to evalue the function.

  • datype (str) – Type of data to do the fitting, can be ‘data’, the data as it’s or ‘integral’, its first integral.

  • mode (str) – Defines the sample type, ‘p’ for powder and ‘c’ for monocristal.

Returns:

spce (np.array) – Best adjusted spectrum.