## pricing.TrendFit


A trend fitted by least squares to values at times in years:


Usage

``` python
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](pricing.TrendFit.md#prospicio.pricing.TrendFit.exponential) or [TrendFit.linear](pricing.TrendFit.md#prospicio.pricing.TrendFit.linear).


## Examples

``` python
>>> 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](#annual_change) | The annual trend: `exp(slope) - 1` for an exponential fit, the |
| [intercept](#intercept) | The intercept, on the log scale for an exponential fit. |
| [kind](#kind) | `"exponential"` or `"linear"`. |
| [n](#n) | The number of points. |
| [r_squared](#r_squared) | The coefficient of determination, on the fitted scale. |
| [slope](#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()](#exponential) | Fit `log(y) = a + b t`; every value must be positive. |
| [fitted()](#fitted) | The fitted value at `time`. |
| [linear()](#linear) | Fit `y = a + b t`. |

------------------------------------------------------------------------


#### exponential()


Fit `log(y) = a + b t`; every value must be positive.


Usage

``` python
exponential(times, values)
```


##### Parameters


`times: list of float`  

`values: list of float`  


##### Returns


`TrendFit`  


------------------------------------------------------------------------


#### fitted()


The fitted value at `time`.


Usage

``` python
fitted(time)
```


##### Parameters


`time: float`  


##### Returns


`float`  


------------------------------------------------------------------------


#### linear()


Fit `y = a + b t`.


Usage

``` python
linear(times, values)
```


##### Parameters


`times: list of float`  

`values: list of float`  


##### Returns


`TrendFit`
