Skip to content

Instantly share code, notes, and snippets.

@krishnanraman
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krishnanraman/8700991 to your computer and use it in GitHub Desktop.
Save krishnanraman/8700991 to your computer and use it in GitHub Desktop.
val (x:Data, y:Data) = dataxy.toIndexedSeq.unzip
val (scaledx, xmin, xscaler) = scale(x)
val (scaledy, ymin, yscaler) = scale(y)
val ysq = scaledx.zip(scaledy).map{ xy => val(x,y) = xy; y - x*x }
val (normx, mux, sigmax) = normalize(scaledx)
val (normy, muy, sigmay) = normalize(ysq)
val corr = OLS.corr(normx,normy)
printf("\n OLS Normalized Poly: \n mux:\t%.3f \n sigmax:\t%.3f \n xmin:\t%.3f \n xscaler:\t%.3f \n muy:\t%.3f \n sigmay:\t%.3f \n ymin:\t%.3f \n yscaler:\t%.3f \n corr:\t%.3f \n rsq:\t%.3f \n ",
mux, sigmax, xmin, xscaler,
muy, sigmay, ymin, yscaler,
corr, corr*corr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment