quri_parts.algo.utils.fitting module#

class FittedResult(parameters, value)#

Bases: object

An immutable (frozen) dataclass representing a fitted result.

Parameters:
  • parameters (list[float]) –

  • value (float) –

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.

polynomial_fitting(x_data, y_data, order, point)#

Polynomial fitting with an polynomial of a given order.

Parameters:
  • x_data (Iterable[float]) – x-coordinates for fitting.

  • y_data (Iterable[float]) – y-coordinates for fitting.

  • order (int) – Order of the polynomial used for fitting.

  • point (float) – 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).

Return type:

FittedResult

exp_fitting(x_data, y_data, order, point)#

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 (Iterable[float]) – x-coordinates for fitting.

  • y_data (Iterable[float]) – y-coordinates for fitting.

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

  • point (float) – 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).

Return type:

FittedResult

exp_fitting_with_const(x_data, y_data, order, constant, point)#

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 (Iterable[float]) – x-coordinates for fitting.

  • y_data (Iterable[float]) – y-coordinates for fitting.

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

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

  • point (float) – 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).

Return type:

FittedResult

exp_fitting_with_const_log(x_data, y_data, order, constant, point)#

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 (Iterable[float]) – x-coordinates for fitting.

  • y_data (Iterable[float]) – y-coordinates for fitting.

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

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

  • point (float) – 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).

Return type:

FittedResult