added table.shuffle()

This commit is contained in:
Heng Li 2011-04-06 12:19:14 -04:00
parent 1f2ef7afd5
commit 54004e39cf
1 changed files with 8 additions and 0 deletions

View File

@ -39,6 +39,7 @@
string:split()
io.xopen()
table.ksmall()
table.shuffle()
math.lgamma() >math.lbinom() >math.igamma()
math.igamma() <math.lgamma() >matrix.chi2()
math.erfc()
@ -163,6 +164,13 @@ function table.ksmall(arr, k)
end
end
function table.shuffle(a)
for i = #a, 1, -1 do
local j = math.random(i)
a[j], a[i] = a[i], a[j]
end
end
--
-- Mathematics
--