anchor.diff:      module OrdinaryLeastSquares =
   
           module Linear =
  -
  +            
               module RTO = 
                   /// 
                   let calculateANOVA (coef : float) x y =                
  
positive.code:         n * log (sse/n) + k * log (n) 
      
      /// Calculates the residuals
      let getResiduals (fitFunc:float -> float)  (x_data : Vector<float>) (y_data : Vector<float>) = 
          Seq.map2 (fun x y -> let y_estimated = fitFunc x
                               (y - y_estimated) ) x_data y_data
  
      /// Calculates SSE: sum of squares of errors
      /// also: unexplained sum of squares    
      let calculateSSE (fitFunc:float -> float)  (x_data : Vector<float>) (y_data : Vector<float>) = 
          Seq.map2 (fun x y -> let y_estimated = fitFunc x
                               (y - y_estimated) * (y - y_estimated) ) x_data y_data
          |> Seq.sum
  
  
      /// Calculates SST: sum of squares total
      /// also: total sum of squares
      let calculateSST (fitFunc:float -> float)  (x_data : Vector<float>) (y_data : Vector<float>) = 
          let meanY = Seq.mean y_data
          x_data |> Vector.map (fun x -> let y_estimated = fitFunc x
                                         (y_estimated - meanY) * (y_estimated - meanY) )
          |> Seq.sum
  
  
      /// explained = total - unexplained
  
  
negative.code: *)
  module GoodnessOfFit =    
      open FSharp.Stats
      open System
      /// Three sum of squares 
      type SumOfSquares = {
          /// Regression sum of squares (SSR: explained); Sum((yFit-yMean)**2.)
          Regression : float
          /// Error sum of squares (SSE: unexplained); residual sum of squares; Sum((y-yFit)**2.)
          Error      : float        
          /// Total sum of squares (SST: total); Sum((y-yMean)**2.)
          Total      : float        
          SSxx       : float
          SSxy       : float
  