philiprehberger-math_kit 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5160a941a8d5e202674e87876873e770f8c1977e9a16bcc3123e58a5a6b665d
4
- data.tar.gz: b3ec9ac5e16e4defa442e6c9470065540da9acbbe4281884b034a66d91ec5b57
3
+ metadata.gz: 749c0a9a1c673c58a1ba320d3bbf2dacf89328a3feedb166d76ef18dcca60284
4
+ data.tar.gz: 5698fb8599aa8343585a5cd64cd5b95bce81b6fb919a688aa7435af9a60882ae
5
5
  SHA512:
6
- metadata.gz: 75957977d35a9313b370f65ab8c9bc99fa267eb0b14e93a4c2e802ef671ea5926991e871fc8794724dd3c58c1dec49accbca4d34ab181dac5907c257a4fcf998
7
- data.tar.gz: ef5a5f0e61a225e88b8a232da5e60472a7aad51c0512163eb82a5e85207977fce943388142fcaa210252d8a104392a472a7069fc16dc38e2b5e70b5d4d9027e2
6
+ metadata.gz: 8019d5ee6e9f7e78cb2609f830d944f164aa77a333b49abadd6e75d4c62e3ba100f022f7c2212648bff3ac1d4ac362f6ec1cd575acad39164992727cb6aa2f44
7
+ data.tar.gz: 392bb7e9c895353d838582f5d80467d8edd3f46ecc9f0bb98c854079106dedcfd5c38f79e03646371f05b08cb847799d92f8041bba05c088374ea6664ab255d9
data/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.6.0] - 2026-05-07
11
+
12
+ ### Added
13
+ - `Stats.iqr(values)` — interquartile range (Q3 - Q1), commonly used for outlier detection.
14
+
10
15
  ## [0.5.0] - 2026-04-21
11
16
 
12
17
  ### Added
@@ -82,7 +87,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
82
87
  - Rounding modes: bankers (round half to even), ceiling, floor, truncate with precision
83
88
  - Simple moving average and exponential moving average
84
89
 
85
- [Unreleased]: https://github.com/philiprehberger/rb-math-kit/compare/v0.4.0...HEAD
90
+ [Unreleased]: https://github.com/philiprehberger/rb-math-kit/compare/v0.6.0...HEAD
91
+ [0.6.0]: https://github.com/philiprehberger/rb-math-kit/compare/v0.5.0...v0.6.0
92
+ [0.5.0]: https://github.com/philiprehberger/rb-math-kit/compare/v0.4.0...v0.5.0
86
93
  [0.4.0]: https://github.com/philiprehberger/rb-math-kit/compare/v0.3.0...v0.4.0
87
94
  [0.3.0]: https://github.com/philiprehberger/rb-math-kit/compare/v0.2.3...v0.3.0
88
95
  [0.2.3]: https://github.com/philiprehberger/rb-math-kit/compare/v0.2.2...v0.2.3
data/README.md CHANGED
@@ -44,6 +44,12 @@ Philiprehberger::MathKit::Stats.range([1, 5, 3, 9, 2]) # => 8
44
44
  Philiprehberger::MathKit::Stats.sum_of_squares([1, 2, 3]) # => 2.0
45
45
  ```
46
46
 
47
+ ### Interquartile Range
48
+
49
+ ```ruby
50
+ Philiprehberger::MathKit::Stats.iqr([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) # => 4.5
51
+ ```
52
+
47
53
  ### Summary Statistics
48
54
 
49
55
  ```ruby
@@ -161,6 +167,7 @@ Philiprehberger::MathKit::Numeric.clamp(42, 0, 10) # => 10
161
167
  | `.variance(values, population: true)` | Population or sample variance |
162
168
  | `.stddev(values, population: true)` | Standard deviation |
163
169
  | `.percentile(values, p)` | Percentile (0-100) with linear interpolation |
170
+ | `.iqr(values)` | Interquartile range (Q3 - Q1) |
164
171
  | `.sum(values)` | Sum of values |
165
172
  | `.sum_of_squares(values)` | Sum of squared deviations from the mean (0.0 for empty/single input) |
166
173
  | `.range(values)` | Max - min |
@@ -97,6 +97,17 @@ module Philiprehberger
97
97
  (sorted[lower] + (fraction * (sorted[upper] - sorted[lower]))).to_f
98
98
  end
99
99
 
100
+ # Interquartile range (Q3 - Q1) using linear interpolation
101
+ #
102
+ # @param values [Array<Numeric>] the input values
103
+ # @return [Float] Q3 minus Q1
104
+ # @raise [ArgumentError] if values is empty
105
+ def iqr(values)
106
+ raise ArgumentError, 'values must not be empty' if values.empty?
107
+
108
+ percentile(values, 75) - percentile(values, 25)
109
+ end
110
+
100
111
  # Sum of values
101
112
  #
102
113
  # @param values [Array<Numeric>] the input values
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module MathKit
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philiprehberger-math_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Rehberger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-21 00:00:00.000000000 Z
11
+ date: 2026-05-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Descriptive statistics, linear interpolation, rounding modes, and moving
14
14
  averages. Lightweight math toolkit with zero dependencies.