fit

Module Contents

Classes

Functions

class _Device(fitFunction, nbArgs)[source]
class _Objective(x_data, y_data, fitCriterion)[source]

Bases: optimeed.optimize.InterfaceObjCons

Interface class for objectives and constraints. The objective is to MINIMIZE and the constraint has to respect VALUE <= 0

compute(theDevice)[source]

Get the value of the objective or the constraint. The objective is to MINIMIZE and the constraint has to respect VALUE <= 0

Parameters:theDevice – Input device that has already been evaluated
Returns:float.
leastSquare(function, functionArgs, x_data, y_data)[source]

Least square calculation (sum (y-ŷ)^2)

Parameters:
  • function – Function to fit
  • functionArgs – Arguments of the function
  • x_data – x-axis coordinates of data to fit
  • y_data – y-axis coordinates of data to fit
Returns:

least squares

r_squared(function, functionArgs, x_data, y_data)[source]

R squared calculation

Parameters:
  • function – Function to fit
  • functionArgs – Arguments of the function
  • x_data – x-axis coordinates of data to fit
  • y_data – y-axis coordinates of data to fit
Returns:

R squared

do_fit(fitFunction, x_data, y_data, *args, fitCriterion=leastSquare)[source]

Main method to fit a function

Parameters:
  • fitFunction – the function to fit (link to it)
  • x_data – x-axis coordinates of data to fit
  • y_data – y-axis coordinates of data to fit
  • args – for each parameter: [min, max] admissible value
  • fitCriterion – fit criterion to minimize. Default: least square
Returns:

[arg_i_optimal, …], y estimated, error.