pricing.TrendFit
A trend fitted by least squares to values at times in years:
Usage
pricing.TrendFit()log(y) on time for an exponential trend, y for a linear one. For quarterly points, pass times a quarter apart.
Build one with TrendFit.exponential or TrendFit.linear.
Examples
>>> from prospicio.pricing import TrendFit
>>> t = [0.0, 0.25, 0.5, 0.75]
>>> fit = TrendFit.exponential(t, [100 * 1.03 ** x for x in t])
>>> round(fit.annual_change, 6)0.03
Attributes
| Name | Description |
|---|---|
| annual_change |
The annual trend: exp(slope) - 1 for an exponential fit, the
|
| intercept | The intercept, on the log scale for an exponential fit. |
| kind |
"exponential" or "linear".
|
| n | The number of points. |
| r_squared | The coefficient of determination, on the fitted scale. |
| slope | The slope per year, on the log scale for an exponential fit. |
annual_change
The annual trend: exp(slope) - 1 for an exponential fit, the
annual_change: float
slope (an amount a year) for a linear one.
intercept
The intercept, on the log scale for an exponential fit.
intercept: float
kind
"exponential" or "linear".
kind: str
n
The number of points.
n: int
r_squared
The coefficient of determination, on the fitted scale.
r_squared: float
slope
The slope per year, on the log scale for an exponential fit.
slope: float
Methods
| Name | Description |
|---|---|
| exponential() |
Fit log(y) = a + b t; every value must be positive.
|
| fitted() |
The fitted value at time.
|
| linear() |
Fit y = a + b t.
|
exponential()
Fit log(y) = a + b t; every value must be positive.
Usage
exponential(times, values)Parameters
times: list of floatvalues: list of float
Returns
TrendFit
fitted()
The fitted value at time.
Usage
fitted(time)Parameters
time: float
Returns
float
linear()
Fit y = a + b t.
Usage
linear(times, values)Parameters
times: list of floatvalues: list of float
Returns
TrendFit