Hi! This is my first forum post on Cemetech Very Happy .I've been working on this sample skewness & kurtosis formula program, but after a certain point during execution, the calculator returns a syntax error and brings me to line 2. Does anybody have any advice on how to fix this? Thanks!


Code:
ClrHome
Output(6,11,"SKEWNESS")
Output(6,9,"& KURTOSIS")
Output(10,9,"By StatMan")
Pause
ClrHome
Disp "Input your list of data","below."
Disp ""
Disp "To input your list,","press [2nd][stat] to find it","and press [enter]."
Disp ""
Prompt ⌊XKURT
ClrHome
Disp "Note: Both analyses use the"
Disp "formulae for unweighted"
Disp "sample and all formulae are"
Disp "from SPSS."
dim(⌊XKURT)→N
((sum((⌊XKURT-mean(⌊XKURT))^2))/(N-1))→V
√(V)→S
Pause
ClrHome
Menu("Samp. Skewness & Kurtosis","Wait, What?",1,"Sample Skewness",2,"Sample Kurtosis",3,"Quit",4)

Lbl 1
ClrHome
Stop

Lbl 2
Disp "Note: Skewness inter-"
Disp "pretation is based on the"
Disp "rule of thumb suggested in"
Disp "M.G. Bulmer's Principle of"
Disp "Statistics, written in"
Disp "1979."
N*(sum((⌊XKURT-mean(⌊XKURT))^3))→T
(N-1)*(N-2)*(S^3)→B
T/B→S
6*N*(N-1)→T
(N-2)*(N+1)*(N+3)→B
√(T/B)→E
If S>1 or S<-1:Then
ClrHome
Disp "Skewness (g1)="
Disp S
Disp "Standard Error="
Disp E
Disp ""
Disp "The distribution is"
Disp "highly skewed."
Else:If -1≤S≤-0.5 or 0.5≤S≤1:Then
ClrHome
Disp "Skewness (g1)="
Disp S
Disp "Standard Error="
Disp E
Disp ""
Disp "The distribution is"
Disp "moderately skewed."
Else:If -0.5<S<0.5:Then
Disp "Skewness (g1)="
Disp S
Disp "Standard Error="
Disp E
Disp ""
Disp "The distribution is"
Disp "approximately symmetric."
Else
Stop

Lbl 3
Disp "Note: SPSS only calculates"
Disp "excess kurtosis."
N*(N+1)*(sum((⌊XKURT-mean(⌊XKURT))^4))→L
3*(sum((⌊XKURT-mean(⌊XKURT))^2))*(sum((⌊XKURT-mean(⌊XKURT))^2))*(N-1)→R
L-R→T
(N-1)*(N-2)*(N-3)*(S^4)→B
T/B→K
6*N*(N-1)→T
(N-2)*(N+1)*(N+3)→B
√(T/B)→E
If K>0:Then
ClrHome
Disp "Skewness (g1)="
Disp K
Disp "Standard Error="
Disp E
Disp ""
Disp "The distribution is"
Disp "leptokurtic."
Else:If K<0:Then
ClrHome
Disp "Skewness (g1)="
Disp K
Disp "Standard Error="
Disp E
Disp ""
Disp "The distribution is"
Disp "platykurtic."
Else
ClrHome
Disp "Skewness (g1)="
Disp K
Disp "Standard Error="
Disp E
Disp ""
Disp "The distribution is"
Disp "mesokurtic."
Stop
I haven't gone though the whole thing with a magnifying glass but I can see a few potential issues.
  • Lbl 4 is missing which will throw a Label error if you select it.
  • If the list contains 1 data point, you will get a divide by zero error, so you should probably check for that
  • I'm not sure about this, but is it possible you are using the wrong "-" symbol for things like "S<-1"? (There is a subtraction symbol and a negative symbol and they are not interchangeable) That would throw a syntax error if used incorrectly...
  • "press [2nd][stat] to find it" is slightly too long and will get chopped off on the homescreen. The homescreen is 26 characters wide.
  • There is no End to your Ifs... When you open a conditional block with an IF statement, you have to put an End so that the calc knows exactly what to execute conditionally.

For example:

Code:
If A=3
Then
A+1->A
Else
A-1->A
End

Of course, the Else is optional.
Just as an additional note, you should avoid using Stop in your program and instead prefer the Return token. Also welcome to Cemtech! Very Happy
  
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
Page 1 of 1
» All times are GMT - 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

 

Advertisement