datafarming 1.4.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,57 @@
1
+ require 'fwt'
2
+
3
+ module RESV
4
+ # Generate a Resolution V Fractional Factorial design for the specified
5
+ # number of factors. The design is guaranteed to yield unconfounded
6
+ # interactions for all pairs of factors. The design uses standardized
7
+ # notation, i.e., -1 represents a low setting and 1 represents a high
8
+ # setting for each factor.
9
+ #
10
+ # *Arguments*::
11
+ # - +number_of_factors+ -> the number of factors in your design. Limit is 120.
12
+ # *Returns*::
13
+ # - a two-dimensional array specifying the design, where each column
14
+ # corresponds to a factor and each row is a design point.
15
+ #
16
+ # Author:: Paul J Sanchez (mailto:pjs@alum.mit.edu)
17
+ # Copyright:: Copyright (c) 2023 Paul J Sanchez
18
+ # License:: MIT
19
+ #
20
+ INDEX = [1, 2, 4, 8, 15, 16, 32, 51, 64, 85, 106, 128, 150, 171,
21
+ 219, 237, 247, 256, 279, 297, 455, 512, 537, 557, 594, 643, 803,
22
+ 863, 998, 1024, 1051, 1070, 1112, 1169, 1333, 1345, 1620, 1866,
23
+ 2048, 2076, 2085, 2185, 2372, 2456, 2618, 2800, 2873, 3127, 3284,
24
+ 3483, 3557, 3763, 4096, 4125, 4135, 4174, 4435, 4459, 4469, 4497,
25
+ 4752, 5255, 5732, 5804, 5915, 6100, 6369, 6907, 7069, 8192, 8263,
26
+ 8351, 8422, 8458, 8571, 8750, 8858, 9124, 9314, 9500, 10_026,
27
+ 10_455, 10_556, 11_778, 11_885, 11_984, 13_548, 14_007, 14_514,
28
+ 14_965, 15_125, 15_554, 16_384, 16_457, 16_517, 16_609, 16_771,
29
+ 16_853, 17_022, 17_453, 17_891, 18_073, 18_562, 18_980, 19_030,
30
+ 19_932, 20_075, 20_745, 21_544, 22_633, 23_200, 24_167, 25_700,
31
+ 26_360, 26_591, 26_776, 28_443, 28_905, 29_577, 32_705]
32
+ POWER = [1, 2, 4, 8, 16, 16, 32, 64, 64, 128, 128, 128, 256, 256,
33
+ 256, 256, 256, 256, 512, 512, 512, 512, 1024, 1024, 1024, 1024,
34
+ 1024, 1024, 1024, 1024, 2048, 2048, 2048, 2048, 2048, 2048, 2048,
35
+ 2048, 2048, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096,
36
+ 4096, 4096, 4096, 4096, 4096, 8192, 8192, 8192, 8192, 8192, 8192,
37
+ 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192,
38
+ 16_384, 16_384, 16_384, 16_384, 16_384, 16_384, 16_384, 16_384,
39
+ 16_384, 16_384, 16_384, 16_384, 16_384, 16_384, 16_384, 16_384,
40
+ 16_384, 16_384, 16_384, 16_384, 16_384, 16_384, 16_384, 32_768,
41
+ 32_768, 32_768, 32_768, 32_768, 32_768, 32_768, 32_768, 32_768,
42
+ 32_768, 32_768, 32_768, 32_768, 32_768, 32_768, 32_768, 32_768,
43
+ 32_768, 32_768, 32_768, 32_768, 32_768, 32_768, 32_768, 32_768,
44
+ 32_768, 32_768, 32_768]
45
+
46
+ def RESV.make_design(number_of_factors)
47
+ Array.new(number_of_factors) do |i|
48
+ Array.new(POWER[number_of_factors], 0).tap { |a| a[INDEX[i]] = 1 }.hadamard
49
+ end.transpose
50
+ end
51
+
52
+ def RESV.star_pts(k)
53
+ Array.new(2*k+1) do |i|
54
+ Array.new(k) { |j| (j+1) == (i+1) / 2 ? (i.odd? ? -1 : 1) : 0 }
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby -w
2
+
3
+ # A Scaler object will rescale a design from standard range [-1, 1] to a
4
+ # range specified by min & max, with the desired number of decimals
5
+ class Scaler
6
+ def initialize(min: -1, max: 1, decimals: nil)
7
+ unless decimals.nil? || ((decimals >= 0) && (decimals == decimals.to_i))
8
+ fail "Invalid decimals argument: #{decimals}. Must be a non-negative integer"
9
+ end
10
+ @range = (max - min).to_r / 2
11
+ @mid = min + @range
12
+ @scale_factor = (decimals.nil? || decimals.zero?) ? decimals : 10r**decimals
13
+ end
14
+
15
+ def scale(value)
16
+ new_value = @mid + @range * value
17
+ if @scale_factor.nil?
18
+ if new_value.to_r.denominator == 1
19
+ new_value.to_i
20
+ else
21
+ new_value.to_f
22
+ end
23
+ elsif @scale_factor.zero?
24
+ new_value.round
25
+ else
26
+ ((@scale_factor * new_value).round / @scale_factor).to_f
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,143 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FBS
4
+ TWO_PI = 2.0 * Math::PI
5
+
6
+ DesignSet = Struct.new(:nyq, :freqs, keyword_init: true)
7
+
8
+ DESIGN_SETS = {
9
+ 2 => DesignSet.new(
10
+ nyq: 11, freqs: [
11
+ [1, 3],
12
+ [1, 4],
13
+ [1, 5]
14
+ ]
15
+ ),
16
+ 3 => DesignSet.new(
17
+ nyq: 19, freqs: [
18
+ [1, 3, 7],
19
+ [1, 7, 8],
20
+ [2, 3, 5],
21
+ [4, 6, 9]
22
+ ]
23
+ ),
24
+ 4 => DesignSet.new(
25
+ nyq: 29, freqs: [
26
+ [1, 4, 5, 11]
27
+ ]
28
+ ),
29
+ 5 => DesignSet.new(
30
+ nyq: 43, freqs: [
31
+ [1, 5, 6, 8, 20],
32
+ [1, 8, 9, 11, 14],
33
+ [3, 4, 7, 9, 19]
34
+ ]
35
+ ),
36
+ 6 => DesignSet.new(
37
+ nyq: 59, freqs: [
38
+ [1, 6, 10, 16, 24, 28],
39
+ [1, 7, 11, 16, 19, 23],
40
+ [2, 8, 20, 23, 25, 29]
41
+ ]
42
+ ),
43
+ 7 => DesignSet.new(
44
+ nyq: 79, freqs: [
45
+ [1, 3, 8, 11, 26, 29, 33],
46
+ [1, 4, 11, 12, 29, 30, 35],
47
+ [1, 5, 6, 14, 15, 17, 38],
48
+ [1, 10, 11, 16, 17, 24, 25],
49
+ [2, 3, 5, 11, 20, 21, 25],
50
+ [2, 3, 17, 22, 25, 33, 36],
51
+ [2, 5, 7, 13, 15, 16, 39],
52
+ [2, 7, 9, 10, 15, 19, 33],
53
+ [2, 20, 22, 29, 31, 32, 34],
54
+ [3, 8, 15, 17, 18, 24, 28]
55
+ ]
56
+ ),
57
+ 8 => DesignSet.new(
58
+ nyq: 101, freqs: [
59
+ [1, 4, 5, 17, 21, 27, 41, 45],
60
+ [1, 5, 6, 14, 15, 17, 38, 41],
61
+ [2, 8, 10, 11, 19, 34, 42, 47],
62
+ [2, 14, 29, 31, 38, 40, 48, 50],
63
+ [3, 5, 8, 24, 28, 33, 42, 47],
64
+ [3, 13, 15, 18, 22, 42, 45, 50],
65
+ [4, 7, 16, 17, 20, 22, 26, 45],
66
+ [5, 7, 13, 25, 29, 31, 40, 42],
67
+ [5, 8, 12, 20, 26, 34, 43, 45]
68
+ ]
69
+ ),
70
+ 9 => DesignSet.new(
71
+ nyq: 127, freqs: [
72
+ [1, 3, 10, 11, 15, 33, 38, 49, 57],
73
+ [1, 7, 8, 18, 19, 24, 39, 52, 53],
74
+ [1, 7, 8, 18, 19, 24, 52, 53, 62],
75
+ [1, 9, 13, 22, 28, 37, 42, 51, 58],
76
+ [1, 13, 14, 22, 23, 54, 55, 61, 62],
77
+ [1, 29, 38, 39, 41, 54, 55, 61, 62],
78
+ [2, 3, 5, 11, 15, 31, 38, 50, 52],
79
+ [2, 5, 20, 26, 28, 39, 41, 55, 63],
80
+ [3, 4, 7, 12, 27, 29, 38, 47, 52],
81
+ [4, 5, 9, 11, 15, 23, 36, 48, 62],
82
+ [5, 7, 16, 20, 22, 28, 45, 46, 48],
83
+ [5, 7, 16, 20, 22, 28, 46, 48, 62],
84
+ [7, 13, 16, 18, 24, 28, 34, 51, 54],
85
+ [7, 17, 20, 24, 26, 30, 38, 42, 53]
86
+ ]
87
+ ),
88
+ 10 => DesignSet.new(
89
+ nyq: 149, freqs: [
90
+ [3, 15, 18, 25, 40, 41, 49, 56, 60, 61]
91
+ ]
92
+ ),
93
+ 11 => DesignSet.new(
94
+ nyq: 191, freqs: [
95
+ [1, 8, 9, 12, 19, 34, 41, 46, 62, 85, 93],
96
+ [1, 9, 22, 29, 41, 46, 52, 56, 59, 61, 94],
97
+ [1, 15, 16, 19, 20, 26, 27, 62, 75, 79, 84],
98
+ [1, 19, 25, 26, 35, 36, 40, 41, 48, 64, 94],
99
+ [2, 3, 10, 13, 19, 33, 44, 54, 58, 72, 82],
100
+ [2, 3, 11, 12, 31, 34, 44, 47, 61, 82, 87],
101
+ [2, 5, 7, 13, 18, 35, 38, 48, 67, 82, 85],
102
+ [2, 7, 15, 20, 31, 36, 48, 54, 57, 69, 73],
103
+ [3, 16, 19, 36, 39, 44, 47, 62, 65, 92, 95],
104
+ [4, 7, 11, 16, 20, 37, 41, 49, 55, 83, 84],
105
+ [4, 18, 19, 21, 22, 28, 31, 51, 60, 65, 76],
106
+ [5, 7, 13, 15, 16, 34, 35, 59, 67, 71, 79],
107
+ [6, 10, 16, 19, 25, 33, 39, 40, 46, 51, 93],
108
+ [8, 9, 17, 21, 28, 29, 31, 32, 70, 76, 88],
109
+ [9, 35, 38, 39, 47, 59, 65, 75, 84, 90, 92],
110
+ [12, 15, 16, 22, 34, 51, 53, 54, 65, 74, 79],
111
+ [16, 25, 30, 31, 33, 39, 43, 49, 77, 84, 85]
112
+ ]
113
+ ),
114
+ 12 => DesignSet.new(
115
+ nyq: 223, freqs: [
116
+ [1, 15, 16, 19, 20, 27, 28, 61, 62, 64, 86, 87],
117
+ [2, 8, 17, 19, 41, 43, 47, 48, 50, 61, 70, 73],
118
+ [2, 11, 13, 19, 21, 31, 33, 37, 82, 84, 109, 111],
119
+ [2, 19, 21, 39, 41, 47, 49, 50, 52, 64, 74, 108]
120
+ ]
121
+ ),
122
+ 13 => DesignSet.new(
123
+ nyq: 263, freqs: [
124
+ [1, 4, 5, 22, 23, 35, 36, 55, 56, 84, 98, 99, 126]
125
+ ]
126
+ ),
127
+ 14 => DesignSet.new(
128
+ nyq: 331, freqs: [
129
+ [1, 3, 7, 19, 26, 36, 47, 60, 70, 79, 128, 148, 153, 161]
130
+ ]
131
+ ),
132
+ 15 => DesignSet.new(
133
+ nyq: 389, freqs: [
134
+ [1, 3, 7, 12, 29, 40, 49, 65, 91, 100, 125, 131, 148, 154, 172]
135
+ ]
136
+ ),
137
+ 20 => DesignSet.new(
138
+ nyq: 853, freqs: [
139
+ [1, 3, 7, 12, 15, 25, 41, 58, 60, 80, 107, 154, 161, 193, 232, 249, 284, 291, 377, 412]
140
+ ]
141
+ )
142
+ }.freeze
143
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DataFarming
4
+ VERSION = "2.1.0"
5
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "datafarming/version"
4
+
5
+ module DataFarming
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datafarming
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul J Sanchez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-19 00:00:00.000000000 Z
11
+ date: 2023-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fwt
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.8'
33
+ version: '1'
34
34
  type: :runtime
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.8'
40
+ version: '1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: quickstats
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,11 +52,38 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2'
55
- description: Ruby scripts for data farming, including pre- and post-processing, design
55
+ - !ruby/object:Gem::Dependency
56
+ name: optparse
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.4'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yaml
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.3'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.3'
83
+ description: Ruby scripts for data farming, including pre- andpost-processing, design
56
84
  generation and scaling, and run control.
