You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//Loading values of the csv file and generating a dense matrix//Please modify the file path to point it in your local discletrows= File.ReadAllLines("C:\\mpg.csv")|> Array.map (fun t -> t.Split(',')|> Array.map (fun t -> float t);letmpgData= DenseMatrix.ofRowArrays rows
Finding transpose of a matrix
Finding the inverse of a matrix
Trace of a matrix
QR decomposition of a matrix
SVD of a matrix
Linear Regression Method of Least Square
letx=[14;16;27;42;39;50;83]lety=[02;05;07;09;10;13;20]letdiff= List.zip x y
letxy= diff |> List.map (fun it -> float (fst it)* float (snd it))|> List.sum
letx_= x |> List.map (fun z -> float z)|> List.average
lety_= y |> List.map (fun z -> float z)|> List.average
letsx_2= x |> List.sumBy (fun t -> float t * float t)letsy_2= y |> List.sumBy (fun t -> float t * float t)letn= float x.Length
letb1=(xy - n*x_*y_)/(sx_2 - n * x_* x_)letb0= y_- b1*x_
b1.Dump("b1")
b0.Dump("b0")typeEntry={
DiskIO:int;
CPUTime:int;
Estimate:float;
Error :float;
ErrorSquared:float}letresult= List.zip x y |> List.map (fun elem ->{ DiskIO = fst elem;
CPUTime = snd elem;
Estimate = b0 + b1 * float( fst elem);
Error = float(snd elem)- b0 - b1 * float (fst elem);
ErrorSquared = Math.Pow(float(snd elem)- b0 - b1 * float (fst elem),2.)})
result.Dump("Result of the linear regression")