fibonacci_rng 1.1.0 → 1.1.1

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: 5fdabb723bc231c0172f6fa824c8fa6cd6948a78
4
- data.tar.gz: 2de8db50e6075474582a78e6475e01b5b591ef14
3
+ metadata.gz: aeaeffd9970516773ff376f31c7e9b937b40ad1e
4
+ data.tar.gz: f81169d59987565caf00d8f0f58f5c055193c2ce
5
5
  SHA512:
6
- metadata.gz: 89eecfb7a41a6e24ce0b1cd9d583f720ff4ff74a12438fa5b4b557bf23de911fe96cf054e63435a72328a57342122b7751afe4bb97181117f258bc0a9ded250f
7
- data.tar.gz: 3c2164cb23b043b1be8ed21dbdcc4c129bd3f5da818564c3d658c9944bf9a7dfd4a51918427fc6df8a7f592c2384aa5ee68b81b62d08d4d64aa45554a27a6eb7
6
+ metadata.gz: 539bd740b23b2466e8832f75138842c4b060154a3a1170686e0a6ee1aac9c6dc3690e3f2bf0f57e48ab976c6424f8eb6b16dd435a8f078fe5627f9109f586c20
7
+ data.tar.gz: 14948121de4868db91145c8ff37fb45ff91c05fc7ccf08d8085c26de49a67391a507ba686585b2c5c0b67140b19a399d644fe576009704efdeeb43d2a4e6c0ba
data/README.md CHANGED
@@ -44,7 +44,7 @@ require 'fibonacci_rng'
44
44
  Then in an appropriate place in the code:
45
45
 
46
46
  ```ruby
47
- @my_rng = FibonacciRng.new(depth, seed)
47
+ @my_rng = FibonacciRng.new(seed, depth, init)
48
48
  ```
49
49
 
50
50
  Where:
@@ -52,6 +52,8 @@ Where:
52
52
  * seed is an optional number or string or other object that has a repeatable
53
53
  value and responds to the to_s method. Defaults to a value derived from system
54
54
  entropy.
55
+ * init is the number of initial training cycles used to seed the generator. The
56
+ allowed range is 1 to 1,000,000. By default the init value is 32*depth+768.
55
57
 
56
58
  Here is an overview of the available options.
57
59
 
@@ -68,6 +70,8 @@ Here is an overview of the available options.
68
70
  #Method #4
69
71
  @my_rng = FibonacciRng.new(FibonacciRng.new_seed, 12) # Random seed, depth = 12
70
72
 
73
+ #Method #5
74
+ @my_rng = FibonacciRng.new(FibonacciRng.new_seed, 12, 100) # Random seed, depth = 12 with 100 passes.
71
75
  ```
72
76
  In addition, keyword arguments are emulated (as of Version 0.4.0) so these
73
77
  additional options also are available:
@@ -77,21 +81,21 @@ additional options also are available:
77
81
  responds to the to_s method. Defaults to a value derived from system entropy.
78
82
  * init: value -- the number of initial training cycles used to seed the
79
83
  generator. The allowed range is 1 to 1,000,000. By default the init value is
80
- 32*depth+768. This setting is only available with keyword arguments.
84
+ 32*depth+768.
81
85
 
82
86
  The following are examples of constructors with keyword arguments.
83
87
 
84
88
  ```ruby
85
- #Method #5
89
+ #Method #6
86
90
  @my_rng = FibonacciRng.new(seed: 'seed') # Specified seed = 'seed', depth = 8
87
91
 
88
- #Method #6
92
+ #Method #7
89
93
  @my_rng = FibonacciRng.new(seed: 'seed', depth: 12) # Specified seed = 'seed', depth = 12
90
94
 
91
- #Method #7
95
+ #Method #8
92
96
  @my_rng = FibonacciRng.new(depth: 12) # Random seed, depth = 12
93
97
 
94
- #Method #8
98
+ #Method #9
95
99
  @my_rng = FibonacciRng.new(seed: 'seed', init: 2048) # Specified seed = 'seed' with 2048 passes.
96
100
 
