eenie_meenie 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -8,6 +8,79 @@ Installation
8
8
 
9
9
  EenieMeenie is a Ruby gem, and can be installed using `gem install eenie_meenie`
10
10
 
11
+ Usage
12
+ -----
13
+
14
+ EenieMeenie currently provides two algorithms for assigning members to experimental groups.
15
+
16
+ `EenieMeenie::Assignment` was the first algorithm, and was intended to handle situations where members of a population are to be assigned to ONE of TWO groups. As I started working with a greater variety of research studies, I found the algorithm to be both overcomplicated and inadequate.
17
+
18
+ `EeenieMeenie::PolyAssignment` is a new algorithm. With this algorithm you'll be able to:
19
+
20
+ 1. Assign a threshold (a `Float` to represent percentage) to each experimental group.
21
+ 2. Assign a threshold of "DO NOT CARE" to any group by passing `false` instead of a `Float`
22
+ 3. Tell EeenieMeenie which groups can be assigned by the algorithm. Any group with a threshold should be included here.
23
+ 4. Tell it how to scope the member class (tell it which study, if you're using one member class for all studies)
24
+
25
+ Example Configurations
26
+ ----------------------
27
+
28
+ ```ruby
29
+ # Control: Do not care (chosen manually, if ever)
30
+ # Experimental A: %50 (randomly assign)
31
+ # Experimental B: %50 (randomly assign)
32
+
33
+ EenieMeenie::Assignment.new({
34
+ groups: ["Experimental A", "Experimental B"], # EenieMeenie's assignment options
35
+ member: @obj, # Member of population
36
+ group_rules: {
37
+ "Control" => { threshold: false }, # Don't care
38
+ "Full-Incentive" => { threshold: 0.5 }, # No more than 50%
39
+ "Split-Incentive" => { threshold: 0.5 } # No more than 50%
40
+ },
41
+ class_rules: { organization_id: 1} # Only consider members belonging to Organization 1
42
+ }).execute!
43
+ ```
44
+
45
+ ```ruby
46
+ # Control: %33.3 (randomly assign)
47
+ # Experimental A: %33.3 (randomly assign)
48
+ # Experimental B: %33.3 (randomly assign)
49
+
50
+ EenieMeenie::Assignment.new({
51
+ groups: ["Control", "Experimental A", "Experimental B"], # EenieMeenie's assignment options
52
+ member: @obj, # Member of population
53
+ group_rules: {
54
+ "Control" => { threshold: (1.0 / 3.0) }, # No more than one-third
55
+ "Full-Incentive" => { threshold: (1.0 / 3.0) }, # No more than one-third
56
+ "Split-Incentive" => { threshold: (1.0 / 3.0) } # No more than one-third
57
+ },
58
+ class_rules: { organization_id: 1} # Only consider members belonging to Organization 1
59
+ }).execute!
60
+ ```
61
+
62
+ ```ruby
63
+ # Control: %50 (randomly assign)
64
+ # Experimental: Do not care (randomly assign)
65
+ # Experimental A: Do not care (manually assign)
66
+ # Experimental B: Do not care (manually assign)
67
+
68
+ # If "Control" is too full, put them in "Experimental" ...
69
+ # Later someone will choose whether they're in "Experimental A" ...
70
+ # or in "Experimental B"
71
+
72
+ EenieMeenie::Assignment.new({
73
+ groups: ["Control", "Experimental"], # EenieMeenie's assignment options
74
+ member: @obj, # Member of population
75
+ group_rules: {
76
+ "Control" => { threshold: 0.5 }, # No more than one-third
77
+ "Experimental" => { threshold: false }, # Don't care
78
+ "Experimental A" => { threshold: false } # Don't care
79
+ "Experimental B" => { threshold: false } # Don't care
80
+ }
81
+ }).execute!
82
+ ```
83
+
11
84
  ### Pull requests/issues
12
85
 
13
86
  Please submit any useful pull requests through GitHub. Please report any bugs using Github's issue tracker
@@ -0,0 +1,41 @@
1
+ module EenieMeenie
2
+ class PolyAssignment < ::EenieMeenie::Base
3
+ def initialize(options)
4
+ options = {
5
+ class_rules: {}
6
+ }.merge(options)
7
+
8
+ load_options(:group_rules, :class_rules, :groups, :member, options)
9
+ end
10
+
11
+ def execute!
12
+ set_group_counts
13
+ return random_group
14
+ end
15
+
16
+ private
17
+
18
+ # Total population
19
+ def population
20
+ @members ||= @member.class.where(@class_rules)
21
+ end
22
+
23
+ # Current population in each group
24
+ def set_group_counts
25
+ @group_rules.each do |k,v|
26
+ v[:count] = population.where(experimental_group: k.to_s).count
27
+ end
28
+ end
29
+
30
+ # Groups not over threshold
31
+ def group_candidates
32
+ @group_candidates ||= @group_rules.reject { |k,v|
33
+ v[:threshold] && (v[:count] / @members.count.to_f) >= v[:threshold]
34
+ }.keys.map(&:to_s)
35
+ end
36
+
37
+ def random_group
38
+ group_candidates.sample || @groups.sample
39
+ end
40
+ end
41
+ end
@@ -1,3 +1,3 @@
1
1
  module EenieMeenie
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,66 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eenie_meenie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ prerelease:
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tad Hosford
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-15 00:00:00.000000000 Z
12
+ date: 2013-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
16
+ version_requirements: !ruby/object:Gem::Requirement
18
17
  requirements:
19
18
  - - ! '>='
20
19
  - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
20
+ version: !binary |-
21
+ MA==
25
22
  none: false
23
+ requirement: !ruby/object:Gem::Requirement
26
24
  requirements:
27
25
  - - ! '>='
28
26
  - !ruby/object:Gem::Version
29
- version: '0'
27
+ version: !binary |-
28
+ MA==
29
+ none: false
30
+ prerelease: false
31
+ type: :development
30
32
  - !ruby/object:Gem::Dependency
31
33
  name: rake
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
+ version_requirements: !ruby/object:Gem::Requirement
34
35
  requirements:
35
36
  - - ! '>='
36
37
  - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
38
+ version: !binary |-
39
+ MA==
41
40
  none: false
41
+ requirement: !ruby/object:Gem::Requirement
42
42
  requirements:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: '0'
45
+ version: !binary |-
46
+ MA==
47
+ none: false
48
+ prerelease: false
49
+ type: :development
46
50
  - !ruby/object:Gem::Dependency
47
51
  name: pry
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
52
+ version_requirements: !ruby/object:Gem::Requirement
50
53
  requirements:
51
54
  - - ! '>='
52
55
  - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
56
+ version: !binary |-
57
+ MA==
57
58
  none: false
59
+ requirement: !ruby/object:Gem::Requirement
58
60
  requirements:
59
61
  - - ! '>='
60
62
  - !ruby/object:Gem::Version
61
- version: '0'
62
- description: ! " Attempts to provide a random but (mostly)\n even
63
- distribution of samples amongst\n specified groups\n "
63
+ version: !binary |-
64
+ MA==
65
+ none: false
66
+ prerelease: false
67
+ type: :development
68
+ description: ! " Attempts to provide a random but (mostly)\n \
69
+ \ even distribution of samples amongst\n specified groups\n\
70
+ \ "
64
71
  email:
65
72
  - tad.hosford@gmail.com
66
73
  executables: []
@@ -68,9 +75,7 @@ extensions: []
68
75
  extra_rdoc_files: []
69
76
  files:
70
77
  - .gitignore
71
- - CHANGELOG.md
72
78
  - Gemfile
73
- - Gemfile.lock
74
79
  - README.md
75
80
  - Rakefile
76
81
  - eenie_meenie.gemspec
@@ -78,6 +83,7 @@ files:
78
83
  - lib/eenie_meenie/assignment.rb
79
84
  - lib/eenie_meenie/base.rb
80
85
  - lib/eenie_meenie/miny_moe.rb
86
+ - lib/eenie_meenie/poly_assignment.rb
81
87
  - lib/eenie_meenie/result.rb
82
88
  - lib/eenie_meenie/sorters/bucket_shuffle.rb
83
89
  - lib/eenie_meenie/sorters/late_coercion.rb
@@ -89,26 +95,34 @@ files:
89
95
  - test/minitest_helper.rb
90
96
  homepage: http://github.com/rthbound/eenie_meenie
91
97
  licenses: []
92
- post_install_message:
98
+ post_install_message:
93
99
  rdoc_options: []
94
100
  require_paths:
95
101
  - lib
96
102
  required_ruby_version: !ruby/object:Gem::Requirement
97
- none: false
98
103
  requirements:
99
104
  - - ! '>='
100
105
  - !ruby/object:Gem::Version
101
- version: '0'
102
- required_rubygems_version: !ruby/object:Gem::Requirement
106
+ segments:
107
+ - 0
108
+ hash: 2
109
+ version: !binary |-
110
+ MA==
103
111
  none: false
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
113
  requirements:
105
114
  - - ! '>='
106
115
  - !ruby/object:Gem::Version
107
- version: '0'
116
+ segments:
117
+ - 0
118
+ hash: 2
119
+ version: !binary |-
120
+ MA==
121
+ none: false
108
122
  requirements: []
109
- rubyforge_project:
123
+ rubyforge_project:
110
124
  rubygems_version: 1.8.24
111
- signing_key:
125
+ signing_key:
112
126
  specification_version: 3
113
127
  summary: ''
114
128
  test_files: []
data/CHANGELOG.md DELETED
@@ -1,13 +0,0 @@
1
- 0.0.1 - Initial release, allows you to initialize an instance of Rubeuler::Problem with required options `:number` (int) and `:answer` (string of ruby code). Answer is evaluated and compared to answer predefined in Rubeuler::Problem#solutions method. Result is returned indicating success/failure and the time elapsed when running the code in `:answer`
2
-
3
- 0.0.2 - Fixed Rakefile (gave myself the ability to use `rake release`); Updated description in gemspec
4
-
5
- 0.0.3 - Moved Rubeuler::Problem#solutions to Rubeuler::Solution#for_problem to make the intended use more intuitive
6
-
7
- 0.0.4 - Add tests using minitest
8
-
9
- 0.0.5 - Feature: Track other variables... the options `tracked: {foo: @foo}` would track a variable set as `@foo` in Rubeuler::Problem's `:answer` argument
10
- Improve on tests, improve timer by moving Benchmark closer to code being evaluated
11
-
12
- 0.0.6 - Reverting the change to the Benchmark implementation from 0.0.5
13
-
data/Gemfile.lock DELETED
@@ -1,33 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- eenie_meenie (0.0.1)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- coderay (1.0.7)
10
- method_source (0.8)
11
- minitest (3.5.0)
12
- pry (0.9.10)
13
- coderay (~> 1.0.5)
14
- method_source (~> 0.8)
15
- slop (~> 3.3.1)
16
- pry (0.9.10-java)
17
- coderay (~> 1.0.5)
18
- method_source (~> 0.8)
19
- slop (~> 3.3.1)
20
- spoon (~> 0.0)
21
- rake (0.9.2.2)
22
- slop (3.3.3)
23
- spoon (0.0.1)
24
-
25
- PLATFORMS
26
- java
27
- ruby
28
-
29
- DEPENDENCIES
30
- eenie_meenie!
31
- minitest
32
- pry
33
- rake