57
85
  email: pjs@alum.mit.edu
58
86
  executables:
59
- - augment_design.rb
60
87
  - batchrunner.rb
61
88
  - blank2csv.rb
62
89
  - cat.rb
@@ -64,26 +91,21 @@ executables:
64
91
  - cross.rb
65
92
  - csv2blank.rb
66
93
  - datafarming.rb
94
+ - generate_design.rb
67
95
  - moving_average.rb
68
96
  - mser.rb
69
97
  - mser_nolbm.rb
70
98
  - mser_olbm.rb
71
99
  - pool_files.rb
72
100
  - rundesign_general.rb
73
- - scaled_fde.rb
74
- - scaled_rf_cubed.rb
75
- - stack_nolhs.rb
76
101
  - stripheaderdups.rb
77
102
  - stripheaders.rb
78
103
  extensions: []
79
104
  extra_rdoc_files: []
80
105
  files:
81
- - DESCRIPTIONS.html
82
- - DESCRIPTIONS.md
83
106
  - LICENSE.md
84
107
  - README.md
85
108
  - datafarming.gemspec
86
- - exe/augment_design.rb
87
109
  - exe/batchrunner.rb
88
110
  - exe/blank2csv.rb
89
111
  - exe/cat.rb
@@ -91,23 +113,25 @@ files:
91
113
  - exe/cross.rb
