philiprehberger-math_kit 0.4.0 → 0.5.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -0
- data/lib/philiprehberger/math_kit/stats.rb +13 -0
- data/lib/philiprehberger/math_kit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e5160a941a8d5e202674e87876873e770f8c1977e9a16bcc3123e58a5a6b665d
|
|
4
|
+
data.tar.gz: b3ec9ac5e16e4defa442e6c9470065540da9acbbe4281884b034a66d91ec5b57
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 75957977d35a9313b370f65ab8c9bc99fa267eb0b14e93a4c2e802ef671ea5926991e871fc8794724dd3c58c1dec49accbca4d34ab181dac5907c257a4fcf998
|
|
7
|
+
data.tar.gz: ef5a5f0e61a225e88b8a232da5e60472a7aad51c0512163eb82a5e85207977fce943388142fcaa210252d8a104392a472a7069fc16dc38e2b5e70b5d4d9027e2
|
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.5.0] - 2026-04-21
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `Stats.sum_of_squares(values)` — sum of squared deviations from the mean, a building block for variance, regression residuals, and ANOVA; returns 0.0 for empty or single-element inputs
|
|
14
|
+
|
|
10
15
|
## [0.4.0] - 2026-04-15
|
|
11
16
|
|
|
12
17
|
### Added
|
data/README.md
CHANGED
|
@@ -41,6 +41,7 @@ Philiprehberger::MathKit::Stats.stddev([2, 4, 4, 4, 5, 5, 7, 9]) # => 2.0
|
|
|
41
41
|
Philiprehberger::MathKit::Stats.percentile([1, 2, 3, 4, 5], 50) # => 3.0
|
|
42
42
|
Philiprehberger::MathKit::Stats.sum([1, 2, 3]) # => 6
|
|
43
43
|
Philiprehberger::MathKit::Stats.range([1, 5, 3, 9, 2]) # => 8
|
|
44
|
+
Philiprehberger::MathKit::Stats.sum_of_squares([1, 2, 3]) # => 2.0
|
|
44
45
|
```
|
|
45
46
|
|
|
46
47
|
### Summary Statistics
|
|
@@ -161,6 +162,7 @@ Philiprehberger::MathKit::Numeric.clamp(42, 0, 10) # => 10
|
|
|
161
162
|
| `.stddev(values, population: true)` | Standard deviation |
|
|
162
163
|
| `.percentile(values, p)` | Percentile (0-100) with linear interpolation |
|
|
163
164
|
| `.sum(values)` | Sum of values |
|
|
165
|
+
| `.sum_of_squares(values)` | Sum of squared deviations from the mean (0.0 for empty/single input) |
|
|
164
166
|
| `.range(values)` | Max - min |
|
|
165
167
|
| `.skewness(values)` | Sample skewness (Fisher-Pearson) |
|
|
166
168
|
| `.kurtosis(values)` | Sample excess kurtosis (Fisher definition) |
|
|
@@ -105,6 +105,19 @@ module Philiprehberger
|
|
|
105
105
|
values.sum
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
+
# Sum of squared deviations from the mean: \sum_i (x_i - mean)^2.
|
|
109
|
+
# Building block for variance, regression residuals, ANOVA, etc.
|
|
110
|
+
# Returns 0.0 for empty or single-element inputs.
|
|
111
|
+
#
|
|
112
|
+
# @param values [Array<Numeric>] the input values
|
|
113
|
+
# @return [Float] the sum of squares
|
|
114
|
+
def sum_of_squares(values)
|
|
115
|
+
return 0.0 if values.size < 2
|
|
116
|
+
|
|
117
|
+
avg = mean(values)
|
|
118
|
+
values.sum(0.0) { |v| (v - avg)**2 }
|
|
119
|
+
end
|
|
120
|
+
|
|
108
121
|
# Range (max - min)
|
|
109
122
|
#
|
|
110
123
|
# @param values [Array<Numeric>] the input values
|
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.
|
|
4
|
+
version: 0.5.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-
|
|
11
|
+
date: 2026-04-21 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.
|