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-013 days ago0 downloads
1.6-01 year ago33 downloads
1.5-03 years ago43 downloads
1.4-03 years ago8 downloads
1.3-03 years ago20 downloads
1.2-04 years ago25 downloads
1.0-04 years ago22 downloads

Dependencies

lua >= 5.1

Labels

Manifests