PHP Class MathPHP\Statistics\Regression\LinearThroughPoint

A model with a single explanatory variable. Fits a straight line through the set of n points in such a way that makes the sum of squared residuals of the model (that is, vertical distances between the points of the data set and the fitted line) as small as possible. https://en.wikipedia.org/wiki/Simple_linear_regression Having data points {(xᵢ, yᵢ), i = 1 ..., n } Find the equation y = mx + b such that the line passes through the point (v,w) ∑((x-v)(y-w)) m = _____________ ∑(x-v)² b = w - m * v
Inheritance: extends ParametricRegression, use trait MathPHP\Statistics\Regression\Methods\LeastSquares, use trait MathPHP\Statistics\Regression\Models\LinearModel
Show file Open project: markrogoyski/math-php

Public Methods

Method Description
__construct ( array $points, array $force = [0, 0] ) Given a set of data ($points) and a point($force), perform a least squares regression of the data, such that the regression is forced to pass through the specified point.
calculate ( ) Calculates the regression parameters.

Method Details

__construct() public method

This procedure is most frequently used with $force = [0,0], the origin.
public __construct ( array $points, array $force = [0, 0] )
$points array
$force array Point to force regression line through (default: origin)

calculate() public method

Calculates the regression parameters.
public calculate ( )