Hi! I've been working on this Mann-Whitney U test program, but after a few seconds, the program just ends. Does anybody have any advice on how to fix this? Thanks!

Code:
```ClrHome Output(5,8,"MANN-WHITNEY") Output(6,11,"U TEST") Output(10,8,"By StatManan") Pause ClrHome Disp "Input both lists of sam-","ple data below." Disp "" Disp "To input your list,","press [2nd][stat] to find","it and press [enter]." Disp "" Input "Samp1List: ",⌊SAMP1 Input "Samp2List: ",⌊SAMP2 SortA(⌊SAMP1) SortA(⌊SAMP2) ((dim(⌊SAMP1))*(dim(⌊SAMP2)))+(dim(⌊SAMP1)*(dim(⌊SAMP1)+1))2→U augment(⌊SAMP1,⌊SAMP2)→⌊SAMPX SortA(⌊SAMPX) 0→W For(I,1,dim(⌊SAMPX)): I→⌊RANK(I) If ⌊SAMPX(I)=⌊SAMP1(I):Then ⌊RANK(I)→Y W+Y→W Else W+0→W End U-W→U If dim(⌊SAMP1)>10 and dim(⌊SAMP2)>20:Then Disp "The sample sizes allow","for the use of a simpli-","fied large sample test.","","Press 1 for a one-tailed","test or 2 for a two-","tailed test.","" Input "Which test? ",A getKey→A If A=92:Then U-(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2)→T √((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12)→B T/B→Z Disp "Press  if you wish to test","if Population 1 is","shifted to the right of","Population 2, or  if","you wish to test if Popu-","lation 1 is shifted to","left of Population 2.","" Input "Which alt. hypothesis?",A getKey→A If A=26:Then normalcdf(­199,­(Z),(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2),√((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12))→P ClrHome Disp "Please input the desired","α-level below.","" Input "α=?",A If P<A:Then ClrHome Disp "Hypothesis rejected." Disp "" Disp "U" Disp U Disp "p=" Disp P Disp "N₁" Disp dim(⌊SAMP1) Disp "N₂" Disp dim(⌊SAMP2) Else ClrHome Disp "Failed to reject." Disp "" Disp "U" Disp U Disp "p=" Disp P Disp "N1" Disp dim(⌊SAMP1) Disp "N2" Disp dim(⌊SAMP2) Stop Else:If A=24:Then normalcdf(Z,199,(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2),√((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12))→P ClrHome Disp "Please input the desired","α-level below.","" Input "α=?",A If P<A:Then ClrHome Disp "Hypothesis rejected." Disp "" Disp "U" Disp U Disp "p=" Disp P Disp "N₁" Disp dim(⌊SAMP1) Disp "N₂" Disp dim(⌊SAMP2) Else ClrHome Disp "Failed to reject." Disp "" Disp "U" Disp U Disp "p=" Disp P Disp "N1" Disp dim(⌊SAMP1) Disp "N2" Disp dim(⌊SAMP2) Stop Else:If A=93:Then U-(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2)→T √((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12)→B T/B→Z normalcdf(Z,199,(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2),√((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12))+normalcdf(­199,­(Z),(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2),√((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12))→P ClrHome Disp "Please input the desired","α-level below.","" Input "α=?",A If P<A:Then ClrHome Disp "Hypothesis rejected." Disp "" Disp "U" Disp U Disp "p=" Disp P Disp "N₁" Disp dim(⌊SAMP1) Disp "N₂" Disp dim(⌊SAMP2) Else ClrHome Disp "Failed to reject." Disp "" Disp "U" Disp U Disp "p=" Disp P Disp "N1" Disp dim(⌊SAMP1) Disp "N2" Disp dim(⌊SAMP2) Stop Else ClrHome Disp "U=",U,"","N₁=",dim(⌊SAMP1),"N₂=",dim(⌊SAMP2),"Press [enter] for inter-","pretation." Pause Disp "" Disp "To find the p-value, use","a table of Mann-Whitney","U values given the above","values." Stop ```

I'll update this post if I figure out something else. My calculations for the Mann-Whitney U test are based on the formulae provided on pages 782-786 of the PDF in the link below:

https://github.com/chqngh-berkeley/personal/blob/master/Mathematical%20Statistics%20-%207th%20Edition%20-%20Wackerly.pdf
You are missing lots of Ends to close off your If statements.
The way you've written it, if a condition is false, then it will skip to the end of the program.
Here's how Ifs work:

Code:
```If A=92 Then [...] End```
mr womp womp wrote:
You are missing lots of Ends to close off your If statements.
The way you've written it, if a condition is false, then it will skip to the end of the program.
Here's how Ifs work:

Code:
```If A=92 Then [...] End```

Thanks for the advice! I'll make sure to add those in and see how it plays out. Also, sorry I didn't reply to your reply on my earlier post, but thanks for the advice then as well! I made the edits and it worked out perfectly
statman23 wrote:
mr womp womp wrote:
You are missing lots of Ends to close off your If statements.
The way you've written it, if a condition is false, then it will skip to the end of the program.
Here's how Ifs work:

Code:
```If A=92 Then [...] End```

Thanks for the advice! I'll make sure to add those in and see how it plays out. Also, sorry I didn't reply to your reply on my earlier post, but thanks for the advice then as well! I made the edits and it worked out perfectly

So I just added a bunch of Ends... the program still isn't functioning tho . There has to be some way for me to run conditionals in a for loop without the program just skipping to the end when a conditional is false...

Code:
```ClrHome Output(5,8,"MANN-WHITNEY") Output(6,11,"U TEST") Output(10,8,"By StatManan") Pause ClrHome Disp "Input both lists of sam-","ple data below." Disp "" Disp "To input your list,","press [2nd][stat] to find","it and press [enter]." Disp "" Input "Samp1List: ",⌊SAMP1 Input "Samp2List: ",⌊SAMP2 SortA(⌊SAMP1) SortA(⌊SAMP2) ((dim(⌊SAMP1))*(dim(⌊SAMP2)))+(dim(⌊SAMP1)*(dim(⌊SAMP1)+1))2→U augment(⌊SAMP1,⌊SAMP2)→⌊SAMPX SortA(⌊SAMPX) 0→W For(I,1,dim(⌊SAMPX)) I→⌊RANK(I) End For(I,1,dim(⌊RANK)) If ⌊SAMPX(I)=⌊SAMP1(I):Then ⌊RANK(I)→W U-W→U Else U-0→U If dim(⌊SAMP1)>10 and dim(⌊SAMP2)>20:Then Disp "The sample sizes allow","for the use of a simpli-","fied large sample test.","","Press 1 for a one-tailed","test or 2 for a two-","tailed test.","" Input "Which test? ",A getKey→A If A=92:Then U-(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2)→T √((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12)→B T/B→Z Disp "Press  if you wish to test","if Population 1 is","shifted to the right of","Population 2, or  if","you wish to test if Popu-","lation 1 is shifted to","left of Population 2.","" Input "Which alt. hypothesis?",A getKey→A If A=26:Then normalcdf(­199,­(Z),(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2),√((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12))→P ClrHome Disp "Please input the desired","α-level below.","" Input "α=?",A If P<A:Then ClrHome Disp "Hypothesis rejected." Disp "" Disp "U" Disp U Disp "p=" Disp P Disp "N₁" Disp dim(⌊SAMP1) Disp "N₂" Disp dim(⌊SAMP2) End Else ClrHome Disp "Failed to reject." Disp "" Disp "U" Disp U Disp "p=" Disp P Disp "N1" Disp dim(⌊SAMP1) Disp "N2" Disp dim(⌊SAMP2) End Else:If A=24:Then normalcdf(Z,199,(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2),√((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12))→P ClrHome Disp "Please input the desired","α-level below.","" Input "α=?",A If P<A:Then ClrHome Disp "Hypothesis rejected." Disp "" Disp "U" Disp U Disp "p=" Disp P Disp "N₁" Disp dim(⌊SAMP1) Disp "N₂" Disp dim(⌊SAMP2) End Else ClrHome Disp "Failed to reject." Disp "" Disp "U" Disp U Disp "p=" Disp P Disp "N1" Disp dim(⌊SAMP1) Disp "N2" Disp dim(⌊SAMP2) End Else:If A=93:Then U-(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2)→T √((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12)→B T/B→Z normalcdf(Z,199,(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2),√((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12))+normalcdf(­199,­(Z),(((dim(⌊SAMP1))*(dim(⌊SAMP2)))2),√((dim(⌊SAMP1)*dim(⌊SAMP2))*(dim(⌊SAMP1)+dim(⌊SAMP2)+1)/12))→P ClrHome Disp "Please input the desired","α-level below.","" Input "α=?",A If P<A:Then ClrHome Disp "Hypothesis rejected." Disp "" Disp "U" Disp U Disp "p=" Disp P Disp "N₁" Disp dim(⌊SAMP1) Disp "N₂" Disp dim(⌊SAMP2) End Else ClrHome Disp "Failed to reject." Disp "" Disp "U" Disp U Disp "p=" Disp P Disp "N1" Disp dim(⌊SAMP1) Disp "N2" Disp dim(⌊SAMP2) End Else ClrHome Disp "U=",U,"","N₁=",dim(⌊SAMP1),"N₂=",dim(⌊SAMP2),"Press [enter] for inter-","pretation." Pause Disp "" Disp "To find the p-value, use","a table of Mann-Whitney","U values given the above","values." End```

Code:
```End Else```

don't do that
If you're gonna have an Else, the End goes at the end of the else block like this:

Code:
```If [condition] Then [...] Else [...] End```

Regarding nesting conditionals in loops, you can do this:

Code:
```For(A,1,10) If A<5 Then [...] End End```

The first End is for the conditional and the 2nd one is for the loop.
Here's some documentation on these commands.

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.

»
» All times are UTC - 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