97
101
  ```
@@ -2,5 +2,5 @@
2
2
 
3
3
  #The class of Fibonacci inspired random number generators.
4
4
  class FibonacciRng
5
- VERSION = "1.1.0"
5
+ VERSION = "1.1.1"
6
6
  end
data/lib/fibonacci_rng.rb CHANGED
@@ -27,15 +27,16 @@ class FibonacciRng
27
27
  attr_reader :init
28
28
 
29
29
  #Initialize the PRN generator
30
- def initialize(arg_a=nil, arg_b=nil)
30
+ def initialize(arg_a=nil, arg_b=nil, arg_c=nil)
31
31
  #Extract the parameters.
32
32
  if arg_a.is_a?(Hash)
33
- seed = arg_a[:seed]
33
+ seed = arg_a[:seed]
34
34
  @depth = arg_a[:depth]
35
35
  @init = arg_a[:init]
36
36
  else
37
- seed = arg_a
37
+ seed = arg_a
38
38
  @depth = arg_b
39
+ @init = arg_c
39
40
  end
40
41
 
41
42
  #Set up the default parameters if needed.
@@ -15,32 +15,44 @@ class FibonacciRngTester < Minitest::Test
15
15
  gen = FibonacciRng.new
16
16
  assert_equal(8, gen.depth)
17
17
  assert_equal(String, gen.seed.class)
18
+ assert_equal(1024, gen.init)
18
19
 
19
20
  gen = FibonacciRng.new('seed')
20
21
  assert_equal(8, gen.depth)
21
22
  assert_equal('seed', gen.seed)
23
+ assert_equal(1024, gen.init)
22
24
 
23
25
  gen = FibonacciRng.new('seed', 12)
24
26
  assert_equal(12, gen.depth)
25
27
  assert_equal('seed', gen.seed)
28
+ assert_equal(1152, gen.init)
29
+
30
+ gen = FibonacciRng.new('seed', 12, 2048)
31
+ assert_equal(12, gen.depth)
32
+ assert_equal('seed', gen.seed)
33
+ assert_equal(2048, gen.init)
26
34
  end
27
35
 
28
36
  def test_building_with_keywords
29
37
  gen = FibonacciRng.new(seed: 'seed')
30
38
  assert_equal(8, gen.depth)
31
39
  assert_equal('seed', gen.seed)
40
+ assert_equal(1024, gen.init)
32
41
 
33
42
  gen = FibonacciRng.new(depth: 12)
34
43
  assert_equal(12, gen.depth)
35
44
  assert_equal(String, gen.seed.class)
45
+ assert_equal(1152, gen.init)
36
46
 
37
47
  gen = FibonacciRng.new(seed: 'seed', depth: 12)
38
48
  assert_equal(12, gen.depth)
39
49
  assert_equal('seed', gen.seed)
50
+ assert_equal(1152, gen.init)
40
51
 
41
52
  gen = FibonacciRng.new(depth: 12, seed: 'seed')
42
53
  assert_equal(12, gen.depth)
43
54
  assert_equal('seed', gen.seed)
55
+ assert_equal(1152, gen.init)
44
56
 
45
57
  gen = FibonacciRng.new(seed: 'seed', init: 2048)
46
58
  assert_equal('seed', gen.seed)
@@ -113,7 +125,7 @@ class FibonacciRngTester < Minitest::Test
113
125
  assert_equal(10, rs.length)
114
126
  end
115
127
 
116
- def test_that_it_makes_unique_sequnces
128
+ def test_that_it_makes_unique_sequences
117
129
  prnga = FibonacciRng.new
118
130
  prngb = FibonacciRng.new
119
131
 
@@ -128,7 +140,7 @@ class FibonacciRngTester < Minitest::Test
128
140
  assert(buffa != buffb)
129
141
  end
130
142
 
131
- def test_that_it_makes_repeatable_sequnces
143
+ def test_that_it_makes_repeatable_sequences
132
144
  prnga = FibonacciRng.new(0)
133
145
  prngb = FibonacciRng.new(0)
134
146
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fibonacci_rng
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Camilleri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-11 00:00:00.000000000 Z
11
+ date: 2016-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest_visible