funfit module
get y = f(x) based on pair of two points using given function shape.
This is the internal module to help point values calculation.
- lin_fit(x, xy_0: tuple, xy_1: tuple)
Get value of point using linear function
Get \(y = f(x)\) using linear function of form \(y = ax\) on range \((x_0, x_1)\)
- Parameters:
x (scalar) – Point for which return value of y
xy_0 (tuple of two floats) – Starting point (x0, y0)
xy_1 (tuple of two floats) – Ending point (x1, y1)
- Returns:
Value of y at point x.
- Return type:
float
Examples
>>> xy_0 = (10, 10) >>> xy_1 = (20, 30) >>> x = 11 >>> lin_fit(x, xy_0, xy_1) 12.0
- exp_fit(x, xy_0: tuple, xy_1: tuple, alpha: float = 2.0)
Get value of point using exponential function
Get \(y = f(x)\) using exp function of form \(y = ax^\alpha\) on range \((0, 1)\) scaled to \((x_0, x_1)\)
- Parameters:
x (float) – Point for which return value of y
xy_0 (tuple of two floats) – Starting point (x0, y0)
xy_1 (tuple of two floats) – Ending point (x1, y1)
alpha (float, optional) – Exponent factor. Default is 2.
- Returns:
Value of y at point x.
- Return type:
float
Examples
>>> xy_0 = (10, 10) >>> xy_1 = (20, 30) >>> x = 11 >>> exp_fit(x, xy_0, xy_1, alpha=2.0) 10.2
- exp_xy_fit(x, xy_0: tuple, xy_1: tuple, alpha: float = 2.0)
Get value of point using exponential function mirrored over y=x
Get \(y = f(x)\) using exp function mirrored over \(x = y\) line of form \(y = a (1 - (1-x)^\alpha)\) on range \((0, 1)\) scaled to \((x_0, x_1)\)
- Parameters:
x (float) – Point for which return value of y
xy_0 (tuple of two floats) – Starting point (x0, y0)
xy_1 (tuple of two floats) – Ending point (x1, y1)
alpha (float, optional) – Exponent factor. Default is 2.
- Returns:
Value of y at point x.
- Return type:
float
Examples
>>> xy_0 = (10, 10) >>> xy_1 = (20, 30) >>> x = 19 >>> exp_xy_fit(x, xy_0, xy_1, alpha=2.0) 29.8
- exp_lin_fit(x, xy_0: tuple, xy_1: tuple, alpha=2)
Get value of point using combination of linear and exponential function
Get \(y = f(x)\) using linear and exp function line of form \(y = a ((1- b) \cdot x + b \cdot x^\alpha)\) on range \((0, 1)\) scaled to \((x_0, x_1)\) where \(b = (x - x_0)\)
It is a linear combination of values returned be
exp_fit()
andlin_fit()
.- Parameters:
x (float) – Point for which return value of y
xy_0 (tuple of two floats) – Starting point (x0, y0)
xy_1 (tuple of two floats) – Ending point (x1, y1)
alpha (float, optional) – Exponent factor. Default is 2.
- Returns:
Value of y at point x.
- Return type:
float
Examples
>>> xy_0 = (10, 10) >>> xy_1 = (20, 30) >>> x = 19 >>> exp_lin_fit(x, xy_0, xy_1, alpha=2.0) 27.82
- lin_exp_xy_fit(x, xy_0: tuple, xy_1: tuple, alpha=2)
Get value of point using combination of linear and exponential function mirrored over xy line
Get \(y = f(x)\) using linear and exp function line mirrored over xy of form \(y = a (x + 1 - (1-x)^\alpha)\) on range \((0, 1)\) scaled to \((x_0, x_1)\)
It is a linear combination of values returned be
lin_fit()
andexp_xy_fit()
.- Parameters:
x (float) – Point for which return value of y
xy_0 (tuple of two floats) – Starting point (x0, y0)
xy_1 (tuple of two floats) – Ending point (x1, y1)
alpha (float, optional) – Exponent factor. Default is 2.
- Returns:
Value of y at point x.
- Return type:
float
Examples
>>> xy_0 = (10, 10) >>> xy_1 = (20, 30) >>> x = 19 >>> exp_xy_fit(x, xy_0, xy_1, alpha=2.0) 29.8