Unfit  3.1.1
Data fitting and optimization software
Public Member Functions | Private Attributes | List of all members
Unfit::Examples::ODE3DVariant Class Reference

Fit a three parameter first order ordinary differential equation (ODE) More...

#include <ODE3DVariant.hpp>

Inheritance diagram for Unfit::Examples::ODE3DVariant:
Unfit::GenericCostFunction

Public Member Functions

 ODE3DVariant (const std::vector< double > &x, double dt)
 
std::vector< double > operator() (const std::vector< double > &param)
 
- Public Member Functions inherited from Unfit::GenericCostFunction
virtual ~GenericCostFunction ()
 

Private Attributes

const std::vector< double > x_
 
const double dt_
 

Detailed Description

Fit a three parameter first order ordinary differential equation (ODE)

This is an example data fitting problem with two parameters for a single first order ordinary differential equation (ODE). Here the goal is to fit the following ODE to some experimental data:

dx/dt = Ax + B

This is an initial value problem, and the third parameter here is the value of that initial condition. The goal is to find the values of A & B, and the initial condition x(0), that best fit the data. In terms of the model, A = param[0], B = param[1], and x(0) = param[2].

Constructor & Destructor Documentation

◆ ODE3DVariant()

Unfit::Examples::ODE3DVariant::ODE3DVariant ( const std::vector< double > &  x,
double  dt 
)
inline

Create the cost function. Here the experimental data must be passed in, and cannot be changed (if you want to, just create another cost function object). Here the experimental data is a vector, and we also require the time step between observations.

Intended use : ODE3DVariant cost_func(x, dt);

Parameters
xA vector of experimental data
dtThe time step between observations

Member Function Documentation

◆ operator()()

std::vector<double> Unfit::Examples::ODE3DVariant::operator() ( const std::vector< double > &  param)
inlinevirtual

Calculate the linear distance (residuals) between our model and the data. This method encapsulates the model, and expects the current estimates of the unknown parameters as an input. See the class documentation for details about the model.

Intended use : residuals = cost_func(param)

Parameters
paramA vector containing the current estimates of the parameters we are trying to fit
Returns
A vector containing the residuals

Implements Unfit::GenericCostFunction.

Member Data Documentation

◆ dt_

const double Unfit::Examples::ODE3DVariant::dt_
private

The time step between observations

◆ x_

const std::vector<double> Unfit::Examples::ODE3DVariant::x_
private

A vector to store the experimental data x


The documentation for this class was generated from the following file: