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.

TI-Basic => TI-BASIC
Author Message
Henry

Newbie

Joined: 02 Jun 2010
Posts: 7

 Posted: 04 Jun 2010 04:27:51 pm    Post subject: I've been trying to figure out the best and fastest way to find the mode(s) of a list. By using a frequency routine and then just a loop to find repeats of the frequency, the mode is found: ClrList L₂,L₃,L₄ SortA(L₁ For(A,1,dim(L₁ L₁(A→L₂(1+dim(L₂ sum(L₁=Ans→L₃(dim(L₂ A-1+Ans→A End For(A,1,dim(L₃ If max(L₃)=L₃(A) L₂(A→L₄(1+dim(L₄ End ClrList L₂,L₃ List four is the output of the modes Any suggestions? There is also some theorem for finding the mode stating that mean - mode is approx. equal to 3(mean - median), http://mathworld.wolfram.com/Mode.html Also, there is a quick routine posted on the TI-basic vault: http://weregoose.unitedti.org/#ModeCalculator :imag(max(Ansi+E9seq(sum(Ans=Ans(A)),A,1,dim(Ans But it only finds one mode if there exists more than one.
Galandros

Active Member

Joined: 29 Aug 2008
Posts: 565

 Posted: 04 Jun 2010 05:02:19 pm    Post subject: That seems the normal and best way to find all the modes with sure. To initialize the lists without giving errors (if they don't exist) use: 0->dim(L₂ instead of ClrList L₂ Then in the end to clear the lists, delete them with: DelVar L₂ DelVar L₃ because DelVar for some odd reason does not need a new line you can type in TI-BASIC: DelVar L₂DelVar L₃
Weregoose
Authentic INTJ

Super Elite (Last Title)

Joined: 25 Nov 2004
Posts: 3976

 Posted: 05 Jun 2010 07:36:49 pm    Post subject: This was my distraction while losing a game of Settlers of Catan... seq(sum(L1=L1(X)),X,1,dim(L1 Ans=max(Ans For(X,1,dim(Ans If Ans(1)min(Ans≠L1(X augment(Ans,{L1(X ΔList(cumSum(Ans End The output is in Ans. (This runs into strange issues when the modes are zero or one.)Last edited by Guest on 05 Jun 2010 07:41:04 pm; edited 1 time in total
 Display posts from previous: All Posts Oldest FirstNewest First
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.

»
 Page 1 of 1 » All times are UTC - 5 Hours