home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG055.ARC
/
STANDEV.BAS
< prev
next >
Wrap
BASIC Source File
|
1979-12-31
|
3KB
|
118 lines
5 REM
10 REM standard deviation program main
15 REM By Ralph Johnson 1-1982
16 REM
20 GOSUB 500 REM setup and title
30 GOSUB 1000 REM inputs
40 GOSUB 1500 REM standard deviation
50 GOSUB 2000 REM data rejection
60 GOSUB 2500 REM output
70 INPUT"Do you have more data (y/n)"; LOOP$
80 IF LOOP$ = "n" OR LOOP$="N"THEN GOTO 100
90 GOSUB 3000 REM reset
95 GOTO 30
100 STOP
110 REM end main
120 REM
500 REM setup and titles
510 DIM A(50),B(50): PRINT CHR$(&H1A)
520 PRINT"************ Standard Deviation ************"
530 PRINT:PRINT
540 PRINT" This program will give the mean and "
550 PRINT"standard deviation of a set of data. It will"
560 PRINT"also reject bad data according to Chuavenet's"
565 PRINT "criteria on your direction."
570 PRINT: PRINT "Number of entries is limited to 50. See text."
580 PRINT:PRINT:PRINT
590 INPUT"Hit return to begin";A$
600 PRINT CHR$(&H1A)
610 RETURN
620 REM end setup and titles
630 REM
1000 REM inputs
1010 INPUT"How many data points are there";N%
1020 PRINT CHR$(&H1A)
1030 PRINT"Now enter the data":PRINT:PRINT
1040 FOR I%=1 TO N%
1050 PRINT"x(";I%;")";
1060 INPUT A(I%)
1070 B(I%)=A(I%)
1080 NEXT I%
1090 REM corrections
1100 PRINT CHR$(&H1A)
1110 PRINT "This is the entered data":PRINT
1120 FOR I%=1 TO N%
1130 PRINT I%,A(I%)
1140 IF I%/20<>INT(I%/20) THEN GOTO 1160
1150 INPUT"Hit enter to continue";A$
1160 NEXT I%
1170 INPUT"Is there any bad data (y/n)"; FLAG$
1180 IF FLAG$ <> "y" AND FLAG$ <> "Y" THEN GOTO 1260
1190 INPUT "How many points";BAD%
1200 FOR I%=1 TO BAD%
1210 INPUT"Enter the loc. of one bad number";J%
1220 INPUT"Enter the correct number";A(J%)
1230 B(J%)=A(J%)
1240 NEXT I%
1250 GOTO 1100
1260 RETURN
1270 REM End inputs
1280 REM
1500 REM Standard Deviation
1510 SD=0
1520 XB=0
1530 FOR I%=1 TO N%
1540 XB=B(I%)/N%+XB
1550 NEXT I%
1560 FOR I%=1 TO N%
1570 SD=(B(I%)-XB)^2/(N%-1)+SD
1580 NEXT I%
1590 SD=SD^.5
1600 PRINT CHR$(&H1A): PRINT: PRINT
1610 PRINT "The mean of this data is:";XB
1620 PRINT "Standard deviation is :";SD
1630 RETURN
1640 REM End standard deviation
1650 REM
2000 REM Data rejection
2010 PRINT:PRINT
2020 INPUT"Do you want to check for bad data (y/n)";DR$
2030 IF DR$="n" OR DR$="N" THEN RETURN
2040 XS=-6.54032E-07*N%^4+8.67668E-05*N%^3
-4.30534E-03*N%^2+.106983*N%+1.235
2050 MA=B(1)
2060 MT=MA
2070 FOR K%=2 TO N%
2080 IF B(K%)>MA THEN MA=B(K%) :K1%=K%
2090 IF B(K%)<MT THEN MT=B(K%) :K2%=K%
2100 NEXT K%
2110 D1=(MA-XB)/SD
2120 D2=(XB-MT)/SD
2125 R1$=" ": R2$=" "
2130 IF D1>XS THEN PRINT B(K1%);"is bad","x/s=";D1, "x/s max=";XS ELSE GOTO 2150
2140 INPUT"Do you want to reject this pt. (y/n)";R1$
2150 IF D2>XS THEN PRINT B(K2%);"is bad","x/s=";D2,"x/s max=";XS ELSE GOTO 2170
2160 INPUT"Do you want to reject this pt. (y/n)";R2$
2170 IF R1$<>"y" AND R1$<>"Y"THEN GOTO 2210
2180 B(K1%)=B(N%)
2190 B(N%)=0
2200 N%=N%-1
2210 IF R2$<>"y" AND R2$<>"Y"THEN GOTO 2250
2220 B(K2%)=B(N%)
2230 B(N%)=0
2240 N%=N%-1
2250 IF R1$="y" OR R2$="y" OR R1$="Y" OR R2$="Y"
THEN GOSUB 1500 ELSE GOTO 2270
2260 GOTO 2000
2270 PRINT"No bad data"
2275 RETURN
2290 REM end data reject
2300 REM
2500 RETURN
3000 REM Reset
3010 FOR I%= 1 TO 50
3020 A(I%)=0
3030 B(I%)=0
3040 NEXT I%
3050 RETURN