anchor.diff:                          raise (System.ArgumentException("Coefficient has to be [a;b]!"))
                       let fitFunction x = coef.[0] + coef.[1] * x 
                       calculateANOVA 1 fitFunction x_data y_data 
  -
  +                
           module Polynomial = 
   
               //http://www.wolframalpha.com/input/?i=Vandermonde%20matrix&lk=1&a=ClashPrefs_%2aMathWorld.VandermondeMatrix-
  
positive.code: *)
  module GoodnessOfFit =    
      open FSharp.Stats
    
      /// Three sum of squares 
      type SumOfSquares = {
          /// Regression sum of squares (SSR - explained) 
          Regression : float
          /// Error sum of squares (SSE - unexplained)
          Error      : float        
          /// Total sum of squares (SST - total)
          Total      : float        
          SSxx       : float
          SSxy       : float
  
negative.code: 
      /// Standard deviation of y(x) 
      // Square root of variance s2y,x
      [<Obsolete("Use [standardErrorEstimate] instead")>]
      let stDevY (sumOfSquares:SumOfSquares) =
          sumOfSquares.Error / (sumOfSquares.Count - 2.) |> sqrt
  
      /// Standard error if the estimate 
      /// Square root of variance s2y,x
      let standardErrorEstimate (sumOfSquares:SumOfSquares) =
          sumOfSquares.Error / (sumOfSquares.Count - 2.) |> sqrt
       
      /// Standard deviation of slope (beta)    
      [<Obsolete("Use [standardErrorSlope] instead")>]
      let stDevSlope (sumOfSquares:SumOfSquares) =
          ( sumOfSquares.Error / (sumOfSquares.Count - 2.) ) / sumOfSquares.SSxx
          |> sqrt
  
      /// Standard error of slope (beta)    
      let standardErrorSlope (sumOfSquares:SumOfSquares) =
          (sumOfSquares.Error / (sumOfSquares.Count - 2.)) / sumOfSquares.SSxx 
          |> sqrt
  
      /// Standard deviation of intercept (alpha)
      [<Obsolete("Use [standardErrorIntercept] instead")>]
      let stDevIntercept (sumOfSquares:SumOfSquares) =
          let s2yx = sumOfSquares.Error / (sumOfSquares.Count - 2.) 
          let mx2  = sumOfSquares.MeanX*sumOfSquares.MeanX
          s2yx * ((1./sumOfSquares.Count) + (mx2/sumOfSquares.SSxx))
          |> sqrt
  
      /// Standard error of intercept (alpha)
      let standardErrorIntercept (sumOfSquares:SumOfSquares) =
           let s2yx = sumOfSquares.Error / (sumOfSquares.Count - 2.) 
           let mx2  = sumOfSquares.MeanX*sumOfSquares.MeanX
           s2yx * ((1./sumOfSquares.Count) + (mx2/sumOfSquares.SSxx))
           |> sqrt
  
      let ttestSlope slope (sumOfSquares:SumOfSquares) =
          let sb = standardErrorSlope sumOfSquares
          let statistic =  slope / sb 
          let TTest = Testing.TestStatistics.createTTest statistic (sumOfSquares.Count - 2.)
          TTest
  
      let ttestIntercept intercept (sumOfSquares:SumOfSquares) =
          let si = standardErrorIntercept sumOfSquares
          let statistic =  intercept / si 
          let TTest = Testing.TestStatistics.createTTest statistic (sumOfSquares.Count - 2.)
          TTest
  