anchor.diff:  open FSharp.Plotly
   open FSharp.Stats.Fitting.LinearRegression
   
  -let x_Data = vector [|1.;2.;3.;|]
  -let y_Data = vector [|4.;7.;9.;|]
  +let x_Data = vector [|1. .. 10.|]
  +let y_Data = vector [|4.;7.;9.;12.;15.;17.;16.;23.;5.;30.|]
   
   //Least squares simple linear regression
   let coefficientsLinearLS = 
  
positive.code:     
  let fittingPol = 
      let fit = 
          [|1. .. 0.01 .. 10.|] 
          |> Array.map (fun x -> x,fittingFunctionPol x)
      Chart.Line(fit)
      |> Chart.withTraceName "order = 3"
  
  let fittingPolW = 
      let fit = 
          [|1. .. 0.01 .. 10.|] 
          |> Array.map (fun x -> x,fittingFunctionPolW x)
      Chart.Line(fit)
      |> Chart.withTraceName "order = 3 weigthed"
  
  (*** do-not-eval***)
  [rawChartP;fittingPol;fittingPolW] 
  |> Chart.Combine
  |> Chart.Show
  
  (**
  ##Nonlinear Regression
  
negative.code: 
  ##Smoothing spline
  
  A smoothing spline aims to minimize a function consisting of two error terms: 
  
   - error1: sum of squared residuals
  
      - Similar to the OrdinaryLeastSquares regression this error term ensures the fidelity to the data.
  
   - error2: integral of the second derivative of the fitting function
  
      - This error term ensures the smoothness of the resulting curve.
  
  A smoothing parameter (lambda) mediates between the two error terms.
  
   - E = error1 + (lambda * error2)
  
      - If lambda = 0, the the resulting curve minimizes the sum of squared residuals and results in an interpolating curve.
  
      - If lambda = infinity, the resulting curve is punished by the smoothness measurement and results in a straight regression line.
  
  The spline is constructed out of piecewise cubic polynomials that meet at knots. In the defined knots the function is continuous. 
  