stan_dev.abm (Not Module Specific)

1              REM ***

2              REM Example to Calculate Standard Deviation on an Array

3              REM —

4              REM Steps are as follows

5              REM 1. Find arithmetic mean of the set of numbers

6              REM 2. Subtract the mean from each number of the set

7              REM 3. Square the differences

8              REM 4. Find arithmetic mean of these squares

9              REM 5. Find the Square Root of the last arithmetic mean

10           REM ***

11           DIM NUMS(10)

20           REM Init Array containing set of numbers

22           NUMS(1)=1 : NUMS(2)=5 : NUMS(3)=4 : NUMS(4)=2 : NUMS(5)=6

24           NUMS(6)=2 : NUMS(7)=1 : NUMS(8)=1 : NUMS(9)=5 : NUMS(10)=3

30           REM Calc Mean of the Set

32           SM=0 : MN=0

34           FOR X=1 TO 10

36           SM=SM+NUMS(X)

37           REM PRINT1 “NUMS(“,X,”) =”,NUMS(X)

38           NEXT X

40           MN=SM/10 :  PRINT1 “Sum1=”,SM,” Mean1=”,MN

50           REM Subtract Mean from Each number of the Set,

51           REM Then Square and Replace, Then Sum and Calc Mean

52           SM=0

54           FOR X=1 TO 10

56           NUMS(X)=ABS((NUMS(X)-MN)) :  REM Subtract Mean from Each Num of Set 

57           NUMS(X)=NUMS(X)**2 :  REM Square Each Num of Set 

58           SM=SM+NUMS(X) :  REM Sum the Set 

59           REM PRINT1 “NUMS(“,X,”) =”,NUMS(X)

60           NEXT X

62           MN=SM/10 :  PRINT1 “Sum2=”,SM,” Mean2=”,MN

70           REM Calc Square Root

72           SD=0

74           SD=SQR(MN)

76           PRINT1 “Standard Deviation = “,SD

×