composite_rng 0.1.0 → 0.1.5

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
- SHA1:
3
- metadata.gz: 1f340e108ce670dca8fd91ec9089ae5753eae06e
4
- data.tar.gz: b992ad5f3defe4e2578090833730107b256bfc89
2
+ SHA256:
3
+ metadata.gz: 8f212582253e788745139e57da549a2fe5e682a7117171a867d6e5b52e0a1f3a
4
+ data.tar.gz: 1994196919e99dd6da03bc3264307b4f15c6b9b530d3413dff16ba4d260dac9d
5
5
  SHA512:
6
- metadata.gz: 1731dee7aeb11ec2f9006853c038211c89afcaa4a5e4e9f4e6b3f74e24339218d39c2108e270feea0b05aa01a9f6277d365fb27b59e1397d2799f06d314f828d
7
- data.tar.gz: cf12a60cc2dba80842ef8f2e73dede341cb0a7e6766f1800a6bec6f16b00fbf3a2dd030f7e380818288f3670120f1d12a18d824985ea45dce084da9176f947a4
6
+ metadata.gz: f42e03369535712d75033f3f223726b8650917acf69cc5b4a02f314602af276d9a89a8b16acbd8f06d5dcfd7fed0ef8b9a5f131191afa0ce6d33780b1ec6f16a
7
+ data.tar.gz: 64d58b974b59f75059f0f448bdb9df0fac85128763aa6e717c14076d4477a0c693036b5b2f2ede4c475585f0226c5aeeb0125e4ad11b10979e5a6d1b17e29348
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at peter.c.camilleri@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/README.md CHANGED
@@ -1,53 +1,68 @@
1
1
  # CompositeRng
2
2
 
3
3
  The composite (psuedo) random number generator is a container for two other
4
- (psuedo) random number generators. By working together, these create higher
5
- quality pseudo-random number streams than either could by itself.
4
+ (psuedo) random number generators. By working together, these generators
5
+ create higher quality pseudo-random number streams than either could create
6
+ by itself.
6
7
 
7
- The two generators do not need to be the same type. In fact it helps to reduce
8
- any possible correlation between the parent and the child if they are
9
- completely different sorts of generators. It is really not a good idea for them
10
- to be either the same instance, or the same type with the same seed, because
11
- this negates the advantage of compositing generators.
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
12
11
 
13
- The generators used must comply to the following duck characteristics:
12
+ gem 'composite_rng'
14
13
 
