166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
# File 'lib/zerbo.rb', line 166
def filtered
unless @filtered
filter = [
0.0056, 0.0190, 0.0113, -0.0106, 0.0029, 0.0041,
-0.0082, 0.0089, -0.0062, 0.0006, 0.0066, -0.0129,
0.0157, -0.0127, 0.0035, 0.0102, -0.0244, 0.0336,
-0.0323, 0.0168, 0.0136, -0.0555, 0.1020, -0.1446,
0.1743, 0.8150, 0.1743, -0.1446, 0.1020, -0.0555,
0.0136, 0.0168, -0.0323, 0.0336, -0.0244, 0.0102,
0.0035, -0.0127, 0.0157, -0.0129, 0.0066, 0.0006,
-0.0062, 0.0089, -0.0082, 0.0041, 0.0029, -0.0106,
0.0113, 0.0190, 0.0056
]
p = raw.length
q = filter.length
n = p + q - 1
@filtered = []
n.times do |k|
t = 0
lower = [0, k-(q-1)].max
upper = [p-1, k].min
lower.upto(upper) do |i|
t = t + raw[i] * filter[k-i]
end
@filtered << (t*1e6).round/1e6
end
end
@filtered
end
|