quri_parts.algo.utils.fitting module#

class quri_parts.algo.utils.fitting.FittedResult(parameters: list[float], value: float)#

Bases: object

An immutable (frozen) dataclass representing a fitted result.

parameters: list[float]#

Coefficients of the fitting function, obtained by fitting.

value: float#

The value at a certain point obtained by using a fitted function.

quri_parts.algo.utils.fitting.polynomial_fitting(x_data: Iterable[float], y_data: Iterable[float], order: int, point: float) FittedResult#

Polynomial fitting with an polynomial of a given order.

Parameters:
  • x_data – x-coordinates for fitting.

  • y_data – y-coordinates for fitting.

  • order – Order of the polynomial used for fitting.

  • point – A point at which the fitted function to be evaluated.

Returns:

The fitted parameters (can be accessed with parameters) and a value at the input point of the fitted function (can be accessed with value).

quri_parts.algo.utils.fitting.exp_fitting(x_data: Iterable[float], y_data: Iterable[float], order: int, point: float) FittedResult#

Curve fitting with an exponential ansatz f(x) = a + b exp(p(x)), where p(x) is a polynomial of a given order.

Parameters:
  • x_data – x-coordinates for fitting.

  • y_data – y-coordinates for fitting.

  • order – Order of the polynomial on the exponential used for fitting.

  • point – A point at which the fitted function to be evaluated.

Returns:

The fitted parameters (can be accessed with parameters) and a value at the input point of the fitted function (can be accessed with value).

quri_parts.algo.utils.fitting.exp_fitting_with_const(x_data: Iterable[float], y_data: Iterable[float], order: int, constant: float, point: float) FittedResult#

Curve fitting with an exponential ansatz f(x) = constant + b exp(p(x)), where p(x) is a polynomial of a given order and constant is a known parameter (obtained as the infinite limit f(x->inf) when f(x) converges to a finite asymptotic value).

Parameters:
  • x_data – x-coordinates for fitting.

  • y_data – y-coordinates for fitting.

  • order – Order of the polynomial on the exponential used for fitting.

  • constant – A constant deduced from asymptotic behavior f(x->inf).

  • point – A point at which the fitted function to be evaluated.

Returns:

The fitted parameters (can be accessed with parameters) and a value at the input point of the fitted function (can be accessed with value).

quri_parts.algo.utils.fitting.exp_fitting_with_const_log(x_data: Iterable[float], y_data: Iterable[float], order: int, constant: float, point: float) FittedResult#

Log fitting with an exponential ansatz f(x) = constant + b exp(p(x)), where p(x) is a polynomial of a given order and constant is a known parameter (obtained as the infinite limit f(x->inf) when f(x) converges to a finite asymptotic value).

Parameters:
  • x_data – x-coordinates for fitting.

  • y_data – y-coordinates for fitting.

  • order – Order of the polynomial on the exponential used for fitting.

  • constant – A constant deduced from asymptotic behavior f(x->inf).

  • point – A point at which the fitted function to be evaluated.

Returns:

The fitted parameters (can be accessed with parameters) and a value at the input point of the fitted function (can be accessed with value).