Random Numbers with the Standard Normal Distribution

As RND-function in Full BASIC can be considered as a random variable that distributes uniformly over the interval[0,1), the mean of it is 1/2, and variance 1/12.
Hence, Adding 12 of them and subtracting 6 makes a random variable of mean 0 and of variance 1.

The central limit theorem insists that the sum of many random numbers normally distributes, but as for the sum of uniform random numbers, the distribution of the sum of only 12 random numbers is considerably close to the normal distribution.

Random Number with the Standard Normal Distribution
DEF nrandom=RND+RND+RND+RND+RND+RND+RND+RND+RND+RND+RND+RND-6

We can obtain the random numbers whose distribution is N(μ,σ2), that is, of mean μ and of variance σ2, by nrandom multiplying by σ and adding μ.

Supplement
Another famous method of obtaining a normal random numbers from uniform random numbers is Box-Muller method.
Example.
A program that generates 1000 random numbers with the standard normal distribution by Box-Muller method.

100 DECLARE EXTERNAL FUNCTION Box_Muller.NRandom
110 FOR k=1 TO 1000
120    PRINT USING "-%.######":NRandom
130 NEXT k
140 END
1000 MODULE Box_Muller
1010 PUBLIC FUNCTION NRandom  
1040 SHARE NUMERIC r,t,s
1090 LET s=0
1100 EXTERNAL FUNCTION NRandom
1150    IF s=0 THEN
1160       LET r=SQR(-2*LOG(1-RND))
1170       LET t=2*PI*RND
1180       LET NRandom=r*COS(t)
1190       LET s=1
1200    ELSE
1210       LET NRandom=r*SIN(t)
1220       LET s=0
1230    END IF
1240 END FUNCTION
1300 END MODULE


Note.
RANDOM.LIB included in Decimal BASIC contains some external function definitions that generate normal random numbers and so on.
Usage example.
A program that generates 20 random numbers that follows the normal distribution N(50,102).

10 DECLARE EXTERNAL FUNCTION RNDNormal
20 DECLARE NUMERIC m,s,i
30 LET m=50
40 LET s=10
50 RANDOMIZE
60 FOR i=1 TO 20
70    PRINT RNDNormal(m,s)
80 NEXT i
90 END
100 MERGE "random.lib"


RANDOM.LIB will be found in the "Library" subfolder of the folder where Decimal BASIC has been installed.


Back