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.7-02 years ago74 downloads
1.6-04 years ago60 downloads
1.5-06 years ago70 downloads
1.4-06 years ago35 downloads
1.3-06 years ago47 downloads
1.2-07 years ago1,582 downloads
1.0-07 years ago1,588 downloads

Dependencies

lua >= 5.1

Labels

Manifests