randomdist

a few simple procedures for generating random numbers.

$ luarocks install randomdist

local R = require 'randomdist'

-- Gaussian (or Normal) Distribution
grand1 = R.new_grand(10,3) -- (mean,stddev)
grand2 = R.new_grand(100,3)
for i = 1,20 do print( grand1(), grand2() ) end

-- Gaussian Random Ensemble
gue_irand1 = R.new_gue_irand(4) -- (mean)
gue_irand2 = R.new_gue_irand(20)
for i=1,20 do print( gue_irand1(), gue_irand2() ) end

-- Rayleigh Distribution
for i=1,20 do print(R.rayleigh_rand(3)) end

-- random get from an array
a = {'cold', 'cool', 'warm', 'hot'}
for i = 1,20 do print(R.randomget(a)) end

-- Zipf distributions
word2count = { the=983, ['and']=421, of=340, to=286, I=263, it=252, } --etc
s, stddev = R.wordcount2zipf(word2count)
eo_words = {'la', 'kaj', 'de', 'al', 'mi', 'gxi'}
random_word = R.new_zipf(eo_words, s)
for i = 1,1000 do print(random_word()) end

Versions

1.5-01 year ago26 downloads
1.4-01 year ago0 downloads
1.3-01 year ago12 downloads
1.2-02 years ago17 downloads
1.0-02 years ago14 downloads

Dependencies

lua >= 5.1, < 5.4

Labels

Manifests