https://github.com/paescebu/polynomialregressionswift
Swift function for calculation of the polynomial regression (least squares fitting) of a given set of points.
https://github.com/paescebu/polynomialregressionswift
ios ipados iphone macosx math polynomial polynomial-regression polynomials swift swift4 swift5
Last synced: 5 months ago
JSON representation
Swift function for calculation of the polynomial regression (least squares fitting) of a given set of points.
- Host: GitHub
- URL: https://github.com/paescebu/polynomialregressionswift
- Owner: paescebu
- License: mit
- Fork: true (KingIsulgard/iOS-Polynomial-Regression)
- Created: 2021-03-14T14:26:51.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-10T19:29:06.000Z (9 months ago)
- Last Synced: 2024-09-29T22:01:39.189Z (9 months ago)
- Topics: ios, ipados, iphone, macosx, math, polynomial, polynomial-regression, polynomials, swift, swift4, swift5
- Language: Swift
- Homepage:
- Size: 271 KB
- Stars: 7
- Watchers: 0
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PolynomialRegressionSwift
Swift function for calculation of the polynomial regression of a given set of points in a 2D coordinate system.You have to give an array of CGPoint and the desired degree of polynomial you would like to aquire. The function will return an Array containing the polynomial coefficients.
## Overview
* [Features](#features)
* [Example](#example)
* [Implementation](#implementation)
* [Warranty](#warranty)## Features
- **Uses Apple's Accelerate framework on Matrix operations and solving of linear systems for increased performance**
- Can calculate any degree of polynomial
- Easy to use
- Also contains a custom matrix class which allows to transpose a matrix or multiply two matrices
- runs on iOS and macOS## Example
let points:[CGPoint] = [
CGPoint(x: 0, y: 1),
CGPoint(x: 9, y: -7),
CGPoint(x: 13, y: 6),
CGPoint(x: 15, y: 12),
CGPoint(x: 19, y: -4),
CGPoint(x: 20, y: -12),
CGPoint(x: 26, y: -2),
CGPoint(x: 26, y: 13),
CGPoint(x: 29, y: 23),
CGPoint(x: 30, y: 30),
]let regression = PolynomialRegression.regression(withPoints: points, degree: 6)
print("The result is the sum of")
for i in 0..