by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 5.0, Creation date: 2021-01-15, Last change: 2025-08-18
See Also: , randnorm
, meanGauss
rd=randdice([])
rd: | equal distributed random numbers between 1 6 |
x=randdice(100000,1); meanGauss(x)
The function randdice generates random numbers between 1 and 6, simulating the roll of a fair six-sided die. It is part of the SolidGeometry library, version 5.0, and was created by Tim Lueth.
varargin: This allows the function to accept a variable number of input arguments, which are passed to the rand function. These arguments determine the size of the output array.rd: An array of random numbers, each between 1 and 6, with a uniform distribution.The function uses the following steps to generate the output:
rand function with the input arguments varargin. The rand function generates random numbers between 0 and 1.rand is multiplied by 6, scaling the random numbers to a range between 0 and 6.ceil function is applied to the scaled numbers, rounding them up to the nearest integer. This results in random integers between 1 and 6.An example call to the function is x=randdice(100000,1); meanGauss(x). This generates 100,000 random numbers between 1 and 6 and then calculates their mean using the meanGauss function.