summaryrefslogtreecommitdiff
path: root/info/maad/pgm4.bas
blob: 799fcf0bff5a113319953841f753bb98d1bf08df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
100 DEFDBL A-H, O-Z
110 INPUT "Number of points, Correlation Coefficient "; P, R
130 IF (P < 4) THEN PRINT "Number of points too small": GOTO 110
140 DEF FNA (x AS DOUBLE) = (1 - x * x) ^ ((P - 4!) / 2!)
150 A = 0!: B = 1!: N = 256: SUM = 0!: H = (B - A) / N
160 FOR I = 1 TO N STEP 2
170 SUM = SUM + FNA(A + (I - 1) * H)
180 SUM = SUM + 4! * FNA(A + I * H)
190 SUM = SUM + FNA(A + (I + 1) * H)
200 NEXT I: REM N = 256 gives accuracy to 5 decimal places.
220 PSUM = SUM * H / 3!
240 A = R: B = 1!
250 SUM = 0!:  H = (B - A) / N
260 FOR I = 1 TO N STEP 2
270 SUM = SUM + FNA(A + (I - 1) * H)
280 SUM = SUM + 4! * FNA(A + I * H)
290 SUM = SUM + FNA(A + (I + 1) * H)
300 NEXT I
310 RSUM = 100! * (SUM * H / 3!) / PSUM
320 PRINT USING "Probability |r| >= r_0 is ##.#%"; RSUM