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 => TI-BASIC
United-TI Archives -> TI-Basic
 
    » Goto page 1, 2  Next
» View previous topic :: View next topic  
Author Message
Areign


Newbie


Joined: 27 Jan 2007
Posts: 31

Posted: 17 Mar 2008 12:49:13 pm    Post subject:

in AP stats, a number of my class mates dont have 84+ series calculators. the problem is: they need the invT Tcdf and tpdf functions to pass the exam. do any of you know of a program that does this, adds this functionality, or alternate commands for these functions. is this supported in a newer OS as they are all calculatorly not savy so i dont think theyve updated their OS... edit: just found they have the cdf functions, so i assume theres a way to do invT that i dont know, any guesses?

Last edited by Guest on 18 Mar 2008 08:19:33 pm; edited 1 time in total
Back to top
JoostinOnline


Active Member


Joined: 22 Aug 2007
Posts: 559

Posted: 17 Mar 2008 01:15:41 pm    Post subject:

I don't know why you would assume that there is a way. The InvT command is only on 84's, but I did find a program called Inverse T that duplicates it. Just a note, try to use better punctuation and grammar when posting on UTI.

Last edited by Guest on 02 Aug 2010 02:50:26 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: 17 Mar 2008 01:43:03 pm    Post subject:

You can make the calculation faster if you replace the line solve(tcdf(‾1E99,X,D)-A,X,5) by solve(tcdf(‾1E99,X,D)-A,X,invNorm(A.

Edit: for some special cases (df=1, df=2, df=4), you can significantly speed up the calculation by using a formula (see Student's t quantile function @ Wikipedia).

Input "p=?",P
Input "df=?",F
If F=1
Disp tan([font="times new roman"]π
(P-.5
If F=2
Disp (2P-1)/√(2P(1-P
If F=4:Then
2√(P(1-P
4/Anscos(1/3cosֿ¹(Ans
Disp (2(P>.5)-1)√(Ans-4
End
If min(F≠{1,2,4
Disp solve(tcdf(‾E99,X,F)-P,X,invNorm(P


Unfortunately, the general case is slow enough that you'd probably be better off with a table.

Last edited by Guest on 02 Aug 2010 02:50:57 am; edited 1 time in total
Back to top
Areign


Newbie


Joined: 27 Jan 2007
Posts: 31

Posted: 17 Mar 2008 05:27:07 pm    Post subject:

thanks for the program, as for my grammar....trying to write a perfectly punctuated sentence in the time when a librarian is turned around is not easy. just a note, introing into a post with such an ambiguously worded first sentence isn't any better than me doing all i could given the time i had. as for capitalization, i refuse to do what a brainless computer can do for me.

Last edited by Guest on 17 Mar 2008 05:28:21 pm; edited 1 time in total
Back to top
magicdanw
pcGuru()


Calc Guru


Joined: 14 Feb 2007
Posts: 1110

Posted: 17 Mar 2008 07:25:21 pm    Post subject:

Areign wrote:
thanks for the program, as for my grammar....trying to write a perfectly punctuated sentence in the time when a librarian is turned around is not easy. just a note, introing into a post with such an ambiguously worded first sentence isn't any better than me doing all i could given the time i had. as for capitalization, i refuse to do what a brainless computer can do for me.
[post="121598"]<{POST_SNAPBACK}>[/post]
If you need to think that hard about how to punctuate a sentence in your native language (I'm assuming it is English - correct me if I'm wrong) then there are better things you could be doing in a library than using the computers Very Happy . Also, just because a computer could fix capitalization for you, it doesn't mean it will, nor does it mean it should. My mom could spoon-feed me mushy carrots and peas, but she doesn't, for quite a number of reasons! Are you beginning to understand my point? By not using simple capitalization, you are saying that the very people who are helping you are not worth spending a few extra keystrokes on.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 17 Mar 2008 08:32:59 pm    Post subject:

In an article on JSTOR about calculating invT (A Retrievable Recipe for Inverse t, by Donald P. Gaver; Karen Kafadar. The American Statistician © 1984), I discovered an excellent approximation (valid for df>1.5, and good for df≥5, but small values of df don't occur that often)

Input "p=?",P
Input "df=?",F
(2(P>.5)-1)√(Fe^(invNorm(P)²(F-3/2)/(F-1)²)-F
Disp "Approx:",Ans
solve(tcdf(‾E99,X,F)-P,X,Ans


I thought it would speed up the program if I used this formula to get an approximate answer, then used it as a guess for solve(. Unfortunately, in this case, there's only so far a good guess can get you. The result is a ridiculous program that immediately spits out an answer correct to 2 or 3 significant digits, then spends 10 seconds or more thinking about the rest. Which is twice as fast, but still just slightly easier than looking in a table.

P.S. The discussion on the pros and cons of good grammar sure is fascinating, but I see at least one infinitely more interesting subject to focus on.


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


Active Member


Joined: 27 Mar 2005
Posts: 569

Posted: 18 Mar 2008 12:30:39 am    Post subject:

Let's all keep it on topic, shall we? :D

Anyway... much has been published on (pretty darn good) approximations to the inverse of the Student t CDF. As a matter of fact, mucking around at the StatLib archives will net you quite a few (translating them to TI-BASIC entirely up to you, of course).

If it takes too long on solve(, anyway, it might be expedient to use Newton-Raphson or Halley to refine your starting approximations. (An excellent exercise in derivatives and algebraic manipulation!)

(edit: for the interested, I am attaching the paper DarkerLine was referring to.)

thornahawk


Last edited by Guest on 18 Mar 2008 11:56:38 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: 18 Mar 2008 08:54:14 pm    Post subject:

Actually, Newton's method works like a charm in this case, especially since the derivative of tcdf( is easily computable - it's just tpdf(. You don't even need the fancy approximation, although it certainly helps.

Here's my latest version of prgmINVERSET (the part in gray is optional):

Input "p=?",P
Input "df=?",F
invNorm(P→T
If 2F>3
(2(P>.5)-1)√(Fe^(Ans²(F-3/2)/(F-1)²)-F→T

P-tcdf(‾E99,T,F
While Ans
T+Ans/tpdf(T,F→T
P-tcdf(‾E99,T,F
End
T


This is about five times as fast as the original method which relied only on solve(.

Edit: and I bet it generalizes for the χ² and F distributions quite well, too. The only thing that changes for those is that you no longer have something like invNorm to start as a reasonable guess.


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


Active Member


Joined: 27 Mar 2005
Posts: 569

Posted: 19 Mar 2008 10:20:14 am    Post subject:

"This is about five times as fast as the original method which relied only on solve(."

I think this statement is pretty much general. Keep in mind that solve( uses a more conservative algorithm for finding roots of equations (i.e. it was built to be able to work even for not-too-good starting values). If you have a really good guess to begin with, Newton's (and sometimes Halley's) can usually give results faster. (That, incidentally, is also why I decided to use Newton's method in the Lambert W program I gave a while back.)

"I bet it generalizes for the χ² and F distributions quite well, too. The only thing that changes for those is that you no longer have something like invNorm to start as a reasonable guess."

Yes, of course. One can search the literature for the starting approximations needed to get Newton's method going, but they're no longer as simple as the one given in prgmINVERSET. StatLib seems to have those, too.

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


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 20 Mar 2008 06:10:29 pm    Post subject:

Here's another program for the same purpose. It's slightly slower and only works when df is an integer. I thought I'd share it anyway because it's a less mathematician and more calculator programmer approach to things. Also, it's half the size.

Input "p=?",P
Input "df=?",F
TInterval 0,√(F+1),F+1,abs(2P-1
upper(1-2(P<.5


The idea is that TInterval has to do some sort of inverse-T calculation to accomplish its task, and I hijack that calculation to give me my answer.


Last edited by Guest on 02 Aug 2010 02:53:05 am; edited 1 time in total
Back to top
Areign


Newbie


Joined: 27 Jan 2007
Posts: 31

Posted: 21 Mar 2008 11:40:26 pm    Post subject:

idk, i just gave out a program that was basically: input p and d then solve(p-tcdf(-99,x,d),x,0) and that seemed to work fairly fast. the program you wrote before took forever to do anything above 10 df. the solve on seems easiest and fastest at this point... though the immediate 3 sigdig one i may try out, is that one good for all df or does it increase inaccuracy as df gets larger?

Last edited by Guest on 22 Mar 2008 08:44:53 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: 22 Mar 2008 09:48:47 am    Post subject:

I have to ask if we're talking about the same program and the same TI-Basic language here. Using solve( the way you suggest takes upwards of 20 seconds to give a solution. The last two programs I gave in this topic take 3.5 and 5 seconds respectively. The times may differ from calculator to calculator, but the ratios should stay the same.

Also, in general, the inaccuracy decreases as df gets large; it's for small values of df that there's problems. Of course, both of my last two programs give exact answers, so that's not an issue.


Last edited by Guest on 22 Mar 2008 09:55:16 am; edited 1 time in total
Back to top
Areign


Newbie


Joined: 27 Jan 2007
Posts: 31

Posted: 24 Mar 2008 08:16:06 am    Post subject:

i coulda sworn i replied to this last night but w/e. whenever i ran the program:

Input "p=?",P
Input "df=?",F
invNorm(P→T
If 2F>3
(2(P>.5)-1)√(Fe^(Ans²(F-3/2)/(F-1)²)-F→T
P-tcdf(‾E99,T,F
While Ans
T+Ans/tpdf(T,F→T
P-tcdf(‾E99,T,F
End
T

it would take about 10-20 seconds to run at low df. nothing above 10 df even finished and it took half a period for 7 to end. i did get the same answer as invT (since i was testing on my calc) so i know its not some stupid error, i think everything is working correctly.the solve( one does take a bit of time, but its consistant and works for all df. besides it doesnt take more time that the one you gave, from my own tests at least, i will retest however and tell you later if i was doing something wrong...

edit: for some unexplicable reason, it worked alot better this time, but anything 1000 and up wouldnt work. i put some debug code in and found the difference is alternating between like 13 decimals and 123 decimals and is getting stuck in an endless loop, im just gona set it to check if ans>E(-9) or something so that it works faster/at all with numbers like that, it will be fine since the calc only displays that far anyway. thanks for your help, your program, with that addition works far better than solve does. here is what i came up with:

Input "p=?",P
Input "df=?",F
invNorm(P→T
0
Repeat Ans<E-9
T+Ans/tpdf(T,F→T
P-tcdf(‾E99,T,F
End
T


Last edited by Guest on 24 Mar 2008 08:49:10 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: 24 Mar 2008 10:46:22 am    Post subject:

A better way to approach the df>1000 problem is to replace While Ans with While round(Ans...

Last edited by Guest on 02 Aug 2010 02:50:13 am; edited 1 time in total
Back to top
Areign


Newbie


Joined: 27 Jan 2007
Posts: 31

Posted: 24 Mar 2008 04:31:55 pm    Post subject:

true, but my method seems to work good so far...well your method with an arbitrary prescision added.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 24 Mar 2008 05:32:34 pm    Post subject:

Also, for large df, the t distribution is basically the same as the normal distribution.
Back to top
navyfalcon


Advanced Newbie


Joined: 17 Mar 2008
Posts: 77

Posted: 16 Apr 2008 06:05:35 pm    Post subject:

Areign wrote:
i coulda sworn i replied to this last night but w/e. whenever i ran the program:

Input "p=?",P
Input "df=?",F
invNorm(P→T
If 2F>3
(2(P>.5)-1)√(Fe^(Ans²(F-3/2)/(F-1)²)-F→T
P-tcdf(‾E99,T,F
While Ans
T+Ans/tpdf(T,F→T
P-tcdf(‾E99,T,F
End
T

it would take about 10-20 seconds to run at low df. nothing above 10 df even finished and it took half a period for 7 to end. i did get the same answer as invT (since i was testing on my calc) so i know its not some stupid error, i think everything is working correctly.the solve( one does take a bit of time, but its consistant and works for all df. besides it doesnt take more time that the one you gave, from my own tests at least, i will retest however and tell you later if i was doing something wrong...

edit: for some unexplicable reason, it worked alot better this time,  but anything 1000 and up wouldnt work. i put some debug code in and found the difference is alternating between like 13 decimals and 123 decimals and is getting stuck in an endless loop, im just gona set it to check if ans>E(-9) or something so that it works faster/at all with numbers like that, it will be fine since the calc only displays that far anyway. thanks for your help, your program, with that addition works far better than solve does. here is what i came up with:

Input "p=?",P
Input "df=?",F
invNorm(P→T
0
Repeat Ans<E-9
T+Ans/tpdf(T,F→T
P-tcdf(‾E99,T,F
End
T
[post="121878"]<{POST_SNAPBACK}>[/post]


1. Input "p=?",P
2. Input "df=?",F
3. invNorm(P→T
4. 0
5. Repeat Ans<E-9
6. T+Ans/tpdf(T,F→T
7. P-tcdf(‾E99,T,F
8. End
9. T

7. P-tcdf(‾E99,T,F
What is the symbol prior to E99 ??
Thank You
falcon
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 16 Apr 2008 06:31:48 pm    Post subject:

It's a negative sign. And the E is the scientific E symbol.
Back to top
navyfalcon


Advanced Newbie


Joined: 17 Mar 2008
Posts: 77

Posted: 16 Apr 2008 06:33:12 pm    Post subject:

Sorry, I found the ans. "TI-83 Guidebook" pg.1-7 negative EE
Thank You
I was looking under the wrong items in the "Guidebook".
Back to top
navyfalcon


Advanced Newbie


Joined: 17 Mar 2008
Posts: 77

Posted: 16 Apr 2008 07:20:35 pm    Post subject:

1. Input "P=",P
2. Input "DF=",F
3. invNorm(P->T
4. 0
5. Repeat Ans<E-9
6. T+Ans/tpdf(T,F->T
7. P-tcdf(-E99,T,F
8. End
9. Disp "T=
10. Output(4,3,T
11. Stop

note: I used the correct symbol for -E line 7 [or (-)]

Test P=.95 P=.99
DF=18 DF=18

t.05 (df=1Cool= 1.6449
t.01 (df=1Cool= 2.3263

answers from my textbook tables

t.05 (df=1Cool= 2.1009
t.01 (df=1Cool= 2.8784

where did I error ??
Thank You
falcon
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
    » Goto page 1, 2  Next
» View previous topic :: View next topic  
Page 1 of 2 » All times are UTC - 5 Hours

 

Advertisement