simple-random 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -5,7 +5,9 @@ Generate random numbers sampled from the following distributions:
5
5
  * Beta
6
6
  * Cauchy
7
7
  * Chi square
8
+ * Dirichlet
8
9
  * Exponential
10
+ * Gamma
9
11
  * Inverse gamma
10
12
  * Laplace (double exponential)
11
13
  * Normal
@@ -28,3 +30,14 @@ Based on John D. Cook's SimpleRNG[http://www.codeproject.com/KB/recipes/SimpleRN
28
30
  == Copyright
29
31
 
30
32
  Distributed under the Code Project Open License, which is similar to MIT or BSD. See LICENSE for full details (don't just take my word for it that it's similar to those licenses).
33
+
34
+ == History
35
+
36
+ === 0.9.3 - 2011-09-16
37
+ * Sample from Dirichlet distribution with given set of parameters
38
+
39
+ === 0.9.2 - 2011-09-06
40
+ * Use microseconds for random seed
41
+
42
+ === 0.9.1 - 2010-07-27
43
+ * First stable release
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.2
1
+ 0.9.3
data/lib/simple-random.rb CHANGED
@@ -113,6 +113,12 @@ class SimpleRandom
113
113
  Math.exp(normal(mu, sigma))
114
114
  end
115
115
 
116
+ def dirichlet(*parameters)
117
+ sample = parameters.map { |a| gamma(a, 1) }
118
+ sum = sample.inject(0.0) { |sum, g| sum + g }
119
+ sample.map { |g| g / sum }
120
+ end
121
+
116
122
  private
117
123
 
118
124
  # This is the heart of the generator.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{simple-random}
8
- s.version = "0.9.2"
8
+ s.version = "0.9.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{John D. Cook}, %q{Jason Adams}]
12
- s.date = %q{2011-09-06}
12
+ s.date = %q{2011-09-17}
13
13
  s.description = %q{Simple Random Number Generator including Beta, Cauchy, Chi square, Exponential, Gamma, Inverse Gamma, Laplace (double exponential), Normal, Student t, Uniform, and Weibull. Ported from John D. Cook's C# Code.}
14
14
  s.email = %q{jasonmadams@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
29
29
  ]
30
30
  s.homepage = %q{http://github.com/ealdent/simple-random}
31
31
  s.require_paths = [%q{lib}]
32
- s.rubygems_version = %q{1.8.7}
32
+ s.rubygems_version = %q{1.8.6}
33
33
  s.summary = %q{Simple Random Number Generator}
34
34
 
35
35
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-random
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-09-06 00:00:00.000000000Z
13
+ date: 2011-09-17 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: shoulda
17
- requirement: &2160292400 !ruby/object:Gem::Requirement
17
+ requirement: &23585180 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *2160292400
25
+ version_requirements: *23585180
26
26
  description: Simple Random Number Generator including Beta, Cauchy, Chi square, Exponential,
27
27
  Gamma, Inverse Gamma, Laplace (double exponential), Normal, Student t, Uniform,
28
28
  and Weibull. Ported from John D. Cook's C# Code.
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  version: '0'
63
63
  requirements: []
64
64
  rubyforge_project:
65
- rubygems_version: 1.8.7
65
+ rubygems_version: 1.8.6
66
66
  signing_key:
67
67
  specification_version: 3
68
68
  summary: Simple Random Number Generator