simple-random 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 363ac1c766742b1f03dff7f7d406a9ca39d1695b
4
- data.tar.gz: a21cbf4ea5743f61118dced735a19c7b3f78d9e4
3
+ metadata.gz: 65923da1d24e7888037400e04e8247ce5a65e223
4
+ data.tar.gz: c1340f384268823745fdaefe3f0a3b8a068539d7
5
5
  SHA512:
6
- metadata.gz: e3c6f92ca6a8f05add6f5b1fa3e56320f1b45b6d071b7b390985ae41b73a8a3397d4f769cffdc206290df75ecccb16ee44829bb76b5c89452939232e99ab4dce
7
- data.tar.gz: 57eaf888e134eb1a5db172cdf67866581f6f0c0690ada869de7ce766cd060851958d16a4dbb948dfda314c8144f2884d93de8bc4f5e7b538dd688f8f0051fb4c
6
+ metadata.gz: 99f369a1a00047572b031eae49326f458a2afa8944c8ccfeb03f02872ea1bedfed70939631ee84ce72aee9eabdcdf062e4911ba71f41d0f8dcaf7e8f8da7d271
7
+ data.tar.gz: 9750c6caa2986f42a77333c87f9c6d436c49c9fc5282f77d61f8b9cb1eb6a6fe874bf097b72a623c0101fdb295ceb0093ff1c348a6c0dd01f69ec26f7e2fd428
data/README.md CHANGED
@@ -68,12 +68,15 @@ Distributed under the Code Project Open License, which is similar to MIT or BSD.
68
68
 
69
69
  ## History
70
70
 
71
+ ### 1.0.2 - 2015-11-24
72
+ * Merge pull request from [cunchem](https://github.com/cunchem) to fix Laplace method
73
+
71
74
  ### 1.0.1 - 2015-07-31
72
- * Merge purcell's changes to fix numeric seeds
75
+ * Merge [purcell](https://github.com/purcell)'s changes to fix numeric seeds
73
76
 
74
77
  ### 1.0.0 - 2014-07-08
75
78
  * Migrate to new version of Jeweler for gem packaging
76
- * Merge jwroblewski's changes into a new multi-threaded simple random class
79
+ * Merge [jwroblewski](https://github.com/jwroblewski)'s changes into a new multi-threaded simple random class
77
80
  * Change from Code Project Open License to [CDDL-1.0](http://opensource.org/licenses/CDDL-1.0)
78
81
 
79
82
  ### 0.10.0 - 2014-03-31
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -118,8 +118,9 @@ class SimpleRandom
118
118
  end
119
119
 
120
120
  def laplace(mean, scale)
121
- u = uniform
122
- mean + Math.log(2) + ((u < 0.5 ? 1 : -1) * scale * Math.log(u < 0.5 ? u : 1 - u))
121
+ u_1 = uniform
122
+ u_2 = uniform
123
+ mean + ((u_1 < 0.5 ? 1 : -1) * scale * Math.log( 1-2*(u_2-0.5).abs))
123
124
  end
124
125
 
125
126
  def log_normal(mu, sigma)
@@ -6,12 +6,12 @@
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "simple-random"
9
- s.version = "1.0.1"
9
+ s.version = "1.0.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["John D. Cook", "Jason Adams"]
14
- s.date = "2015-07-31"
14
+ s.date = "2015-11-24"
15
15
  s.description = "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."
16
16
  s.email = "jasonmadams@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -66,4 +66,3 @@ Gem::Specification.new do |s|
66
66
  s.add_dependency(%q<simplecov>, [">= 0"])
67
67
  end
68
68
  end
69
-
@@ -192,6 +192,15 @@ class TestSimpleRandom < MiniTest::Test
192
192
  assert epsilon < MAXIMUM_EPSILON
193
193
  end
194
194
 
195
+ should "generate random numbers from laplace(0, 1) with mean approximately 0" do
196
+ mean = 0.0
197
+ scale = 0.1
198
+ numbers = generate_numbers(@r, :laplace, mean, scale)
199
+ epsilon = (mean - numbers.mean).abs
200
+
201
+ assert epsilon < MAXIMUM_EPSILON
202
+ end
203
+
195
204
  should "generate a random number sampled from a gamma distribution" do
196
205
  assert @r.gamma(5, 2.3)
197
206
  end
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: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John D. Cook
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-31 00:00:00.000000000 Z
12
+ date: 2015-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  requirements: []
141
141
  rubyforge_project:
142
- rubygems_version: 2.2.2
142
+ rubygems_version: 2.4.5.1
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: Simple Random Number Generator