crusher 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/crusher/util.rb +7 -0
- metadata +3 -3
data/lib/crusher/util.rb
CHANGED
@@ -5,6 +5,13 @@ module Crusher::Util
|
|
5
5
|
(1..6).map{ rand(min,max) }.sum / 6
|
6
6
|
end
|
7
7
|
|
8
|
+
# http://en.wikipedia.org/wiki/Poisson_distribution
|
9
|
+
def self.prand(lamb, min, max)
|
10
|
+
l, k, p = [(2.718 ** (-lamb)), 1, rand]
|
11
|
+
k += 1 and p *= rand while p > l
|
12
|
+
((k * (max - min)) + min).to_i
|
13
|
+
end
|
14
|
+
|
8
15
|
def self.lipsum(words)
|
9
16
|
(1..words).map{ DUMMY_WORDS[ rand(DUMMY_WORDS.length) ] }.join(' ')
|
10
17
|
end
|
metadata
CHANGED