This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic Brain Teasers => TI-BASIC
Author Message
thornahawk
μολών λαβέ


Active Member


Joined: 27 Mar 2005
Posts: 569

Posted: 10 Apr 2008 12:16:28 am    Post subject:

Without using any of the LinReg commands, write the smallest possible linear regression routine that, given the x-coordinates stored in L1 and the y-coordinates stored in L2, will output the slope and y-intercept of the best-fit line of a given set of points.

You can of course check the validity of your routine by comparing results with any of the two LinReg functions. ;)

thornahawk
Back to top
emperorwiggy


Newbie


Joined: 27 Mar 2008
Posts: 27

Posted: 10 Apr 2008 07:12:36 am    Post subject:

Is there any particular reason why you can't use the LinReg command? Besides making it really hard? :biggrin:
I could do it with a numstring subroutine that doesn't use linreg, but I don't have one.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 10 Apr 2008 08:29:23 am    Post subject:

This is probably cheating:
Quote:
e^(L2→L2
ExpReg
ln({b,a


I suggest the rules be changed to not allow use of any regressions (including LinRegTTest, or on the newer calculators LinRegTInt)


Last edited by Guest on 10 Apr 2008 08:32:39 am; edited 1 time in total
Back to top
thornahawk
μολών λαβέ


Active Member


Joined: 27 Mar 2005
Posts: 569

Posted: 10 Apr 2008 09:52:27 am    Post subject:

"Besides making it really hard?"

- Well, the name of the forum has "Brain Teasers" in it, so... ;)

"This is probably cheating..."

- Yes it is. :P

"I suggest the rules be changed to not allow use of any regressions (including LinRegTTest, or on the newer calculators LinRegTInt)"

- Yes indeed. No built-in regression functions please, Louise. :P

thornahawk
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 10 Apr 2008 09:44:06 pm    Post subject:

Okay, here's an honest attempt:

Quote:
2-Var Stats
Matr►list(rref([[Σx²,Σx,Σxy][Σx,n,Σy]]),3,L₃


The routine outputs the result in L₃ as the pair {slope, y-intercept}. If you want the result to be displayed as well, add L₃ as a final line.


Last edited by Guest on 02 Aug 2010 02:33:09 am; edited 1 time in total
Back to top
thornahawk
μολών λαβέ


Active Member


Joined: 27 Mar 2005
Posts: 569

Posted: 11 Apr 2008 12:39:00 am    Post subject:

Wow, that is short! Very Happy Here was my attempt:

Quote:
mean(L₁→T
mean((L₁-Ans)L₂)/mean((L₁-Ans)²
{Ans,mean(L₂)-AnsT


thornahawk
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 11 Apr 2008 08:48:44 am    Post subject:

Where X = and Y = :
Quote:
2-Var Stats
(Σxy-nXY)/(Σx²-nX²
{Ans,Y-XAns

[EDIT]

That's basically what thornahawk had. Surprised
My sources were (27) and (2Cool from here.


Last edited by Guest on 11 Apr 2008 09:04:22 am; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 11 Apr 2008 01:33:30 pm    Post subject:

A minor optimization to the second line of your routine: (Σxy/n-XY)/σx²

Last edited by Guest on 02 Aug 2010 02:32:56 am; edited 1 time in total
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement