Skip to content

Commit

Permalink
Adjusted Precentile for interquartile range (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
brand-it authored Nov 9, 2024
1 parent 4912fda commit e21fe8a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
12 changes: 9 additions & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 1000`
# on 2024-11-08 20:15:10 UTC using RuboCop version 1.68.0.
# on 2024-11-09 21:50:10 UTC using RuboCop version 1.68.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -18,7 +18,7 @@ Lint/UnreachableCode:
Exclude:
- 'lib/tasks/upload.rake'

# Offense count: 24
# Offense count: 26
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 72
Expand All @@ -28,6 +28,12 @@ Metrics/AbcSize:
Metrics/ClassLength:
Max: 222

# Offense count: 1
# Configuration parameters: LengthThreshold.
Metrics/CollectionLiteralLength:
Exclude:
- 'spec/services/stats_service_spec.rb'

# Offense count: 5
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Expand Down Expand Up @@ -108,7 +114,7 @@ Style/SafeNavigationChainLength:
- 'app/controllers/start_controller.rb'
- 'app/services/key_parser_service.rb'

# Offense count: 21
# Offense count: 28
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Expand Down
4 changes: 2 additions & 2 deletions app/services/stats_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def median_difference
end

def differences
@differences ||= list.uniq.permutation(2).map { _1.inject(:-).abs }.uniq.sort
@differences ||= list.uniq.permutation(2).map { _1.inject(:-).abs }.sort
end

def weighted_average_difference
Expand All @@ -60,7 +60,7 @@ def interquartile_range
return if differences.empty?

q1 = differences[(differences.size * 0.25).floor]
q3 = differences[(differences.size * 0.75).floor]
q3 = differences[(differences.size * 0.50).floor]
iqr = q3 - q1

upper_bound = q3 + (1.5 * iqr)
Expand Down
2 changes: 1 addition & 1 deletion current_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v5.13.0
v5.14.0
12 changes: 8 additions & 4 deletions spec/services/stats_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
context 'when a bunch of values are given' do
let(:list) { [2579, 2498, 2549, 2575, 2573, 2486, 2518, 2580, 2494, 2577, 2575, 2575, 2577, 2443, 2578, 2441, 2521, 2561, 2580, 2534, 2571, 2565, 5062] }
let(:differences) do
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 35, 36, 37, 39, 40, 41, 43, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 67, 71, 73,
75, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 89, 91, 92, 93, 94, 106, 108, 118, 120, 122, 124, 128, 130, 132, 134, 135, 136, 137, 138, 139, 2482, 2483, 2484, 2485, 2487, 2489, 2491, 2497, 2501, 2513, 2528, 2541, 2544,
2564, 2568, 2576, 2619, 2621]
[1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13,
13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 22, 22, 23, 23, 24, 24, 24, 24, 26, 26, 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 30, 30, 31, 31, 31, 31, 31, 31, 32, 32, 35, 35,
36, 36, 37, 37, 39, 39, 40, 40, 40, 40, 41, 41, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44, 45, 45, 45, 45, 46, 46, 47, 47, 48, 48, 50, 50, 51, 51, 51, 51, 52, 52, 53, 53, 53, 53, 54, 54, 55, 55, 55, 55, 55, 55, 56, 56, 57, 57,
57, 57, 57, 57, 58, 58, 59, 59, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63, 63, 63, 67, 67, 67, 67, 71, 71, 73, 73, 75, 75, 75, 75, 75, 75, 77, 77, 77, 77, 77, 77, 78, 78, 79, 79, 79, 79, 79, 79, 80, 80, 80, 80, 81, 81, 81, 81,
82, 82, 83, 83, 84, 84, 85, 85, 85, 85, 86, 86, 87, 87, 89, 89, 91, 91, 91, 91, 92, 92, 93, 93, 93, 93, 94, 94, 106, 106, 108, 108, 118, 118, 120, 120, 122, 122, 124, 124, 128, 128, 130, 130, 130, 130, 132, 132, 132, 132,
134, 134, 134, 134, 135, 135, 136, 136, 136, 136, 137, 137, 137, 137, 138, 138, 139, 139, 2482, 2482, 2483, 2483, 2484, 2484, 2485, 2485, 2487, 2487, 2489, 2489, 2491, 2491, 2497, 2497, 2501, 2501, 2513, 2513, 2528, 2528,
2541, 2541, 2544, 2544, 2564, 2564, 2568, 2568, 2576, 2576, 2619, 2619, 2621, 2621]
end

it { is_expected.to eq(described_class::Info.new(2575, 2573.7497394471216, 62.5, 62.79612125669019, 139, 2621, differences)) }
it { is_expected.to eq(described_class::Info.new(2575, 2573.7497394471216, 54.0, 53.98761880330858, 108, 2621, differences)) }
end

context 'when nothing is given' do
Expand Down

0 comments on commit e21fe8a

Please sign in to comment.