randdice

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

same as rand but only numbers between 1 and 6



See Also: , randnorm , meanGauss

Example Illustration

 missing image of randdice()

Syntax

rd=randdice([])

Output Parameter

rd: equal distributed random numbers between 1 6

Examples


x=randdice(100000,1); meanGauss(x)




Copyright 2021-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

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.

Input Parameters

Output

Algorithm Explanation

The function uses the following steps to generate the output:

  1. It calls the rand function with the input arguments varargin. The rand function generates random numbers between 0 and 1.
  2. The result from rand is multiplied by 6, scaling the random numbers to a range between 0 and 6.
  3. The ceil function is applied to the scaled numbers, rounding them up to the nearest integer. This results in random integers between 1 and 6.

Example Usage

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.

Algorithm explaination created using ChatGPT on 2025-08-18 21:58. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21