92
114
  - exe/csv2blank.rb
93
115
  - exe/datafarming.rb
116
+ - exe/generate_design.rb
94
117
  - exe/moving_average.rb
95
118
  - exe/mser.rb
96
119
  - exe/mser_nolbm.rb
97
120
  - exe/mser_olbm.rb
98
121
  - exe/pool_files.rb
99
122
  - exe/rundesign_general.rb
100
- - exe/scaled_fde.rb
101
- - exe/scaled_rf_cubed.rb
102
- - exe/stack_nolhs.rb
103
123
  - exe/stripheaderdups.rb
104
124
  - exe/stripheaders.rb
125
+ - lib/datafarming.rb
105
126
  - lib/datafarming/cross.rb
106
127
  - lib/datafarming/error_handling.rb
107
- - lib/datafarming/factorial_generator.rb
108
128
  - lib/datafarming/freq_sets.rb
109
129
  - lib/datafarming/moving_average.rb
110
130
  - lib/datafarming/nolh_designs.rb
131
+ - lib/datafarming/res_v_seqs.rb
132
+ - lib/datafarming/scale_design.rb
133
+ - lib/datafarming/screen_freq_sets.rb
134
+ - lib/datafarming/version.rb
111
135
  homepage: https://bitbucket.org/paul_j_sanchez/datafarmingrubyscripts
112
136
  licenses:
113
137
  - MIT
@@ -120,14 +144,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
144
  requirements:
121
145
  - - ">="
122
146
  - !ruby/object:Gem::Version
123
- version: '2.5'
147
+ version: '2.6'
124
148
  required_rubygems_version: !ruby/object:Gem::Requirement
125
149
  requirements:
126
150
  - - ">="
127
151
  - !ruby/object:Gem::Version
128
152
  version: '0'
129
153
  requirements: []
130
- rubygems_version: 3.2.3
154
+ rubygems_version: 3.4.20
131
155
  signing_key:
132
156
  specification_version: 4
133
157
  summary: Useful scripts for data farming.