Package specific_analyses :: Package relax_disp :: Module estimate_r2eff :: Class Exp
[hide private]
[frames] | no frames]

Class Exp

source code

Instance Methods [hide private]
 
__init__(self, verbosity=1)
Class for to set settings for minimisation and dispersion target functions for minimisation.
source code
 
setup_data(self, times=None, values=None, errors=None)
Setup for minimisation with minfx.
source code
 
set_settings_leastsq(self, ftol=1e-15, xtol=1e-15, maxfev=10000000, factor=100.0)
Setup options to scipy.optimize.leastsq.
source code
 
set_settings_minfx(self, scaling_matrix=None, min_algor='simplex', c_code=True, constraints=False, chi2_jacobian=False, func_tol=1e-25, grad_tol=None, max_iterations=10000000)
Setup options to minfx.
source code
list
estimate_x0_exp(self, times=None, values=None)
Estimate starting parameter x0 = [r2eff_est, i0_est], by converting the exponential curve to a linear problem.
source code
numpy array
func_exp(self, params=None, times=None)
Calculate the function values of exponential function.
source code
numpy array
func_exp_residual(self, params=None, times=None, values=None)
Calculate the residual vector betwen measured values and the function values.
source code
numpy array
func_exp_weighted_residual(self, params=None, times=None, values=None, errors=None)
Calculate the weighted residual vector betwen measured values and the function values.
source code
numpy array
func_exp_grad(self, params=None, times=None)
The gradient (Jacobian matrix) of func_exp for Co-variance calculation.
source code
float
func_exp_chi2(self, params=None, times=None, values=None, errors=None)
Target function for minimising chi2 in minfx, for exponential fit.
source code
numpy array
func_exp_chi2_grad(self, params=None, times=None, values=None, errors=None)
Target function for the gradient (Jacobian matrix) to minfx, for exponential fit .
source code
numpy array
func_exp_chi2_grad_array(self, params=None, times=None, values=None, errors=None)
Return the gradient (Jacobian matrix) of func_exp_chi2() for parameter co-variance error estimation.
source code
Method Details [hide private]

__init__(self, verbosity=1)
(Constructor)

source code 

Class for to set settings for minimisation and dispersion target functions for minimisation.

This class contains minimisation functions for both minfx and scipy.optimize.leastsq.

Parameters:
  • verbosity (int) - The amount of information to print. The higher the value, the greater the verbosity.

setup_data(self, times=None, values=None, errors=None)

source code 

Setup for minimisation with minfx.

Parameters:
  • times (numpy array) - The time points.
  • values (numpy array) - The measured intensity values per time point.
  • errors (numpy array) - The standard deviation of the measured intensity values per time point.

set_settings_leastsq(self, ftol=1e-15, xtol=1e-15, maxfev=10000000, factor=100.0)

source code 

Setup options to scipy.optimize.leastsq.

Parameters:
  • ftol (float) - The function tolerance for the relative error desired in the sum of squares, parsed to leastsq.
  • xtol (float) - The error tolerance for the relative error desired in the approximate solution, parsed to leastsq.
  • maxfev (int) - The maximum number of function evaluations, parsed to leastsq. If zero, then 100*(N+1) is the maximum function calls. N is the number of elements in x0=[r2eff, i0].
  • factor (float) - The initial step bound, parsed to leastsq. It determines the initial step bound (''factor * || diag * x||''). Should be in the interval (0.1, 100).

set_settings_minfx(self, scaling_matrix=None, min_algor='simplex', c_code=True, constraints=False, chi2_jacobian=False, func_tol=1e-25, grad_tol=None, max_iterations=10000000)

source code 

Setup options to minfx.

Parameters:
  • scaling_matrix (numpy rank-2 float array) - The square and diagonal scaling matrix.
  • min_algor (string) - The minimisation algorithm
  • c_code (bool) - If optimise with C code.
  • constraints (bool) - If constraints should be used.
  • chi2_jacobian (bool) - If the chi2 Jacobian should be used.
  • func_tol (None or float) - The function tolerance which, when reached, terminates optimisation. Setting this to None turns of the check.
  • grad_tol (None or float) - The gradient tolerance which, when reached, terminates optimisation. Setting this to None turns of the check.
  • max_iterations (int) - The maximum number of iterations for the algorithm.

estimate_x0_exp(self, times=None, values=None)

source code 

Estimate starting parameter x0 = [r2eff_est, i0_est], by converting the exponential curve to a linear problem. Then solving by linear least squares of: ln(Intensity[j]) = ln(i0) - time[j]* r2eff.

Parameters:
  • times (numpy array) - The time points.
  • values (numpy array) - The measured intensity values per time point.
Returns: list
The list with estimated r2eff and i0 parameter for optimisation, [r2eff_est, i0_est]

func_exp(self, params=None, times=None)

source code 

Calculate the function values of exponential function.

Parameters:
  • params (numpy rank-1 float array) - The vector of parameter values.
  • times (numpy array) - The time points.
Returns: numpy array
The function values.

func_exp_residual(self, params=None, times=None, values=None)

source code 

Calculate the residual vector betwen measured values and the function values.

Parameters:
  • params (numpy rank-1 float array) - The vector of parameter values.
  • times (numpy array) - The time points.
  • values (numpy array) - The measured values.
Returns: numpy array
The residuals.

func_exp_weighted_residual(self, params=None, times=None, values=None, errors=None)

source code 

Calculate the weighted residual vector betwen measured values and the function values.

Parameters:
  • params (numpy rank-1 float array) - The vector of parameter values.
  • times (numpy array) - The time points.
  • values (numpy array) - The measured values.
  • errors (numpy array) - The standard deviation of the measured intensity values per time point.
Returns: numpy array
The weighted residuals.

func_exp_grad(self, params=None, times=None)

source code 

The gradient (Jacobian matrix) of func_exp for Co-variance calculation.

Parameters:
  • params (numpy rank-1 float array) - The vector of parameter values.
  • times (numpy array) - The time points.
Returns: numpy array
The Jacobian matrix with 'm' rows of function derivatives per 'n' columns of parameters.

func_exp_chi2(self, params=None, times=None, values=None, errors=None)

source code 

Target function for minimising chi2 in minfx, for exponential fit.

Parameters:
  • params (numpy rank-1 float array) - The vector of parameter values.
  • times (numpy array) - The time points.
  • values (numpy array) - The measured values.
  • errors (numpy array) - The standard deviation of the measured intensity values per time point.
Returns: float
The chi2 value.

func_exp_chi2_grad(self, params=None, times=None, values=None, errors=None)

source code 

Target function for the gradient (Jacobian matrix) to minfx, for exponential fit .

Parameters:
  • params (numpy rank-1 float array) - The vector of parameter values.
  • times (numpy array) - The time points.
  • values (numpy array) - The measured values.
  • errors (numpy array) - The standard deviation of the measured intensity values per time point.
Returns: numpy array
The Jacobian matrix with 'm' rows of function derivatives per 'n' columns of parameters, which have been summed together.

func_exp_chi2_grad_array(self, params=None, times=None, values=None, errors=None)

source code 

Return the gradient (Jacobian matrix) of func_exp_chi2() for parameter co-variance error estimation. This needs return as array.

Parameters:
  • params (numpy rank-1 float array) - The vector of parameter values.
  • times (numpy array) - The time points.
  • values (numpy array) - The measured intensity values per time point.
  • errors (numpy array) - The standard deviation of the measured intensity values per time point.
Returns: numpy array
The Jacobian matrix with 'm' rows of function derivatives per 'n' columns of parameters.