HP Customer Support - Knowledge Base

# HP 50g Graphing Calculator - Curve Fitting

## The STAT menu

The Statistics menu is accessed from the ORANGE shifted function of the key by pressing . When pressed, a CHOOSE box is displayed with a number of problem areas within statistics where the HP 50g can be applied.
Figure : Displaying the Statistics menu The first choice deals with calculating many values related to the statistics of a single variable, such as the average, standard deviation and others. The second choice deals with placing data within bins or classes and is useful when dealing with frequency distributions or when there is a need to summarize data within a histogram. The third choice, 'Fit Data..' is what we will use to compute trend lines. The fourth choice allows for the computation of summary statistics from a data set, such as the sum of all X values, the sum of all the Y values squared, and others. The fifth choice allows for the evaluation of many different hypothesis tests and the sixth choice allows for the construction of confidence intervals around a sample mean.
To estimate a trend line, press the key until the third choice 'Fit Data..' is highlighted and press the key to register the choice of shown above the key at the right side of the display. The key can also be used to make selections from a CHOOSE box and will be used below. Alternatively, since the 'Fit Data..' choice is the third item in the list, the key can be pressed to immediately choose this function.
The screen displayed allows for the entry of the existing data for the solution of trend lines. The ΣDAT field at the top of the screen is where a matrix containing the statistics data is entered.
Figure : Enter statistical data in the ΣDAT field When the cursor is on this field, press the key at the top left of the keyboard to register the choice of . When pressed, the MatrixWriter is started to allow for the entry of the statistical data as shown in the screen below.
Figure : Entry of the statistical data In many ways, this screen works like any spreadsheet. Enter numbers and they will go in the highlighted cell. The menu labels at the lower left corner of the screen, and , determine the direction the cursor moves after a data point has been entered, either right to the next column or down to the next row. In this example, the selection is to move right after each data point has been entered. This is indicated by the square present next to the menu label. To change the way the cursor will move, press the menu label for the direction desired and the square in the menu label will change accordingly. If a column is too small to show the data entered, the and menu keys may be used to expand or shrink the area displayed for each column.
Enter the first X data value by keying in the numbers and pressing the key. The cursor will move to the right into the second column where the first Y data value should be keyed with the key pressed to accept this value. At this point, the cursor will be in column 3. Use the and keys to move back to the first column and enter the second X data value. Since the variable for ΣDAT will hold its contents from one calculation to the next, be alert to extra rows of data that may exist below the last row entered for the current calculation. Any rows not needed can be deleted if the cursor is on the row to be deleted by pressing the key and then pressing the menu label above the key. Continue entering the pairs of numbers in columns 1 and 2 until all have been entered. Press the key until the cursor is in row 1 and the screen would look something like this:
Figure : Displaying the data entered To accept the data as input, press the key to return to the previous menu. If an error is noticed, use the cursor keys to move to the cell with the incorrect value. Key in the correct value and press the key. Do this until all data values have been corrected and press the key again to return to the previous menu. The screen will now look something like this:
Figure : Displaying the data in the ΣDAT field To make predictions using a linear regression model, leave the model choice set to the value of Linear Fit. Other choices include Logarithmic, Exponential, Power and Best fits. These are accessed by pressing, .
Figure : Choosing statistical model To access the prediction screen, press the key to register the choice of . The screen displayed will look like this:
Figure : Accessing the prediction screen Move the cursor key down to the X: or Y: data entry locations. You may then enter an X or Y value for which you wish to predict the corresponding X or Y value. To actually predict the corresponding value, press the key after entering the X or Y value. You may do this as often as you like by moving the cursor back and forth.
To exit from this data entry screen, press the key to return to the previous data entry screen. From this location, you can either press the key again to quit the STAT screen or press shown above the to exit the STAT screen but with the extra feature of copying to the screen information about the linear regression line that was used. Three items will be shown on the screen. The top level indicates the equation of the linear regression-determined line. The second level indicates the correlation of the line. The bottom level indicates the covariance of the line. The correlation will always be between –1 and +1, where values closer to –1 and +1 indicating a good “fit” of the line to the data. Values nearer to zero indicate little to no “fit.” Little reliance should be placed upon predictions made where the correlation is not near –1 or +1. Exactly how far away from these values the correlation can be and the equation still be considered a good predictor is a matter of debate. Once these data items are viewed, pressing will return you to the STAT menu where you can reenter the Fit data... area, if desired.

## Curve fitting

Curve fitting is a general term applied to process of fitting an equation to a set of data points. In each of the models below, a represents the Y-intercept and b represents the slope. Fitting a Linear model to a set of data points (the process of linear regression) generates an equation of the form Y = bX + a, where b is the slope of the line and a is the Y-intercept. Fitting a Logarithmic model to a set of data points generates an equation of the form Y = b LN(X) + a.
note:
This is the same as the linear model except that the model generated uses the natural logarithm of the X values to predict a value for Y.
Fitting an Exponential model to a set of data points generates an equation of the form Y = a ebX, where the constant e is raised to the power of the X values multiplied by the slope, which is then multiplied by the Y-Intercept. Fitting a Power model to a set of data points generates an equation of the form Y = a X b, where the Y-intercept is multiplied by X raised to the power of the slope. The Best fit model examines these model types and uses the model that best fits the data. The process used for each of these models calculates the equation for these lines by minimizing the sum of the squared residuals between the actual data points and the predicted data points using the estimated slope and intercept. Once the slope and intercept have been calculated, it is fairly easy to substitute other values for X and predict a corresponding value for Y, or to substitute a value for Y and predict a value for X. For the power and exponential models, the YIntercept is assumed to be greater than zero. For the logarithmic model, values of X less than or equal to zero are not defined.

## Practice fitting curves to sets of data

### Example 1

Fit a Linear model to the data below and predict the value of Y when X is 37. What is the correlation?
 X Y 40.5 104.5 38.6 102 37.9 100 36.2 97.5 35.1 95.5 34.6 94

### Solution Figure : Entering the values  Figure : Accessing the prediction screen  Figure : Displaying the result When X is 37, the predicted value for Y is 98.65. The correlation is 0.995, which indicates a very strong relationship and predictive ability.

### Example 2

Have the calculator choose the Best fitting model for the data below and predict the value of Y when X is 8.5. What is the correlation?
 X Y 1 1.5 4 5.8 6 12.6 10 56.8 12 121.4

### Solution Figure : Entering the values  Figure : Entering the statistical data in the ΣDAT field  Figure : Accessing the prediction screen  Figure : Displaying the result Country/Region: Lithuania