home *** CD-ROM | disk | FTP | other *** search
- WINDOW 1,"Unary Data Set Statistics",(0,0)-(640,200),31+256
-
- LIBRARY "requester.library"
- DECLARE FUNCTION DoFileIOWindow&() LIBRARY
- DECLARE FUNCTION GetFileIO&() LIBRARY
- DECLARE FUNCTION AutoFileMessage() LIBRARY
-
- ' subroutine to call file requestor from the requester.library.
-
- ' ireqx,ireqy x and y coordinates for the requestor
- ' WindowTitle$ a title displayed in the requestor's title bar
- ' Values returned by the subroutine:
- ' PathName$ full path for selected file
- ' FileName$ file name only
- ' VolName$ the volume name or drive id
- ' DrawerName$ drawer name or subdirectory
- ' DiscOrDir% returns 1 if selection is a drive or directory only
- ' NoExist% returns 1 if file does not exist
- ' flag% returns 0 if request fails and 1 if successful
- ' Reason$ short message explaining failure
- '
- SUB requestor(ireqx,ireqy,WindowTitle$,PathName$,FileName$,VolName$,DrawerName$,DiscOrDir%,NoExist%,flag%,reason$)
- LOCAL i
- DEFINT i
- DiscOrDir%=0 : NoExist%=0 : flag%=0
- PathName$="" : FileName$="" : VolName$="" : DrawerName$=""
- reason$=""
- PathBuffer$=SPACE$(202)
- ExtPtrBuff$=SPACE$(24)
- FileIO&=GetFileIO&()
- IF FileIO&=0 THEN
- CALL ReleaseFileIO&(FileIO&)
- flag%=0
- reason$="FileIO Failed"
- EXIT SUB
- END IF
- POKEL FileIO&+248,SADD(PathBuffer$)
- POKEL FileIO&+222,SADD(ExtPtrBuff$)
- POKEL FileIO&+244,SADD(WindowTitle$+CHR$(0))
- POKE FileIO&+261,1
- POKE FileIO&+262,1
- POKE FileIO&+263,0
- POKEW FileIO&+232,ireqx
- POKEW FileIO&+234,ireqy
- POKE FileIO&+1,4
- extsize&=LEN(ext$)
- POKE FileIO&+1,128
- result&=DoFileIOWindow&(FileIO&,0&)
- IF result&=-1 THEN
- CALL ResetTitle(FileIO,WINDOW(7))
- CALL ReleaseFileIO(FileIO)
- flag%=0
- reason$="Cancel"
- EXIT SUB
- END IF
- IF result&=0 THEN
- result&=AutoFileMessage&(0&,WINDOW(7))
- INPUT "Type path: ";PathName$
- CALL ParseString&(FileIO&,SADD(PathName$+CHR$(0)))
- GOTO CopyFN
- END IF
-
- pathname$ = ""
- FOR i = 0 TO 202
- value = PEEK(SADD(PathBuffer$)+i)
- IF value = 0 THEN EXIT FOR
- char$ = CHR$(value)
- pathname$ = pathname$+char$
- NEXT i
-
- CopyFN: 'Copy out the Filename to Filename$.
- FileName$ = ""
- FOR i = 0 TO 30
- value = PEEK(FileIO&+2+i)
- IF value = 0 THEN EXIT FOR
- char$ = CHR$(value)
- FileName$ = FileName$+char$
- NEXT i
-
- CopyDrawer: 'Copy out all the drawers
- DrawerName$ = ""
- FOR i = 0 TO 132
- value = PEEK(FileIO&+32+i)
- IF value = 0 THEN EXIT FOR
- char$ = CHR$(value)
- DrawerName$ = DrawerName$+char$
- NEXT i
-
- CopyVol: 'Copy out the diskname
- VolName$ = ""
- FOR i = 0 TO 30
- value = PEEK(FileIO&+164+i)
- IF value = 0 THEN EXIT FOR
- char$ = CHR$(value)
- VolName$ = VolName$+char$
- NEXT i
-
- extsize&=LEN(FileName$)
- IF extsize&=0 THEN DiscOrDir%=1
- IF PEEKL(FileIO&+240)=0 THEN NoExist%=1
- CALL ResetTitle&(FileIO&,WINDOW(7))
- CALL ReleaseFileIO&(FileIO&)
- flag%=1
- END SUB
-
- 'subroutine to print message at line linenum1%, then wait for key press
- 'key press message is printed at line linenum2%
-
- SUB message (VAL linenum1%, VAL linenum2%, VAL m$)
- LOCATE linenum1%,INT((80-LEN(m$))/2) : ?m$;
- LOCATE linenum2%,27,0 : ?"Press any key to continue";
- DO
- IF INKEY$<>"" THEN EXIT LOOP
- SLEEP
- LOOP
- CLS : LOCATE 1,1,1
- END SUB
-
- 'subroutine to ask if user wants to continue
- 'returns flag%=0 if no, flag%=1 if yes
-
- SUB continue (flag%)
- local t$ : t$="" : flag% = 0
- WHILE t$<>"YES" AND t$<>"NO" AND t$<>"Y" AND t$<>"N"
- CLS : LOCATE 12,32 : INPUT "Try again? ",t$
- t$=UCASE$(t$)
- IF t$="YES" OR t$="Y" THEN
- flag%=1 : EXIT SUB
- END IF
- IF t$="NO" OR t$="N" THEN
- flag%=0 : EXIT SUB
- END IF
- WEND
- END SUB
-
- 'print instructions
-
- CLS
- ?
- ?"This program will allow you to select a data file, and then calculate"
- ?" statistical parameters, such as mean, average deviation, variance,"
- ?" standard deviation, skewness, and kurtosis. The data file MUST be"
- ?" of a certain format."
- ?
- ?" WARNING: This program will NOT accept files that do not conform to"
- ?" the expected format!"
- ?
- ?"The format is the number of data points (MUST be an integer) followed"
- ?" by the data points, which may be arranged horizontally, vertically,"
- ?" or a combination of the two. For example, to calculate the statistical"
- ?" parameters of 7.22, 4.56, 3.22, and 1.23 the following files are"
- ?" acceptable:"
- ?
- ?" 4 7.22 4.56 3.22 1.23"
- ?
- ?" OR"
- ?
- ?" 4 7.22 4.56"
- ?" 3.22 1.23"
- ?
- message 23,23,""
- CLS
- ? : ? : ?
- ?"You may use your favorite word processor, spreadsheet, or whatever to"
- ?" generate the data file. However, the file MUST be in ASCII. This"
- ?" is actually pretty simple--it usually just means selecting the"
- ?" ""general"" option when saving the file from your word processor, or"
- ?" the ""print to file"" option when saving the file from your"
- ?" spreadsheet."
- ?
- ?"Note: the program does not care about spaces in a file. It DOES however"
- ?" care about carriage returns, and will treat them as zeros. IF YOU"
- ?" HAVE EXTRA CARRIAGE RETURNS IN YOUR DATA FILE, DELETE THEM PRIOR TO"
- ?" RUNNING THIS PROGRAM!"
- message 19,23,"Happy Analyzing! C. Niederberger 2/91"
-
- start: CLS
-
- DEFDBL D
- DEFINT i-k,n
-
- CALL requestor (10,10,"Select Data File",Name$,f$,v$,d$,dod%,ne%,f%,r$)
-
- IF dod%=1 OR ne%=1 OR f%=0 THEN
- CLS : message 11,13,"File lookup failed: "+r$
- continue flg%
- IF flg%=0 THEN GOTO finish ELSE GOTO start
- END IF
-
- OPEN Name$ FOR INPUT AS #1
-
- 'load data array with data from file
-
- INPUT #1,Dn 'n = Dn = total number of data points
-
- n=INT(Dn)
- IF Dn<>n THEN
- CLS : message 11,13,"n is not an integer!"
- continue flg%
- IF flg%=0 THEN
- GOTO finish
- ELSE
- ERASE Ddata
- GOTO start
- END IF
- END IF
-
- DIM Ddata(n)
-
- FOR i=1 TO n
- IF EOF(1) THEN
- CLS : message 11,13,"Not enough data for n!"
- continue flg%
- IF flg%=0 THEN
- GOTO finish
- ELSE
- ERASE Ddata
- GOTO start
- END IF
- END IF
- INPUT #1,Ddata(i)
- NEXT i
-
- IF NOT EOF(1) THEN
- CLS : message 11,13,"Too much data for n!"
- continue flg%
- IF flg%=0 THEN
- GOTO finish
- ELSE
- ERASE Ddata
- GOTO start
- END IF
- END IF
-
- CLOSE #1
-
- 'sum all data
-
- Ds=0
-
- FOR j=1 TO n
- Ds=Ds+Ddata(j)
- NEXT j
-
- 'calculate average, and set other results to 0
-
- ? : ? : ? : ?
- Dave=Ds/n : ?" mean is "Dave
- Dadev=0
- Dsvar=0
- Dskew=0
- Dcurt=0
-
- 'now calculate other results
-
- FOR j=1 TO n
- Ds=Ddata(j)-Dave
- Dadev=Dadev+ABS(Ds)
- Dp=Ds*Ds
- Dsvar=Dsvar+Dp
- Dp=Dp*Ds
- Dskew=Dskew+Dp
- Dp=Dp*Ds
- Dcurt=Dcurt+Dp
- NEXT j
-
- Dadev=Dadev/n : ?" average deviation is "Dadev
- Dsvar=Dsvar/(n-1) : ?" variance is "Dsvar
- Dsdev=SQR(Dsvar) : ?" standard deviation is "Dsdev
-
- IF Dsvar<>0 THEN
- Dskew=Dskew/(n*Dsdev^3) : ?" skew is "Dskew
- Dcurt=Dcurt/(n*Dsvar^2)-3 : ?" kurtosis is "Dcurt
- ELSE
- PRINT " No skew or kurtosis when variance = 0"
- END IF
-
- 'after results display, wait for user entry
-
- LOCATE 13,27,0 : ?"Press any key to continue"
- DO
- IF INKEY$<>"" THEN EXIT LOOP
- SLEEP
- LOOP
-
- continue flg%
- IF flg%=0 THEN
- GOTO finish
- ELSE
- ERASE Ddata
- GOTO start
- END IF
-
- finish: WINDOW CLOSE 1
- STOP
-
-
-
-