15
- rand(max) - This method must compute a random integer from 0...max
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install composite_rng
21
+
22
+ The composite_rng gem itself is found at: ( https://rubygems.org/gems/composite_rng )
16
23
 
17
- The constructor takes four arguments:
18
- * The parent PRNG that is used to "educate" the child.
19
- * The child PRNG that is the actual generator of data.
20
- * The optional churn_limit factor that controls how much tutoring the child
21
- can receive. This optional parameter defaults to 16. This value may be read
22
- back with the churn_limit property. Valid values are 2..256
23
- * The optional init factor that controls the amount of initial tutoring the
24
- child receives initially. This defaults to 0 for none. Valid values are 0..256
24
+ ##Usage
25
25
 
26
- The following shows how this could work:
27
26
  ```ruby
28
- parent = Random.new #Get the built in Mersenne Twister MT19937 PRNG
29
- child = Random.new
30
- composite = CompositeRng.new(parent, child, 42, 11)
31
- # ...
32
- dice_roll = 1 + composite.rand(6)
33
- # ...
27
+ require 'composite_rng'
34
28
  ```
35
29
 
36
- It is also possible to use the default PRNG as follows:
30
+ Then in an appropriate place in the code:
31
+
37
32
  ```ruby
38
- parent = Object.new
33
+ @my_rng = CompositeRng.new(parent, child, churn, init)
34
+ ```
35
+ Where:
36
+ * parent is a random number generator used to educate the child.
37
+ * child is the random number generator used to generate the output.
38
+ * churn is the limit on the education process. Default 16, Range 2..256
39
+ * init is the number of initial churns done during initialization. Default 0, Range 0..256
40
+
41
+ The parent and child generators do not need to be the same type. In fact it
42
+ helps to reduce any possible correlation between the parent and the child
43
+ if they are completely different sorts of generators. It is a really bad
44
+ idea for them to be either the same instance, or the same type with the same
45
+ seed, because this negates the advantage of compositing generators.
46
+
47
+ To be used in a composite generator, both generators used must implement the
48
+ following method:
49
+
50
+ rand(max)
51
+
52
+ which method must return a pseudo-random integer in 0...max.
53
+
54
+ The following are examples of this class in action.
55
+ ```ruby
56
+ parent = Random.new #Get the built in Mersenne Twister MT19937 PRNG
39
57
  child = Random.new
40
- composite = CompositeRng.new(parent, child)
58
+ composite = CompositeRng.new(parent, child, 42, 11)
41
59
  # ...
42
60
  dice_roll = 1 + composite.rand(6)
43
61
  # ...
44
62
  ```
45
- This is because the default PRNG exists as methods of Object. Note that (as
46
- far as I can tell) only one instance of that PRNG exists, so it should only
47
- be used as parent or child but never both!.
48
63
 
49
- The composite generator also works with custom generator, that support rand(n)
50
- like my own Fibonacci generator:
64
+ The composite generator also works with custom generators that support rand(n).
65
+ For example my own Fibonacci generator:
51
66
 
52
67
  ```ruby
53
68
  parent = Random.new
@@ -77,24 +92,6 @@ more thorough job:
77
92
  crazy_string = 22.times.inject("") { |s| s << composite.churn.bytes(1) }
78
93
  ```
79
94
 
80
- ## Installation
81
-
82
- Add this line to your application's Gemfile:
83
-
84
- gem 'composite_rng'
85
-
86
- And then execute:
87
-
88
- $ bundle
89
-
90
- Or install it yourself as:
91
-
92
- $ gem install composite_rng
93
-
94
- The composite_rng gem itself is found at: ( https://rubygems.org/gems/composite_rng )
95
-
96
- The fibonacci_rng code lives at: ( https://github.com/PeterCamilleri/fibonacci_rng )
97
-
98
95
  ## Contributing
99
96
 
100
97
  #### Plan A
@@ -109,3 +106,14 @@ The fibonacci_rng code lives at: ( https://github.com/PeterCamilleri/fibonacci_r
109
106
 
110
107
  Go to the GitHub repository and raise an issue calling attention to some
111
108
  aspect that could use some TLC or a suggestion or an idea.
109
+
110
+ ## License
111
+
112
+ The gem is available as open source under the terms of the
113
+ [MIT License](./LICENSE.txt).
114
+
115
+ ## Code of Conduct
116
+
117
+ Everyone interacting in the fully_freeze project’s codebases, issue trackers,
118
+ chat rooms and mailing lists is expected to follow the
119
+ [code of conduct](./CODE_OF_CONDUCT.md).
@@ -23,10 +23,9 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.required_ruby_version = '>= 1.9.3'
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.3"
27
- spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "bundler", ">= 2.1.0"
27
+ spec.add_development_dependency "rake", ">= 12.3.3"
28
28
  spec.add_development_dependency 'reek', "~> 1.3.8"
29
29
  spec.add_development_dependency 'minitest', "~> 5.8"
30
30
  spec.add_development_dependency 'rdoc', "~> 4.0.1"
31
- spec.add_development_dependency 'minitest_visible', ">= 0.1.0"
32
31
  end
data/irbt.rb CHANGED
@@ -2,8 +2,6 @@
2
2
  # An IRB + composite_rng Test bed
3
3
 
4
4
  require 'irb'
5
- $force_alias_read_line_module = true
6
- require 'mini_readline'
7
5
 
8
6
  puts "Starting an IRB console with composite_rng loaded."
9
7
 
@@ -1,4 +1,4 @@
1
1
  class CompositeRng
2
2
  #The CompositeRng version.
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.5".freeze
4
4
  end
@@ -3,14 +3,10 @@
3
3
  require_relative '../lib/composite_rng'
4
4
  gem 'minitest'
5
5
  require 'minitest/autorun'
6
- require 'minitest_visible'
7
6
 
8
7
  #Test the monkey patches applied to the Object class.
9
8
  class CompositeRngTester < Minitest::Test
10
9
 
11
- #Track mini-test progress.
12
- include MinitestVisible
13
-
14
10
  def test_that_it_checks_parms
15
11
  assert_raises { CompositeRng.new(Random.new, Random.new, -1, 0) }
16
12
  assert_raises { CompositeRng.new(Random.new, Random.new, 300, 0) }
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composite_rng
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
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-13 00:00:00.000000000 Z
11
+ date: 2021-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: 2.1.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: 2.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: reek
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 4.0.1
83
- - !ruby/object:Gem::Dependency
84
- name: minitest_visible
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: 0.1.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: 0.1.0
97
83
  description: A composable random number generator.
98
84
  email:
99
85
  - peter.c.camilleri@gmail.com
@@ -102,6 +88,7 @@ extensions: []
102
88
  extra_rdoc_files: []
103
89
  files:
104
90
  - ".gitignore"
91
+ - CODE_OF_CONDUCT.md
105
92
  - Gemfile
106
93
  - LICENSE.txt
107
94
  - README.md
@@ -131,10 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
118
  - !ruby/object:Gem::Version
132
119
  version: '0'
133
120
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 2.2.2
121
+ rubygems_version: 3.2.17
136
122
  signing_key:
137
123
  specification_version: 4
138
124
  summary: A composable random number generation class.
139
125
  test_files: []
140
- has_rdoc: