HP Prime & TI36X Pro: Part I - cubic curve-fitting

Introduction This module shows methods for x,y data generation and regression analysis including - Generate x,y data based on a model f(x) = cubic function + random noise
- Curve fitting the appropriate f(x) model based on the x,y data
- Generating predicted or fitted y values based on the regression model f(x)
I show these methods using both the HP Prime and the TI36X Pro (a non CAS, non graphing) calculator. I did this to show myself the differences in using the two devices. As you might expect, the HP Prime has some more capabilities than the TI36X, however the TI36X was to me a bit easier to use without making operator errors. In part II, we continue the comparison with: Using the f(x) model, answer questions related to extremes, slopes, inflection points, derivatives and integrals. ## HelpIf you are still getting familiar with the HP Prime or the TI-36x Pro, take some time to familiarize yourself with the units basic functions and in particular: - HP Prime: Stats 2Var App
- TI36X: data, stat-reg and table commands
. |

## HP Prime Graphing Calculator(a) Generate 10 pairs of x,y data where f(x)= cubic + noise Use f(x) = -0.3x^3 +2.0x^2 -1.5x +1.0 +rand as the model to generate data, where x = {0.5-5.0 in 0.5 steps) (b) Curve fit the appropriate f(x) model based on the x,y data (c.) Generate a table of fitted y values based on the regression (a) Generate 10 pairs of x,y data where f(x)= cubic + noise Open the 2 var stats application. In Num, just type in 0.5 to 5.0 in 0.5 steps into C1 Note that RANDNORM() comes from toolbox 5 4 3. Note also, the start, stop and step used to store the calculated expression in C2. Your C2 results should be similar to mine. Note - I set to Fix 1 to round to 0.x place. Congratulations, you just generated some data using a model expression + noise Before proceeding, manually type in the following data into C2: 0.6, 0.5, 1.4, 3.5, 4.5, 6.4, 7.4, 7.4, 6.9, 6.0 (b) Curve fit the appropriate f(x) model based on the x,y data Now that we have some data, we can move to the Symb to setup some 2 variable analysis. If we want to plot C1 versus C2 and fit to a linear model, enter C1 and C2 into S1: as independent and dependant data as shown. Now press Plot and you should see a plot that looks “something” like this: It may not look like this unless you have setup the Plot settings ahead of time. Shift Plot (settings) will allow you to adjust the plot. Setting X Rng: -1 to +6 and Y Rng: -1 to 10 helps zoom in. If you want to see statistics related to the x, y and linear fit, pressing Plot Menu then Defn can provide the linear model Return to the Symb menu and change the model Type1: Cubic. Now, Plot gives the cubic model fitted to the data. This appears to be a better fit visually. Note the model coefficients in the display. Checking Num Stats shows an R^2 value of 0.99. S1: = f(x) = -0.34*X^3 +2.31*X^2 -2.18*X +0.94 is the regression with coefficients rounded to 0.xx (c.) Generate a table of fitted y values based on the regression To generate a table of fitted y values, from the Symb view, shift-copy the formula in Fit1:. Now in Num view, press Make to make a fitted set of data in C3. Shift-paste the formula into the Expression as shown, fill in the rest of the Make screen then OK. Note that the copied model is pasted with full precision, not rounded to 0.xx. We will use this cubic expression often in later analyses. At this point, based on graphical and statistical analyses, a cubic model is suitable for the x,y data provided. ** Congratulations if you completed this module. I would return to this point before starting part II of this analysis. The x,y data and the cubic f(x) regression model are used again there. | ## TI-36X Pro Calculator(a) Generate 10 pairs of x,y data where f(x)= cubic + noise Use f(x) = -0.3x^3 +2.0x^2 -1.5x +1.0 +rand as the model to generate data, where x = {0.5-5.0 in 0.5 steps) (b) Curve fit the appropriate f(x) model based on the x,y data (c.) Generate a table of fitted y values based on the regression (a) Generate 10 pairs of x,y data where f(x)= cubic + noise Press data data 4 to clear all data. Press data and move to L1 column. Directly enter 0.5-5.0 in 0.5 steps (10 points). Move to the L2 column and press data FORMULA 1: Add/Edit . Enter -0.3*L1^3 +2.0*L1^2 -1.5*L1 +1.0 +rand Note - each L1 is selected in the expression by pressing data 1:L1 Hit enter and L2 will show generated values. In my case they were: 0.6, 0.5, 1.4, 3.5, 4.5, 6.4, 7.4, 7.4, 6.9, 6.0 Yours may be different due to the rand (noise) term. Congratulations, you just generated some data using a model expression + noise. Remember that each time the data button is pressed, the data formulas recalculate. To “freeze in” your L2 data, use data data formula 3-clr L2 frmla Before proceeding, manually type in the L2 data I had above: 0.6, 0.5, 1.4, 3.5, 4.5, 6.4, 7.4, 7.4, 6.9, 6.0 (b) Curve fit the appropriate f(x) model based on the x,y data Since this is not a graphing calculator, you should plot the x,y data by hand or electronically. Viewing this scatter plot, it appears that there may be a non linear relationship. Should not be surprising since we used a cubic expression to generate the y data... Just to check, lets first try a linear regression. 2nd Stat-reg 4:LinReg ax+b Enter . x data: L1, y data: L2 Calc. Output is: a = 1.66, b = -.11, R^2 = 0.81 This roughly fits the x,y data but perhaps the R^2 value can be increased. Now try a quadratic model and record coefficients, R^2. In this case, lets also generate fitted (y’) values. 2nd Stat-reg 5:Quadratic Enter x data: L1, y data: L2 RegEQ>f(x): YES Calc Output: a = -0.47 For a table of fitted (y’) values use table table 2: Edit Function Enter Enter start 0.5, 0.5 step Calc Output (y’): -0.7, 1.1, 2.6, 3.9, 5, 5.8, 6.4, 6.8, 6.9, 6.8 y data: 0.6, 0.5, 1.4, 3.5, 4.5, 6.4, 7.4, 7.4, 6.9, 6.0 This follows the y data closer than the linear model, but there are some residuals >1.0, (ie. 2.6-1.4) Finally, see how well a cubic model fits the data 2nd Stat-reg 6: Enter RegEQ>f(x): YES Calc Output: or f(x) = -0.34*X^3 +2.31*X^2 -2.18*X +0.94 is the regression (c.) Generate a table of fitted y values based on the regression Again. for table of fitted (y’) values table 2: Edit Function Enter Enter start 0.5, 0.5 step Calc Output: 0.4, 0.7, 1.7, 3.1, 4.7, 6.1, 7.2, 7.7, 7.3, 5.7 y data: 0.6, 0.5, 1.4, 3.5, 4.5, 6.4, 7.4, 7.4, 6.9, 6.0 This follows the y data very closely with residuals <0.4. That, coupled with the high 0.99 R^2 value make the quadratic model useful with this x,y data. ----- Important note: Although I show the coefficients to only two decimal places (to save typing), I will use the full precision of the calculator when using the model a,b,c,d. For illustration, if I use a=-0.34 versus the precise -0.33644..... then its effect on f(5.0) is ~ (5.0^3)*(.33644-0.34) or ~0.45. This is as large as the maximum residuals of the model. Also, note that since the a-d coefficients are saved after regression, we can put them to good use in the analyses that follow in part II. ** Congratulations if you completed this module. I would return to this point before starting part II of this analysis. The x,y data and the cubic f(x) regression model are used again there. |

[1] HP Prime: We could have used the Make or MAKELIST commands, but for 10 points, I just type it in

[2] HP Prime: You may have to hit the up or down arrow a couple of times to get to this equation. You can also see the fit in the Symb view

[3] TI36X: rand is accessed via 2nd random 1: rand

[4] TI36X: Actual coefficient a = -0.465151515 and a-d are stored automatically

[5] TI36X: Alternately, you could create an L3 formula: data L3 data formula 1: Add/Edit : a*L1^3 +b*L2^2 +c*L1 +d

[6] TI36X and HP Prime: Note that the cubic regression coefficients will differ slightly from the cubic model used to create the y data. This is due to the rand or “noise” term used in the model