Univariable Module

Univariable handles two dimensional x,y data.

Functions and values

Function or value Description

cooksDistance xData yData

Full Usage: cooksDistance xData yData

Parameters:
    xData : Vector<float> - vector of x values
    yData : Vector<float> - vector of y values

Returns: vector Collection of cooks distances for every input coordinate.

Fits a model f(x) = b + m * x) to the data and returns the cooks distance for every data pair present in the input collections as an estimator for the influence of each data point in coefficient estimation.

xData : Vector<float>

vector of x values

yData : Vector<float>

vector of y values

Returns: vector

Collection of cooks distances for every input coordinate.

Example

 
   // e.g. days since a certain event
   let xData = vector [|1.;2.;3.;4.;5.;6.|]
   // e.g. some measured feature 
   let yData = vector [|4.;7.;9.;10.;11.;15.|]
   
   let distances = 
       Univariable.cooksDistance xData yData

fit xData yData

Full Usage: fit xData yData

Parameters:
    xData : Vector<float> - vector of x values
    yData : Vector<float> - vector of y values

Returns: Coefficients vector of [intercept; slope]

Calculates the intercept and slope for a straight line fitting the data. Linear regression minimizes the sum of squared residuals.

xData : Vector<float>

vector of x values

yData : Vector<float>

vector of y values

Returns: Coefficients

vector of [intercept; slope]

Example

 
   // e.g. days since a certain event
   let xData = vector [|1.;2.;3.;4.;5.;6.|]
   // e.g. some measured feature 
   let yData = vector [|4.;7.;9.;10.;11.;15.|]
   
   // Estimate the coefficients of a straight line fitting the given data
   let coefficients = 
       Univariable.fit xData yData

fitCholesky xData yData

Full Usage: fitCholesky xData yData

Parameters:
    xData : Vector<float> - vector of x values
    yData : Vector<float> - vector of y values

Returns: Coefficients vector of [intercept; slope]

Calculates the intercept and slope for a straight line fitting the data using Cholesky Decomposition. Linear regression minimizes the sum of squared residuals.

xData : Vector<float>

vector of x values

yData : Vector<float>

vector of y values

Returns: Coefficients

vector of [intercept; slope]

Example

 
   // e.g. days since a certain event
   let xData = vector [|1.;2.;3.;4.;5.;6.|]
   // e.g. some measured feature 
   let yData = vector [|4.;7.;9.;10.;11.;15.|]
   
   // Estimate the coefficients of a straight line fitting the given data
   let coefficients = 
       Univariable.fitCholesky xData yData

fitConstrained xData yData (arg3, arg4)

Full Usage: fitConstrained xData yData (arg3, arg4)

Parameters:
    xData : Vector<float> - vector of x values
    yData : Vector<float> - vector of y values
    arg2 : float
    arg3 : float

Returns: Coefficients vector of [intercept; slope]

Calculates the intercept and slope for a straight line fitting the data and passing through a specified point (xC,yC) . Linear regression minimizes the sum of squared residuals.

xData : Vector<float>

vector of x values

yData : Vector<float>

vector of y values

arg2 : float
arg3 : float
Returns: Coefficients

vector of [intercept; slope]

Example

 
   // e.g. days since a certain event
   let xData = vector [|1.;2.;3.;4.;5.;6.|]
   // e.g. some measured feature 
   let yData = vector [|4.;7.;9.;10.;11.;15.|]
   
   // Estimate the coefficients of a straight line fitting the given data
   let coefficients = 
       Univariable.fitConstrained xData yData (6.,15.)

predict coef x

Full Usage: predict coef x

Parameters:
    coef : Coefficients - vector of [intercept;slope] (e.g. determined by Univariable.coefficient)
    x : float - x value of which the corresponding y value should be predicted

Returns: float predicted y value with given coefficients at X=x

Takes intercept and slope of simple linear regression to predict the corresponding y value.

coef : Coefficients

vector of [intercept;slope] (e.g. determined by Univariable.coefficient)

x : float

x value of which the corresponding y value should be predicted

Returns: float

predicted y value with given coefficients at X=x

Example

 
   // e.g. days since a certain event
   let xData = vector [|1.;2.;3.;4.;5.;6.|]
   // e.g. some measured feature 
   let yData = vector [|4.;7.;9.;10.;11.;15.|]
   
   // Estimate the coefficients of a straight line fitting the given data
   let coefficients = 
       Univariable.fit xData yData 
   
   // Predict the feature at midnight between day 1 and 2. 
   Univariable.predict coefficients 1.5