lib/linefit.rb
############################################################################
# Return the correlation coefficient
#
#  rSquared = linefit.rSquared
#
# R squared, also called the square of the Pearson product-moment
# correlation coefficient, is a measure of goodness-of-fit. It is the
# fraction of the variation in Y that can be attributed to the variation
# in X. A perfect fit will have an R squared of 1; fitting a line to the
# vertices of a regular polygon will yield an R squared of zero. Graphical
# displays of data with an R squared of less than about 0.1 do not show a
# visible linear trend.
#
# The return value is undefined if the regression fails. If weights are
# input, the return value is the weighted correlation coefficient.
#
Return the correlation coefficient
rSquared = linefit.rSquared

R squared, also called the square of the Pearson product-moment
correlation coefficient, is a measure of goodness-of-fit. It is the
fraction of the variation in Y that can be attributed to the variation
in X. A perfect fit will have an R squared of 1; fitting a line to the
vertices of a regular polygon will yield an R squared of zero. Graphical
displays of data with an R squared of less than about 0.1 do not show a
visible linear trend.

The return value is undefined if the regression fails. If weights are
input, the return value is the weighted correlation coefficient.
Return the correlation coefficient rSquared = linefit . rSquared R squared also called the square of the Pearson product - moment correlation coefficient is a measure of goodness - of - fit . It is the fraction of the variation in Y that can be attributed to the variation in X . A perfect fit will have an R squared of 1 ; fitting a line to the vertices of a regular polygon will yield an R squared of zero . Graphical displays of data with an R squared of less than about 0 . 1 do not show a visible linear trend . The return value is undefined if the regression fails . If weights are input the return value is the weighted correlation coefficient .
def rSquared
      unless @rSquared
         self.regress or return
         denom = @sumSqDevx * @sumSqDevy
         @rSquared = denom != 0 ? @sumSqDevxy ** 2 / denom : 1
      end
      return @rSquared
   end
def rSquared unless @rSquared self . regress or return denom = @sumSqDevx * @sumSqDevy @rSquared = denom != 0 ? @sumSqDevxy ** 2 / denom : 1 end return @rSquared end
Return the correlation coefficient
rSquared = linefit.rSquared
Return the correlation coefficient rSquared = linefit . rSquared