Function Repository Resource:

# OrthogonalLineFit

Find the best fitting line with respect to orthogonal distance

Contributed by: Jan Mangaldan
 ResourceFunction["OrthogonalLineFit"][data] finds the best fitting orthogonal distance regression line to data.

## Details

Orthogonal distance regression is also known as orthogonal least squares or total least squares.
The orthogonal distance regression line is the line for which its orthogonal distance from the given data is minimized.
ResourceFunction["OrthogonalLineFit"] returns an InfiniteLine object.

## Examples

### Basic Examples (2)

Parameters for a 2D line:

 In[1]:=
 Out[1]=

Generate some points near the line:

 In[2]:=
 Out[2]=

Find the orthogonal distance regression line:

 In[3]:=
 Out[3]=

Compare the regression line and the true line with the data:

 In[4]:=
 Out[4]=

Parameters for a 3D line:

 In[5]:=
 Out[5]=

Generate some points near the line:

 In[6]:=
 Out[6]=

Find the orthogonal distance regression line:

 In[7]:=
 Out[7]=

Compare the regression line and the true line with the data:

 In[8]:=
 Out[8]=

### Scope (2)

Here is a list of values:

 In[9]:=

When coordinates are not given, OrthogonalLineFit assumes the values are to be paired up with 1,2,:

 In[10]:=
 Out[10]=
 In[11]:=
 Out[11]=

### Properties and Relations (6)

Here is some data:

 In[12]:=

This computes the parameters for the orthogonal distance regression line using the definition:

 In[13]:=
 Out[13]=

Use OrthogonalLineFit to get the best-fit line:

 In[14]:=
 Out[14]=

Use RegionMember to compare the equations for the best fit line generated by both methods:

 In[15]:=
 Out[15]=

Construct a function from the orthogonal fit:

 In[16]:=
 Out[16]=

Compare the orthogonal fit with the conventional least-squares fit:

 In[17]:=
 Out[17]=
 In[18]:=
 Out[18]=

## Version History

• 1.0.0 – 01 February 2021