RosettaCodeData/Task/Random-numbers/Pluto/random-numbers.pluto
2026-04-30 12:34:36 -04:00

15 lines
373 B
Text

require "table2"
local function rand_normal()
return math.sqrt(-2 * math.log(math.random())) * math.cos(2 * math.pi * math.random())
end
local n = 1000
local numbers = table.rep(n, 0)
local mu = 1
local sigma = 0.5
for i = 1, n do
numbers[i] = mu + sigma * rand_normal()
end
print($"Actual mean : {numbers:mean()}")
print($"Actual std dev: {numbers:stddev()}")