rngInitialising the built-in random number generator
rng(seed)seed should be a non-negative integer scalar.seed) using the algorithm discussed in William H. Press, Numerical Recipes, 3rd edition, Cambridge University Press, 2007, p. 342.randi, normrnd, exprnd, poissrnd) utilise the same generator, executing rng(seed) would simultaneously reset all of the functions to the initial state determined by seed.seed is the current time, i.e., number of seconds since 00:00:00 UTC, January 1, 1970. The default seed is used when no existing seed can be found. This usually happens the app launches for the first time after a fresh installation. rng or by uninstalling the app.rand() generates the same sequence of pseudo random numbers. When it is initialised with a different number, a different sequence is generated.rng(17)
rand(1,5)
rng(17)
rand(1,5)
% Different seed number
rng(16)
rand(1,5)
ans = 1e-1 ×
0.1463 4.0537 8.8335 9.2374 2.6807
ans = 1e-1 ×
0.1463 4.0537 8.8335 9.2374 2.6807
ans = 1e-1 ×
2.6321 9.6424 8.6923 0.1035 3.6630
rng(seed, generator) and s = rng are not available in this app.