Linear Regression

Category: Fit/Interpolate/Extrapolate
Author:
Description: Function to perform a linear regression on the data passed in as an image. The image is 2 pixels high by n wide - where n is the number of data point pairs. The image format is: x0, x1, x2 . . . . xn y0, y1, y2 . . . . yn The top row of data is x, and the bottom row y. The 95% confidence interval and the R value are calculated in addition to the a (intercept) and b (slope) parameters of the straight line. This script creates some example data and plots it, then fits the straight line to it.
Comments: There is a limitation (or conflict) in User Defined Language with DM script. The operation "/" and "*" cannot be defined as operators in Notepad++ once we define "/*" and "*/" as comment block markers. So I have left "/" and "*" out from the operator list
Acknowledgements: Thanks to Bill Bertram of ANSTO for assistance with algorithm development.
Script version: 1.0
DM/GMS version: 3.11
Script written as a function: Yes
Source: Show code
Download Source Code: Download
Download Zip File: Download