Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
Hi there, I recently started AP Physics this year and love the linear regression feature on the Ti-84 plus CE, but I need the line of best fit to pass through the origin. People have suggested that I just add a point (0,0) in my data set, but that doesn't shift it enough, and adding 100 extra points isn't perfect either. I saw a thread for the Ti-83 where someone posted the completed code, and I tried using that but it wasn't compatible. Could someone update it? or maybe write it brand new? I have seen many people asking about it while searching for a program, and I'm sure they'd love to have it available too! Very Happy
Here is my updated version for the TI-84+CE. This is slightly different than the one I posted in the other thread. This code uses the eval( command to insert the actual coefficient into the equation placed in Y1:


Code:
Prompt L₁,L₂
AxesOn
1+min({0,min(L₁→Xmin
1+max(L₁→Xmax
1+min({0,min(L₂→Ymin
1+max(L₁→Ymax
Plot1(Scatter,L₁,L₂,▫
eval(sum(L₁L₂)/sum(L₁))+"X→Y₁
DispGraph
bubbleumpaul wrote:
People have suggested that I just add a point (0,0) in my data set, but that doesn't shift it enough, and adding 100 extra points isn't perfect either.


Neither of these forces the regression line to go through the origin. To do this, the offset needs to be kept at zero and only the slope must be calculated.

Normal linear regression finds a, b that minimize the term

Σ(a*x+b-y)^2 for all pairs of x, y

What you want is instead finding a that minimizes

Σ(a*x-y)^2

The term becomes minimal when its derivative with respect to a is zero:

d/da Σ(a*x-y)^2 = 2*Σ(a*x-y)*x = 0

This leads to

a*Σ(x^2) - Σ(xy) = 0
a = Σ(xy) / Σ(x^2)

Which is what the second to last line in jonbush's code calculates.
Thanks guys, what a help Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement