Sket and the Hobo


Program a TI-83 to Calculate Chi-squared
March 14, 2009, 4:21 am
Filed under: Projects | Tags:

Chi-squared, and the associated Probability Density Table, is used to quantify the match between a hypothesis and observed data. Chi-Squared is used a heck of a lot in all sorts of statistical sciences but has become a pain in my life recently because of genetics.  So let’s use our TI-83 calculator to crunch the numbers for us.

To make things easy we’ll need three different programs.  Let us start with the most basic:

Chi

hit the ‘program’ button (here on callled prgm), then arrow over to the ‘New’ menu and choose ‘Create New’.

name it ‘Chi’ – Enter the following code

Disp "Input Observerd"
Input O
Disp "Input Expected"
Input E
((O-E)^2/E -> C

We now have our Chi-Squared function so now lets make the Probability Density program.  Again, create a new program, called ‘ChiTable’ here – and enter the following code:

N-1 -> D
(T^((D/2)-1)*e^(-T/2))/(2^(D/2)*(((N-1)!)*(D/2)))->P

Alright almost done – let’s tie it all together with our main program. Again new program, called here ‘ChiSQR’ – enter the following code:

0->R&8800
0->T
0->N
0->C
0->P
Disp "Number of Sets"
Input N
While R ≠ N
R+1 ->R
prgmCHI
C+T->T
Disp T
End
PrgmCHITABLE
Disp "Probability"
Disp P

Alright – so let’s test it to make sure it works – Hit PRGM, EXEC Tab, Then CHISQR and input the following information:

Type Observed Expected
1 62 50
2 38 50

The program should output 2.88 for the first set, then 5.76 for the second and the probability should be .03307……something.

If you don’t get that double check your work.

Advertisement

Leave a Comment so far
Leave a comment



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s



Follow

Get every new post delivered to your Inbox.