How do you calculate the least squares fit to data?
Suppose the data is given by two lists
xi={1,2,3,4,5}
yi={1.1,3.3,4.5,4.2,6.3}
- Place the x values in L1 and the y-values in
L2. This can be done in one of two ways, either
directly through:
{1,2,3,4,5}->L1
{1.1,3.3,4.5,4.2,6.3}->L2
or by the pressing the [Stat] key, and selecting "Edit". The values
for L1 and L2 can be directly entered into the
first two columns of the table.
- The equation for least squares can be found by entering [Stat]
and selecting "Calc" then "LinReg(ax+b)"
- To plot the points, enter [2nd][Stat Plot]. Select Plot1 (or Plot2
or Plot3), making sure it is "On".
- Choose the scatterplot display (first option).
- Set XList: to be L1 and YList: to be L2
- Enter [Y=], and select Plot1. For the variable enter [Vars]->
"Statistics"->"Eq"->"RegEq"
- Enter [Window], and set up correct ranges.
- Enter [Graph]
- The display should be as shown below