[#BloombergLP-bdlsta-LineFit] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlsta.adoc[bdlsta]::LineFit :relfileprefix: ../../ :mrdocs: This class provides an efficient online algorithm for calculating linear square line fit. The class also calculates the mean for the X's and Y's, and variance for the X's. These are byproducts of calculating the line fit. The online algorithm is detailed in the implementation notes. == Synopsis Declared in `<bdlsta_linefit.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class LineFit; ---- == Enums [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlsta/LineFit/_04enum.adoc[`Unnamed enum`] | Status codes returned by statistical computations. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlsta/LineFit/2constructor.adoc[`LineFit`] [.small]#[constructor]# | Create an empty `LineFit` object. | xref:BloombergLP/bdlsta/LineFit/add.adoc[`add`] | Add the specified `(xValue, yValue)` point to the data set. | xref:BloombergLP/bdlsta/LineFit/count.adoc[`count`] | Returns the number of elements in the data set. | xref:BloombergLP/bdlsta/LineFit/fit.adoc[`fit`] | Calculate line fit coefficients `Y = Alpha + Beta * X`, and populate the specified `alpha` (intercept) and `beta` (slope). The behavior is undefined if `2 > count` or all X's are identical. | xref:BloombergLP/bdlsta/LineFit/fitIfValid.adoc[`fitIfValid`] | Calculate line fit coefficients `Y = Alpha + Beta * X`, and populate the specified `alpha` (intercept) and `beta` (slope). Return 0 on success, and non‐zero otherwise. The computations is unsuccessful if `2 > count` or all X's are identical. | xref:BloombergLP/bdlsta/LineFit/variance.adoc[`variance`] | Return the variance of the data set X's. The behavior is undefined unless `2 <= count`. | xref:BloombergLP/bdlsta/LineFit/varianceIfValid.adoc[`varianceIfValid`] | Load into the specified `result`, the variance of the data set X's. Return 0 on success, and a non‐zero value otherwise. Specifically, `e_INADEQUATE_DATA` is returned if `2 > count`. | xref:BloombergLP/bdlsta/LineFit/xMean.adoc[`xMean`] | Return the mean of the data set X's. The behavior is undefined unless `1 <= count`. | xref:BloombergLP/bdlsta/LineFit/xMeanIfValid.adoc[`xMeanIfValid`] | Load into the specified `result`, the mean of the data set X's. Return 0 on success, and a non‐zero value otherwise. Specifically, `e_INADEQUATE_DATA` is returned if `1 > count`. | xref:BloombergLP/bdlsta/LineFit/yMean.adoc[`yMean`] | Return the mean of the data set Y's. The behavior is undefined unless `1 <= count`. | xref:BloombergLP/bdlsta/LineFit/yMeanIfValid.adoc[`yMeanIfValid`] | Load into the specified `result`, the mean of the data set Y's. Return 0 on success, and a non‐zero value otherwise. Specifically, `e_INADEQUATE_DATA` is returned if `1 > count`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#