random_variates 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/random_variates.rb +13 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed08b2544c35758dec93a8da948bd7c573d60d29e3051d09137d42de74ed3a2f
|
4
|
+
data.tar.gz: e5cba37e231d3f408039e03e8e9490c9f9217f4c9c0c8187770aabb5895aee4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 115f11ec9c400c17b8886a87a3e533a9e8032e433756aa9567b95802a263f94c988e2ce8637a37c05bac7f4b5dcae3a965e0730acbc4b3ede1df1b4a2cfbd09a
|
7
|
+
data.tar.gz: a977f035dd639ce390c019facd0b68cd883bf4cadce2db8c78ecf1d30911ded099f1f4c4a8926d6505bfd20ed542ec1523f84f8b027b776e9125293c309ed94d
|
data/README.md
CHANGED
@@ -18,6 +18,9 @@ a generator in any iterable context. Since these are "infinite" generators, enu
|
|
18
18
|
|
19
19
|
### RELEASE NOTES
|
20
20
|
|
21
|
+
**v0.4.1**
|
22
|
+
- Added ability to set rate to new value for `Poisson`.
|
23
|
+
|
21
24
|
**v0.4**
|
22
25
|
- All distribution classes have been placed in a module called `RV` to try to avoid namespace conflicts.
|
23
26
|
- The `Gaussian` class has been renamed, it is now the `Normal` class.
|
data/lib/random_variates.rb
CHANGED
@@ -152,14 +152,14 @@ module RV
|
|
152
152
|
end
|
153
153
|
|
154
154
|
def rate=(rate)
|
155
|
-
raise 'Rate must be a number.' unless rate.is_a?
|
155
|
+
raise 'Rate must be a number.' unless rate.is_a? Numeric
|
156
156
|
raise 'Rate must be positive.' if rate <= 0
|
157
157
|
@mean = 1.0 / rate
|
158
158
|
@rate = rate
|
159
159
|
end
|
160
160
|
|
161
161
|
def mean=(mean)
|
162
|
-
raise 'Mean must be a number.' unless mean.is_a?
|
162
|
+
raise 'Mean must be a number.' unless mean.is_a? Numeric
|
163
163
|
raise 'Mean must be positive.' if mean <= 0
|
164
164
|
@mean = mean
|
165
165
|
@rate = 1.0 / mean
|
@@ -207,12 +207,12 @@ module RV
|
|
207
207
|
end
|
208
208
|
|
209
209
|
def sigma=(sigma)
|
210
|
-
raise 'sigma must be a number.' unless sigma.is_a?
|
210
|
+
raise 'sigma must be a number.' unless sigma.is_a? Numeric
|
211
211
|
@sigma = sigma
|
212
212
|
end
|
213
213
|
|
214
214
|
def mu=(mu)
|
215
|
-
raise 'mu must be a number.' unless mu.is_a?
|
215
|
+
raise 'mu must be a number.' unless mu.is_a? Numeric
|
216
216
|
@mu = mu
|
217
217
|
end
|
218
218
|
end
|
@@ -253,12 +253,12 @@ module RV
|
|
253
253
|
end
|
254
254
|
|
255
255
|
def sigma=(sigma)
|
256
|
-
raise 'sigma must be a number.' unless sigma.is_a?
|
256
|
+
raise 'sigma must be a number.' unless sigma.is_a? Numeric
|
257
257
|
@sigma = sigma
|
258
258
|
end
|
259
259
|
|
260
260
|
def mu=(mu)
|
261
|
-
raise 'mu must be a number.' unless mu.is_a?
|
261
|
+
raise 'mu must be a number.' unless mu.is_a? Numeric
|
262
262
|
@mu = mu
|
263
263
|
end
|
264
264
|
end
|
@@ -410,6 +410,13 @@ module RV
|
|
410
410
|
@rng = rng
|
411
411
|
end
|
412
412
|
|
413
|
+
def rate=(rate)
|
414
|
+
raise 'Rate must be a number.' unless rate.is_a? Numeric
|
415
|
+
raise 'Rate must be positive.' if rate <= 0
|
416
|
+
@rate = rate
|
417
|
+
@threshold = Math.exp(-rate)
|
418
|
+
end
|
419
|
+
|
413
420
|
def next
|
414
421
|
count = 0
|
415
422
|
product = 1.0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: random_variates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul J Sanchez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Random variate generators implemented as enumerators.
|
14
14
|
email: pjs@alum.mit.edu
|