>> randn_test 11-Jun-2012 15:59:20 RANDN_TEST: MATLAB version Test the MATLAB RAND function. RANDN_TEST01: In MATLAB, normal random numbers are generated by calling RANDN: A = randn ( ) a random scalar value. B = randn ( 5, 1 ) a random column vector of 5 entries. C = randn ( 1, 5 ) a random row vector of 5 entries. D = randn ( 3, 4 ) a 3 by 4 random matrix. E = randn ( 5 ) a 5 by 5 random matrix. a = -1.6699 b = -0.2378 0.6066 0.3426 0.9475 0.9660 c = 1.6660 0.6552 0.3896 1.3801 -1.0473 d = -0.9271 -0.9132 -0.4576 -1.2220 -0.9434 0.1850 0.1884 -0.7943 0.2594 0.2361 -1.3579 1.5094 e = 0.5062 -1.5806 0.4548 0.9239 2.0445 -0.1600 -1.0477 0.8903 -1.1909 1.8474 0.9218 -1.5473 -0.3863 0.6032 0.7629 -1.4246 0.6133 -1.2991 -1.8730 0.2962 0.6315 1.6859 -1.0043 1.5803 0.2831 RANDN_TEST02: By setting the random number seed, you can control how the random number sequence begins. The command "rng ( 123456789 )" sets the seed to 123456789. Seed has been set to 123456789 Now generate 5 random values. RANDN() = 0.2265 RANDN() = 0.0256107 RANDN() = 0.0376636 RANDN() = 0.364848 RANDN() = -1.05838 Seed has been reset to 123456789 Now generate 5 more random values. RANDN() = 0.2265 RANDN() = 0.0256107 RANDN() = 0.0376636 RANDN() = 0.364848 RANDN() = -1.05838 RANDN_TEST02: By setting the random number seed, you can control how the random number sequence begins. The command "rng ( 123456789 )" sets the seed to 123456789. Seed has been set to 123456789 Now generate 5 random values. RANDN() = 0.2265 RANDN() = 0.0256107 RANDN() = 0.0376636 RANDN() = 0.364848 RANDN() = -1.05838 Seed has been reset to 123456789 Now generate 5 more random values. RANDN() = 0.2265 RANDN() = 0.0256107 RANDN() = 0.0376636 RANDN() = 0.364848 RANDN() = -1.05838 RANDN_TEST02: By setting the random number seed, you can control how the random number sequence begins. The command "rng ( 123456789 )" sets the seed to 123456789. Seed has been set to 123456789 Now generate 5 random values. RANDN() = 0.2265 RANDN() = 0.0256107 RANDN() = 0.0376636 RANDN() = 0.364848 RANDN() = -1.05838 Seed has been reset to 123456789 Now generate 5 more random values. RANDN() = 0.2265 RANDN() = 0.0256107 RANDN() = 0.0376636 RANDN() = 0.364848 RANDN() = -1.05838 RANDN_TEST03: Compute a lot of random values. The average should be 0.0 The variance should be 1. N Ave Var 1 0.326832 0.000000 10 0.018427 1.383352 100 0.067092 1.006473 1000 0.023507 0.957141 10000 0.008770 0.996067 100000 -0.000765 1.005725 1000000 -0.000553 1.000134 10000000 0.000093 0.999422 RANDN_TEST: Normal end of execution. 11-Jun-2012 15:59:20 >>