How to resolve the algorithm Random numbers step by step in the MiniScript programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Random numbers step by step in the MiniScript programming language

Table of Contents

Problem Statement

Generate a collection filled with   1000   normally distributed random (or pseudo-random) numbers with a mean of   1.0   and a   standard deviation   of   0.5 Many libraries only generate uniformly distributed random numbers. If so, you may use one of these algorithms.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Random numbers step by step in the MiniScript programming language

Source code in the miniscript programming language

randNormal = function(mean=0, stddev=1)
    return mean + sqrt(-2 * log(rnd,2.7182818284)) * cos(2*pi*rnd) * stddev
end function

x = []
for i in range(1,1000)
    x.push randNormal(1, 0.5)
end for


  

You may also check:How to resolve the algorithm Function definition step by step in the NetRexx programming language
You may also check:How to resolve the algorithm Multi-dimensional array step by step in the Java programming language
You may also check:How to resolve the algorithm Remove duplicate elements step by step in the Neko programming language
You may also check:How to resolve the algorithm String length step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Rosetta Code/Rank languages by number of users step by step in the Julia programming language