crusher 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/crusher/util.rb +7 -0
  2. 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
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crusher
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - phene