Latest | 1.0.3 |
---|---|

Homepage | https://github.com/wltrup/Swift-WTOnlineLinearRegression |

License | MIT |

Platforms | ios 8.0 |

Authors |

## What

**WTOnlineLinearRegression** allows you to perform *linear* regression on one-dimensional

data, with or without uncertainties in the dependent quantity, and it does so by updating

its internal state in constant time on the number of data points, for each new data point,

resulting in an overall linear time complexity.

In other words, it performs **online** regression, updating its internal state without

recomputing everything from scratch on every addition, which would use the entire data

set every time a new data point is added, hence incurring on an overall quadratic runtime.

You can also *remove* data points that have been previously added to the data set.

Removing, however, runs in linear time on the size of the data set, per removal, since

it must scan the data set to guarantee that the data point being removed was once added.

Additionally, **WTOnlineLinearRegression** optionally keeps a history of every data point

addition or removal, as full snapshots of the regression at the time each data point was

added or removed.

## Usage

An `Observation`

instance represents a pair of values `(x,y)`

where the dependent value,

`y`

, may also have some uncertainty associated with it, in the form of its *variance* (or,

equivalently, its *standard deviation*).

Given a series of `N`

such observations, `{(xi, yi, dyi), 1 ≤ i ≤ N}`

, one might be

interested in finding the straight line `y = a * x + b`

that best fits those observations.

That’s the task of the `LinearRegression`

object and since it’s possible that the `y`

values in the actual observations could be uncertain, the estimated slope `a`

and the

estimated intercept `b`

will, themselves, have some uncertainty.

In other words, the best line that fits the series of observations will have an equation

of the form `y = (a ± da) * x + (b ± db)`

, where I’m using `d•`

to refer to the standard

deviation of the quantity in front of it.

`LinearRegression`

performs the regression and computes the *slope* `a ± da`

, the

*Y-intercept* `b ± db`

, three measures of error (*mean total squared error*, *mean squared
residual error*, and

*mean squared regression error*), and the coefficient of fitness

known as

*r-squared*. You may also inspect various sums that are used to compute those

quantities.

You may also optionally request `LinearRegression`

to record the history of changes, as

data points are added or removed from the data set. Each entry in the history is a full

snapshot of the regression at the time the entry was processed.

## Documentation

Full documentation is provided in the source files. Additionally, the main mathematical

results used to implement `WTOnlineLinearRegression`

are available in a pdf document

here.

## Demo app

Check out the demo app.

## Tests

**WTOnlineLinearRegression** is verified by **134 tests**, with **100% coverage**.

## Changelog

Changes to **WTOnlineLinearRegression** are listed

here.

## Installation

**WTOnlineLinearRegression** is available through CocoaPods. To

install it, simply add the following line to your Podfile:

`ruby pod "WTOnlineLinearRegression"`

## Author

Wagner Truppel, [email protected]

## License

**WTOnlineLinearRegression** is available under the MIT license. See the LICENSE file for

more info.

### Latest podspec

{ "name": "WTOnlineLinearRegression", "version": "1.0.3", "summary": "WTOnlineLinearRegression efficiently performs linear regression on one-dimensional data, with or without variance in the dependent quantity.", "description": "WTOnlineLinearRegression efficiently performs linear regression on one-dimensional data, with or without variance in the dependent quantity. It supports adding and removing data points, as well as a history feature.", "homepage": "https://github.com/wltrup/Swift-WTOnlineLinearRegression", "license": { "type": "MIT", "file": "LICENSE" }, "authors": { "Wagner Truppel": "[email protected]" }, "source": { "git": "https://github.com/wltrup/Swift-WTOnlineLinearRegression.git", "tag": "1.0.3" }, "platforms": { "ios": "8.0" }, "source_files": "WTOnlineLinearRegression/Classes/**/*", "pushed_with_swift_version": "3.0" }

Thu, 16 Feb 2017 22:00:04 +0000