[#BloombergLP-bdlsta-LineFit]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlsta.adoc[bdlsta]::LineFit
:relfileprefix: ../../
:mrdocs:

Online calculator for least&hyphen;squares line fit&period;

== Synopsis

Declared in `&lt;bdlsta&lowbar;linefit&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class LineFit;
----

== Description

This class provides an efficient online algorithm for calculating linear square line fit&period; The class also calculates the mean for the X&apos;s and Y&apos;s, and variance for the X&apos;s&period; These are byproducts of calculating the line fit&period; The online algorithm is detailed in the implementation notes&period;

== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlsta/LineFit/_04enum.adoc[`Unnamed enum`] 
| Status codes returned by statistical computations&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlsta/LineFit/2constructor.adoc[`LineFit`]         [.small]#[constructor]#
| Create an empty `LineFit` object&period;
| xref:BloombergLP/bdlsta/LineFit/add.adoc[`add`] 
| Add the specified `(xValue, yValue)` point to the data set&period;
| xref:BloombergLP/bdlsta/LineFit/count.adoc[`count`] 
| Returns the number of elements in the data set&period;
| xref:BloombergLP/bdlsta/LineFit/fit.adoc[`fit`] 
| Calculate the least&hyphen;squares line fit coefficients&period;
| xref:BloombergLP/bdlsta/LineFit/fitIfValid.adoc[`fitIfValid`] 
| Calculate line fit coefficients when data is sufficient&period;
| xref:BloombergLP/bdlsta/LineFit/variance.adoc[`variance`] 
| Return the variance of the data set X&apos;s&period; The behavior is undefined unless `2 &lt;&equals; count`&period;
| xref:BloombergLP/bdlsta/LineFit/varianceIfValid.adoc[`varianceIfValid`] 
| Load variance of the X values into `result` when data is sufficient&period;
| xref:BloombergLP/bdlsta/LineFit/xMean.adoc[`xMean`] 
| Return the mean of the data set X&apos;s&period; The behavior is undefined unless `1 &lt;&equals; count`&period;
| xref:BloombergLP/bdlsta/LineFit/xMeanIfValid.adoc[`xMeanIfValid`] 
| Load the mean of the X values into `result` when data is sufficient&period;
| xref:BloombergLP/bdlsta/LineFit/yMean.adoc[`yMean`] 
| Return the mean of the data set Y&apos;s&period; The behavior is undefined unless `1 &lt;&equals; count`&period;
| xref:BloombergLP/bdlsta/LineFit/yMeanIfValid.adoc[`yMeanIfValid`] 
| Load the mean of the Y values into `result` when data is sufficient&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
