aggregationslib 0.1.6__tar.gz → 0.2.0__tar.gz

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.
Files changed (79) hide show
  1. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/.gitignore +3 -0
  2. aggregationslib-0.2.0/PKG-INFO +319 -0
  3. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/README.md +80 -6
  4. aggregationslib-0.2.0/README.pl.md +735 -0
  5. aggregationslib-0.2.0/README.rst +297 -0
  6. aggregationslib-0.2.0/aggregationslib/__init__.py +47 -0
  7. aggregationslib-0.2.0/aggregationslib/aggregation.py +399 -0
  8. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/aggregationslib/aggregations.py +78 -19
  9. aggregationslib-0.2.0/aggregationslib/decimalaggregations.py +502 -0
  10. aggregationslib-0.2.0/aggregationslib/feature_selection/binary_fuzzy_entropy.py +104 -0
  11. aggregationslib-0.2.0/aggregationslib/feature_selection/fuzzy_com_entropy.py +424 -0
  12. aggregationslib-0.2.0/aggregationslib.egg-info/PKG-INFO +319 -0
  13. aggregationslib-0.2.0/aggregationslib.egg-info/SOURCES.txt +69 -0
  14. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/aggregationslib.egg-info/requires.txt +2 -0
  15. aggregationslib-0.2.0/aggregationslib.egg-info/scm_file_list.json +66 -0
  16. aggregationslib-0.2.0/aggregationslib.egg-info/scm_version.json +8 -0
  17. aggregationslib-0.2.0/assets/icons/icon.ico +0 -0
  18. aggregationslib-0.2.0/assets/icons/icon.png +0 -0
  19. aggregationslib-0.2.0/assets/icons/icon.svg +12 -0
  20. aggregationslib-0.2.0/build_docs.ps1 +49 -0
  21. aggregationslib-0.2.0/commands.md +1 -0
  22. aggregationslib-0.2.0/docs/.nojekyll +1 -0
  23. aggregationslib-0.2.0/docs/aggregation-classes.md +54 -0
  24. aggregationslib-0.2.0/docs/aggregation-plots.md +80 -0
  25. aggregationslib-0.2.0/docs/assets/aggregation-surfaces-all.png +0 -0
  26. aggregationslib-0.2.0/docs/assets/aggregation-surfaces.png +0 -0
  27. aggregationslib-0.2.0/docs/assets/aggregations/A_amn_p=0.5.png +0 -0
  28. aggregationslib-0.2.0/docs/assets/aggregations/A_amx_p=0.5.png +0 -0
  29. aggregationslib-0.2.0/docs/assets/aggregations/A_ar.png +0 -0
  30. aggregationslib-0.2.0/docs/assets/aggregations/A_ex2_p=2,q=2.png +0 -0
  31. aggregationslib-0.2.0/docs/assets/aggregations/A_ex3_p=2,q=1.5.png +0 -0
  32. aggregationslib-0.2.0/docs/assets/aggregations/A_ex_r=1.png +0 -0
  33. aggregationslib-0.2.0/docs/assets/aggregations/A_gm.png +0 -0
  34. aggregationslib-0.2.0/docs/assets/aggregations/A_hm.png +0 -0
  35. aggregationslib-0.2.0/docs/assets/aggregations/A_lm_r=2.png +0 -0
  36. aggregationslib-0.2.0/docs/assets/aggregations/A_lo.png +0 -0
  37. aggregationslib-0.2.0/docs/assets/aggregations/A_md.png +0 -0
  38. aggregationslib-0.2.0/docs/assets/aggregations/A_mn.png +0 -0
  39. aggregationslib-0.2.0/docs/assets/aggregations/A_mx.png +0 -0
  40. aggregationslib-0.2.0/docs/assets/aggregations/A_ol.png +0 -0
  41. aggregationslib-0.2.0/docs/assets/aggregations/A_oln_p=1.png +0 -0
  42. aggregationslib-0.2.0/docs/assets/aggregations/A_pr.png +0 -0
  43. aggregationslib-0.2.0/docs/assets/aggregations/A_pw_r=2.png +0 -0
  44. aggregationslib-0.2.0/docs/assets/aggregations/A_qd.png +0 -0
  45. aggregationslib-0.2.0/docs/assets/site.css +185 -0
  46. aggregationslib-0.2.0/docs/en/index.html +80 -0
  47. aggregationslib-0.2.0/docs/fuzzy-integrals.md +179 -0
  48. aggregationslib-0.2.0/docs/index.html +24 -0
  49. aggregationslib-0.2.0/docs/pl/index.html +80 -0
  50. aggregationslib-0.2.0/generate_aggregation_plots.py +107 -0
  51. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/pyproject.toml +7 -4
  52. aggregationslib-0.2.0/tests/data/wolfram_integral_reference.json +2648 -0
  53. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/tests/test_aggregations.py +27 -1
  54. aggregationslib-0.2.0/tests/test_decimal_fuzzy_integrals.py +186 -0
  55. aggregationslib-0.2.0/tests/test_fuzzy_integrals.py +175 -0
  56. aggregationslib-0.1.6/.github/workflows/python-publish.yml +0 -39
  57. aggregationslib-0.1.6/PKG-INFO +0 -214
  58. aggregationslib-0.1.6/README.rst +0 -195
  59. aggregationslib-0.1.6/aggregationslib/aggregation.py +0 -203
  60. aggregationslib-0.1.6/aggregationslib/decimalaggregations.py +0 -256
  61. aggregationslib-0.1.6/aggregationslib.egg-info/PKG-INFO +0 -214
  62. aggregationslib-0.1.6/aggregationslib.egg-info/SOURCES.txt +0 -28
  63. aggregationslib-0.1.6/commands.md +0 -1
  64. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/LICENSE +0 -0
  65. {aggregationslib-0.1.6/aggregationslib → aggregationslib-0.2.0/aggregationslib/conjuctive}/__init__.py +0 -0
  66. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/aggregationslib/conjuctive/purepython.py +0 -0
  67. {aggregationslib-0.1.6/aggregationslib/conjuctive → aggregationslib-0.2.0/aggregationslib/disjunctive}/__init__.py +0 -0
  68. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/aggregationslib/example.py +0 -0
  69. {aggregationslib-0.1.6/aggregationslib/disjunctive → aggregationslib-0.2.0/aggregationslib/feature_selection}/__init__.py +0 -0
  70. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/aggregationslib/models/__init__.py +0 -0
  71. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/aggregationslib/models/ensemble/__init__.py +0 -0
  72. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/aggregationslib/models/ensemble/aggregation_regressor.py +0 -0
  73. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/aggregationslib/models/single/__init__.py +0 -0
  74. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/aggregationslib/purepython.py +0 -0
  75. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/aggregationslib.egg-info/dependency_links.txt +0 -0
  76. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/aggregationslib.egg-info/top_level.txt +0 -0
  77. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/setup.cfg +0 -0
  78. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/tests/__init__.py +0 -0
  79. {aggregationslib-0.1.6 → aggregationslib-0.2.0}/tests/test_decimal_exponential_mean.py +0 -0
@@ -127,3 +127,6 @@ dmypy.json
127
127
 
128
128
  # Pyre type checker
129
129
  .pyre/
130
+
131
+ # Local scratch files and generated temporary data
132
+ /tmp/
@@ -0,0 +1,319 @@
1
+ Metadata-Version: 2.4
2
+ Name: aggregationslib
3
+ Version: 0.2.0
4
+ Summary: Python implementation of Arithmetic, quasi arithmetic and other aggregating functions
5
+ Author: wgalka
6
+ Project-URL: Homepage, https://github.com/wgalka/Means
7
+ Project-URL: Documentation, https://wgalka.github.io/Means/
8
+ Project-URL: Download, https://github.com/wgalka/Means/releases/latest
9
+ Classifier: Programming Language :: Python :: 3.14
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.14
12
+ Description-Content-Type: text/x-rst
13
+ License-File: LICENSE
14
+ Requires-Dist: numpy>=2.2.2
15
+ Requires-Dist: pynverse
16
+ Requires-Dist: scikit-learn
17
+ Requires-Dist: pandas
18
+ Requires-Dist: scipy
19
+ Provides-Extra: test
20
+ Requires-Dist: pytest>=8.3.4; extra == "test"
21
+ Dynamic: license-file
22
+
23
+ Means
24
+ =====
25
+
26
+ Means, Aggregation functions...
27
+
28
+ Documentation:
29
+
30
+ - English: https://wgalka.github.io/Means/en/
31
+ - Polski: https://wgalka.github.io/Means/pl/
32
+
33
+ Aggregations functions are:
34
+
35
+ - Conjuctive - the final aggregated value will always be influenced by
36
+ the smallest value among the inputs.
37
+ - Disjnuctive - the aggregated value will always be influenced by the
38
+ largest value among the inputs.
39
+
40
+ Example 1:
41
+ ^^^^^^^^^^
42
+
43
+ .. code:: pycon
44
+
45
+ # example data
46
+ data = [0.2, 0.6, 0.7]
47
+ # configure function parameters
48
+ func1 = A_amn(p=0.5)
49
+ # use aggregation funciton
50
+ print(func1(data))
51
+
52
+ # Combine two aggregations - arithmetic mean and minimum
53
+ func2 = Combine2Aggregations(A_ar(), min)
54
+ # use combination of aggregation funciton
55
+ print(func2(data))
56
+
57
+ Example2:
58
+ ^^^^^^^^^
59
+
60
+ To get information about aggregation function you can use ``__str__()``
61
+ or '**repr**\ ()' methods.
62
+
63
+ .. code:: pycon
64
+
65
+ func1 = A_amn(p=0.5)
66
+ print(func1)
67
+ >>>A_amn(0.5)
68
+
69
+ func2 = Combine2Aggregations(A_ar(), A_md())
70
+ print(func2)
71
+ >>>A_armd
72
+
73
+ func3 = Combine2Aggregations(A_ar(), A_pw(r=3))
74
+ print(func3.__repr__()) # function parameters are printed in order: func1, func2
75
+ >>>A_arpw(r=3)
76
+
77
+ Aggregation functions
78
+ ---------------------
79
+
80
+ An aggregation function on the unit interval [1] is an increasing
81
+ mapping :math:`A:[0,1]^n\to[0,1]`, :math:`n \in \mathbb{N}`,
82
+ :math:`n\ge 2`, satisfying :math:`A(0,\dots,0) = 0` and
83
+ :math:`A(1,\dots,1) = 1`. For inputs on another interval
84
+ :math:`[a,b]\subset\mathbb{R}`, an :math:`[a,b]`-aggregation is an
85
+ increasing mapping :math:`A:[a,b]^n\to[a,b]` satisfying
86
+ :math:`A(a,\dots,a)=a` and :math:`A(b,\dots,b)=b`.
87
+
88
+ The following aggregation functions are implemented in this library.
89
+ Tags describe properties of each formula. ``averaging`` means the result
90
+ lies between the minimum and maximum inputs; ``conjunctive`` means it
91
+ does not exceed the minimum; ``symmetric`` means permuting the inputs
92
+ does not change the result. ``aggregation interval`` states the
93
+ intervals on which the formula is an aggregation function: an increasing
94
+ map :math:`A:[a,b]^n\to[a,b]` satisfying :math:`A(a,\dots,a)=a` and
95
+ :math:`A(b,\dots,b)=b`. ``any [a,b] ⊂ ℝ`` includes intervals with
96
+ negative values; ``any [a,b] ⊆ [0,∞)`` is restricted to nonnegative
97
+ intervals. ``[0,1]`` means only the unit interval. These are
98
+ mathematical properties; most callable objects do not validate input
99
+ bounds at runtime. Some tags depend on parameters or the fuzzy measure.
100
+
101
+ :math:`\mathbf{A_{ch}^{(\mu)}}` **- Choquet integral [1]**
102
+
103
+ Tags: ``averaging`` ``aggregation interval: [0,1]``
104
+ ``symmetric if μ is symmetric``
105
+
106
+ For an input vector :math:`(x_1,\dots,x_n)\in[0,1]^n`, let
107
+ :math:`\sigma` sort its indices so that
108
+ :math:`x_{\sigma(1)} \leq \dots \leq x_{\sigma(n)}`. Define
109
+ :math:`A_i=\{\sigma(i),\dots,\sigma(n)\}` and :math:`x_{\sigma(0)}=0`:
110
+
111
+ .. math:: A_{ch}^{(\mu)}(x_1,\dots,x_n)=\sum_{i=1}^{n}(x_{\sigma(i)}-x_{\sigma(i-1)})\,\mu(A_i)
112
+
113
+ With the default cardinality measure :math:`\mu(A)=|A|/n`, this is the
114
+ arithmetic mean,
115
+ :math:`A_{ch}^{(\mu)}(x_1,\dots,x_n)=\frac{1}{n}\sum_{i=1}^{n}x_i`.
116
+
117
+ :math:`\mathbf{A_{sg}^{(\mu)}}` **- Sugeno integral [1]**
118
+
119
+ Tags: ``averaging`` ``aggregation interval: [0,1]``
120
+ ``symmetric if μ is symmetric``
121
+
122
+ For an input vector :math:`(x_1,\dots,x_n)\in[0,1]^n`, let
123
+ :math:`\sigma` sort its indices so that
124
+ :math:`x_{\sigma(1)} \leq \dots \leq x_{\sigma(n)}`, and define
125
+ :math:`A_i=\{\sigma(i),\dots,\sigma(n)\}`:
126
+
127
+ .. math:: A_{sg}^{(\mu)}(x_1,\dots,x_n)=\max_{1\leq i\leq n}\min(x_{\sigma(i)},\mu(A_i))
128
+
129
+ :math:`\mathbf{A_{ar}}` **- Arithmetic mean**
130
+
131
+ Tags: ``averaging`` ``symmetric``
132
+ ``aggregation interval: any [a,b] ⊂ ℝ``
133
+
134
+ .. math:: A_{ar}(x_1,...,x_n)=\frac{1}{n}\sum \limits_{k=1}^{n} x_k
135
+
136
+ :math:`\mathbf{A_{qd}}` **- Quadratic mean**
137
+
138
+ Tags: ``averaging`` ``symmetric``
139
+ ``aggregation interval: any [a,b] ⊆ [0,∞)``
140
+
141
+ .. math::
142
+
143
+ A_{qd}(x_1,...,x_n)=\sqrt{\frac{1}{n}\sum
144
+ \limits_{k=1}^{n} x_k^2}
145
+
146
+ :math:`\mathbf{A_{pr}}` **- Product aggregation**
147
+
148
+ Tags: ``conjunctive`` ``symmetric`` ``aggregation interval: [0,1]``
149
+
150
+ .. math:: A_{pr}(x_1, x_2, \dots, x_n) = \prod_{k=1}^n x_k
151
+
152
+ :math:`\mathbf{A_{gm}}` **- Geometric mean**
153
+
154
+ Tags: ``averaging`` ``symmetric``
155
+ ``aggregation interval: any [a,b] ⊆ [0,∞)``
156
+
157
+ .. math::
158
+
159
+ A_{gm}(x_1,...,x_n)=\sqrt[n]{\prod
160
+ \limits_{k=1}^{n} x_k}
161
+
162
+ :math:`\mathbf{A_{hm}}` **- Harmonic mean**
163
+
164
+ Tags: ``averaging`` ``symmetric``
165
+ ``aggregation interval: any [a,b] ⊆ [0,∞)``
166
+
167
+ .. math::
168
+
169
+
170
+ A_{hm}(x_1,...,x_n) =
171
+ \begin{cases}
172
+ 0, & \text{if } \exists k,\, 1 \leq k \leq n : x_k = 0 \\
173
+ \frac{n}{\sum\limits_{k=1}^{n} \frac{1}{x_k}}, & \text{otherwise}
174
+ \end{cases}
175
+
176
+ :math:`\mathbf{A_{pw}^{(r)}}` **- Power mean**
177
+
178
+ Tags: ``averaging`` ``symmetric``
179
+ ``aggregation interval: any [a,b] ⊆ [0,∞)`` ``r ≠ 0``
180
+
181
+ .. math::
182
+
183
+
184
+ A_{pw}^{(r)}(x_1,...,x_n) =
185
+ \begin{cases}
186
+ 0, & r < 0, \; \exists k,\, 1 \leq k \leq n : x_k = 0 \\
187
+ \Big(\frac{1}{n} \sum\limits_{k=1}^{n} x_k^r \Big)^{\frac{1}{r}}, & \text{otherwise}
188
+ \end{cases}
189
+
190
+ special cases of power means :math:`A_{\text{pw}}^r` [1] are:
191
+
192
+ - Arithmetic Mean where r=1;
193
+ - Quadratic Mean where r=2;
194
+ - Harmonic Mean where r=-1;
195
+ - Geometric Mean obtained as the limit
196
+ :math:`\lim_{r \to 0} A_{\text{pw}}^r`.
197
+
198
+ --------------
199
+
200
+ :math:`\mathbf{A_{ex}^{(r)}}` **- Exponential mean**
201
+
202
+ Tags: ``averaging`` ``symmetric``
203
+ ``aggregation interval: any [a,b] ⊂ ℝ`` ``r ≠ 0``
204
+
205
+ .. math::
206
+
207
+ A_{ex}^{(r)}(x_1,...,x_n)= \frac{1}{r}\ln
208
+ \Big(\frac{1}{n} \sum \limits_{k=1}^{n} e^{rx_k}\Big), \text{where
209
+ } r \in \mathbb{R}, r \neq 0
210
+
211
+ For computer implementations, to avoid numerical instability (overflow
212
+ when :math:`r x_k > 709.78` or underflow when all
213
+ :math:`r x_k < -709.78`), we use a numerically stable Log-Sum-Exp
214
+ formulation by shifting the exponents by
215
+ :math:`a_{max} = \max_{j} (r x_j)`:
216
+
217
+ .. math:: A_{ex}^{(r)}(x_1,...,x_n) = \frac{1}{r} \left[ a_{max} + \ln \left( \sum_{i=1}^n e^{r x_i - a_{max}} \right) - \ln(n) \right]
218
+
219
+ :math:`\mathbf{A_{lm}}` **- Lehmer mean**
220
+
221
+ Tags: ``averaging`` ``symmetric``
222
+ ``aggregation interval: any [a,b] ⊆ [0,∞) if 0 ≤ r ≤ 1``
223
+
224
+ .. math::
225
+
226
+ A_{lm}(x_1,...,x_n)= \begin{cases}
227
+ 0, & r\leq 1, \exists_{1 \leq k \leq n} x^{k} = 0 \\
228
+ \frac{\sum \limits_{k=1}^{n}x_k^r}{\sum \limits_{k=1}^{n}x_k^{r-1}}, & \text{otherwise}
229
+ \end{cases}
230
+
231
+ :math:`\mathbf{A_{amn}^{(p)}}` **- Arithmetic minimum mean**
232
+
233
+ Tags: ``averaging`` ``symmetric`` ``conjunctive if p = 0``
234
+ ``aggregation interval: any [a,b] ⊂ ℝ`` ``p ∈ [0,1]``
235
+
236
+ .. math::
237
+
238
+ A_{amn}^{(p)}(x_1,...,x_n)=\frac{p}{n}\sum \limits_{k=1}^{n} x_k+
239
+ (1-p) \min \limits_{1 \leq k \leq n}x_k, p \in [0, 1]
240
+
241
+ :math:`\mathbf{A_{amx}^{(p)}}` **- Arithmetic maximum mean**
242
+
243
+ Tags: ``averaging`` ``symmetric`` ``disjunctive if p = 0``
244
+ ``aggregation interval: any [a,b] ⊂ ℝ`` ``p ∈ [0,1]``
245
+
246
+ .. math::
247
+
248
+ A_{amx}^{(p)}(x_1,...,x_n)=\frac{p}{n}\sum \limits_{k=1}^{n} x_k+
249
+ (1-p) \max \limits_{1\leq k \leq n}x_k, p \in [0, 1]
250
+
251
+ OWA
252
+ ~~~
253
+
254
+ In the case of n = 2 (when only two values are aggregated) the
255
+ calculation of the median and the Olympic aggregation are reduced to the
256
+ case of calculating the arithmetic mean of the given values.
257
+
258
+ :math:`\mathbf{A_{md}}` **- Median - ordered weighted aggregation**
259
+
260
+ Tags: ``averaging`` ``symmetric``
261
+ ``aggregation interval: any [a,b] ⊂ ℝ``
262
+
263
+ .. math::
264
+
265
+ A_{md}(x_1,\dots,x_n) =
266
+ \begin{cases}
267
+ y_{(n+1)/2},&\text{if $n$ is odd}\\
268
+ \frac{y_{n/2}+y_{(n/2)+1}}{2},&\text{if $n$ is even}
269
+ \end{cases},
270
+
271
+ :math:`\mathbf{A_{ol}}` **- Olimpic aggregation**
272
+
273
+ Tags: ``averaging`` ``symmetric``
274
+ ``aggregation interval: any [a,b] ⊂ ℝ``
275
+
276
+ .. math:: A_{ol}(x_1,\dots,x_n) = \frac{1}{n-2} \sum \limits_{k=2}^{n-1} y_k, \quad \text{where } \{y_1, \dots, y_n\} = \{x_1, \dots, x_n\},\ y_1 \leq y_2 \leq \dots \leq y_n.
277
+
278
+ :math:`\mathbf{A_{oln}^{(p)}}` **- Olimpic aggregation**
279
+
280
+ Tags: ``averaging`` ``symmetric``
281
+ ``aggregation interval: any [a,b] ⊂ ℝ`` ``p ∈ ℕ, p ≥ 1``
282
+
283
+ We can specify how many greatest and smallest records remove
284
+
285
+ .. math:: A_{oln}^{(p)}(x_1,\dots,x_n) = \frac{1}{n-2p} \sum \limits_{k=p+1}^{n-p} y_k, \quad \text{where } \{y_1, \dots, y_n\} = \{x_1, \dots, x_n\},\ y_1 \leq y_2 \leq \dots \leq y_n, p \in \mathbb{N}, p\geq 1
286
+
287
+ --------------
288
+
289
+ :math:`\mathbf{A_{ln}}` **- Logaritmic aggregation [2]**
290
+
291
+ Tags: ``averaging (continuous formula)`` ``symmetric``
292
+ ``aggregation interval (after continuous extension): any [a,b] ⊂ (0,∞)``
293
+
294
+ .. math::
295
+
296
+
297
+ A_{ln}\left(x_1, x_2, \ldots, x_n\right)=(n-1) ! \sum_{i=1}^n \frac{x_i}{\prod_{\substack{j=1 \\ j \neq i}}^n \log \left(x_i / x_j\right)}
298
+
299
+ The formula has a continuous averaging extension when input values
300
+ coincide, but the current implementation does not handle ties: a zero
301
+ denominator makes it return ``0``.
302
+
303
+ :math:`\mathbf{A^{(p)}_{A_1,A_2}}` - Convex combinations of aggregation functions
304
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
305
+
306
+ Tags: ``aggregation interval: common interval of A₁ and A₂``
307
+ ``averaging if both inputs are averaging`` ``p ∈ [0,1]``
308
+
309
+ We can construct covex combination of aggregation functions as
310
+ :math:`A^{(p)}_{A_1,A_2}=pA_1+(1-p)A_2`, where :math:`A_1, A_2` are
311
+ aggregation functions and :math:`p \in [0,1]`.
312
+
313
+ References
314
+ ----------
315
+
316
+ 1. Beliakov, G., Bustince, H., and Calvo, T.: *A Practical Guide to
317
+ Averaging Functions*. Berlin: Springer, vol. 329, 2016.
318
+ 2. `Mustonen, Seppo. (2010). Logarithmic mean for several
319
+ arguments. <https://www.researchgate.net/publication/228886844_Logarithmic_mean_for_several_arguments>`__
@@ -1,6 +1,11 @@
1
1
  # Means
2
2
  Means, Aggregation functions...
3
3
 
4
+ Documentation:
5
+
6
+ - English: https://wgalka.github.io/Means/en/
7
+ - Polski: https://wgalka.github.io/Means/pl/
8
+
4
9
  Aggregations functions are:
5
10
  - Conjuctive - the final aggregated value will always be influenced by the smallest value among the inputs.
6
11
  - Disjnuctive - the aggregated value will always be influenced by the largest value among the inputs.
@@ -42,32 +47,77 @@ print(func3.__repr__()) # function parameters are printed in order: func1, func2
42
47
 
43
48
  ## Aggregation functions
44
49
 
45
- Aggregation function [1] is a mapping
46
- $A:[0,1]^n\to[0,1]$, $n \in \mathbb{N}$, $n\ge 2$ which is is increasing and
47
- fulfills two boundary conditions, namely $A(0,\dots,0) = 0$, $A(1,\dots,1) = 1$.
50
+ An aggregation function on the unit interval [1] is an increasing mapping
51
+ $A:[0,1]^n\to[0,1]$, $n \in \mathbb{N}$, $n\ge 2$, satisfying
52
+ $A(0,\dots,0) = 0$ and $A(1,\dots,1) = 1$. For inputs on another interval
53
+ $[a,b]\subset\mathbb{R}$, an $[a,b]$-aggregation is an increasing mapping
54
+ $A:[a,b]^n\to[a,b]$ satisfying $A(a,\dots,a)=a$ and $A(b,\dots,b)=b$.
55
+
56
+ The following aggregation functions are implemented in this library. Tags
57
+ describe properties of each formula. `averaging` means the result lies between
58
+ the minimum and maximum inputs; `conjunctive` means it does not exceed the
59
+ minimum; `symmetric` means permuting the inputs does not change the result.
60
+ `aggregation interval` states the intervals on which the formula is an
61
+ aggregation function: an increasing map $A:[a,b]^n\to[a,b]$ satisfying
62
+ $A(a,\dots,a)=a$ and $A(b,\dots,b)=b$. `any [a,b] ⊂ ℝ` includes intervals
63
+ with negative values; `any [a,b] ⊆ [0,∞)` is restricted to nonnegative
64
+ intervals. `[0,1]` means only the unit interval. These are mathematical
65
+ properties; most callable objects do not validate input bounds at runtime.
66
+ Some tags depend on parameters or the fuzzy measure.
67
+
68
+ $\mathbf{A_{ch}^{(\mu)}}$ **- Choquet integral [1]**
69
+
70
+ Tags: `averaging` `aggregation interval: [0,1]` `symmetric if μ is symmetric`
71
+
72
+ For an input vector $(x_1,\dots,x_n)\in[0,1]^n$, let $\sigma$
73
+ sort its indices so that $x_{\sigma(1)} \leq \dots \leq x_{\sigma(n)}$.
74
+ Define $A_i=\{\sigma(i),\dots,\sigma(n)\}$ and $x_{\sigma(0)}=0$:
75
+
76
+ $$A_{ch}^{(\mu)}(x_1,\dots,x_n)=\sum_{i=1}^{n}(x_{\sigma(i)}-x_{\sigma(i-1)})\,\mu(A_i)$$
48
77
 
49
- The floowoing aggregation functions are implemented in this library:
78
+ With the default cardinality measure $\mu(A)=|A|/n$, this is the arithmetic
79
+ mean, $A_{ch}^{(\mu)}(x_1,\dots,x_n)=\frac{1}{n}\sum_{i=1}^{n}x_i$.
80
+
81
+ $\mathbf{A_{sg}^{(\mu)}}$ **- Sugeno integral [1]**
82
+
83
+ Tags: `averaging` `aggregation interval: [0,1]` `symmetric if μ is symmetric`
84
+
85
+ For an input vector $(x_1,\dots,x_n)\in[0,1]^n$, let $\sigma$ sort its indices
86
+ so that $x_{\sigma(1)} \leq \dots \leq x_{\sigma(n)}$, and define
87
+ $A_i=\{\sigma(i),\dots,\sigma(n)\}$:
88
+
89
+ $$A_{sg}^{(\mu)}(x_1,\dots,x_n)=\max_{1\leq i\leq n}\min(x_{\sigma(i)},\mu(A_i))$$
50
90
 
51
91
  $\mathbf{A_{ar}}$ **- Arithmetic mean**
52
92
 
93
+ Tags: `averaging` `symmetric` `aggregation interval: any [a,b] ⊂ ℝ`
94
+
53
95
  $$A_{ar}(x_1,...,x_n)=\frac{1}{n}\sum \limits_{k=1}^{n} x_k$$
54
96
 
55
97
  $\mathbf{A_{qd}}$ **- Quadratic mean**
56
98
 
99
+ Tags: `averaging` `symmetric` `aggregation interval: any [a,b] ⊆ [0,∞)`
100
+
57
101
  $$A_{qd}(x_1,...,x_n)=\sqrt{\frac{1}{n}\sum
58
102
  \limits_{k=1}^{n} x_k^2}$$
59
103
 
60
104
  $\mathbf{A_{pr}}$ **- Product aggregation**
61
105
 
106
+ Tags: `conjunctive` `symmetric` `aggregation interval: [0,1]`
107
+
62
108
  $$A_{pr}(x_1, x_2, \dots, x_n) = \prod_{k=1}^n x_k$$
63
109
 
64
110
  $\mathbf{A_{gm}}$ **- Geometric mean**
65
111
 
112
+ Tags: `averaging` `symmetric` `aggregation interval: any [a,b] ⊆ [0,∞)`
113
+
66
114
  $$A_{gm}(x_1,...,x_n)=\sqrt[n]{\prod
67
115
  \limits_{k=1}^{n} x_k}$$
68
116
 
69
117
  $\mathbf{A_{hm}}$ **- Harmonic mean**
70
118
 
119
+ Tags: `averaging` `symmetric` `aggregation interval: any [a,b] ⊆ [0,∞)`
120
+
71
121
  $$
72
122
  A_{hm}(x_1,...,x_n) =
73
123
  \begin{cases}
@@ -79,6 +129,8 @@ $$
79
129
 
80
130
  $\mathbf{A_{pw}^{(r)}}$ **- Power mean**
81
131
 
132
+ Tags: `averaging` `symmetric` `aggregation interval: any [a,b] ⊆ [0,∞)` `r ≠ 0`
133
+
82
134
  $$
83
135
  A_{pw}^{(r)}(x_1,...,x_n) =
84
136
  \begin{cases}
@@ -99,6 +151,8 @@ special cases of power means $A_{\text{pw}}^r$ [1] are:
99
151
 
100
152
  $\mathbf{A_{ex}^{(r)}}$ **- Exponential mean**
101
153
 
154
+ Tags: `averaging` `symmetric` `aggregation interval: any [a,b] ⊂ ℝ` `r ≠ 0`
155
+
102
156
  $$A_{ex}^{(r)}(x_1,...,x_n)= \frac{1}{r}\ln
103
157
  \Big(\frac{1}{n} \sum \limits_{k=1}^{n} e^{rx_k}\Big), \text{where
104
158
  } r \in \mathbb{R}, r \neq 0$$
@@ -109,6 +163,8 @@ $$A_{ex}^{(r)}(x_1,...,x_n) = \frac{1}{r} \left[ a_{max} + \ln \left( \sum_{i=1}
109
163
 
110
164
  $\mathbf{A_{lm}}$ **- Lehmer mean**
111
165
 
166
+ Tags: `averaging` `symmetric` `aggregation interval: any [a,b] ⊆ [0,∞) if 0 ≤ r ≤ 1`
167
+
112
168
  $$A_{lm}(x_1,...,x_n)= \begin{cases}
113
169
  0, & r\leq 1, \exists_{1 \leq k \leq n} x^{k} = 0 \\
114
170
  \frac{\sum \limits_{k=1}^{n}x_k^r}{\sum \limits_{k=1}^{n}x_k^{r-1}}, & \text{otherwise}
@@ -116,11 +172,15 @@ $$A_{lm}(x_1,...,x_n)= \begin{cases}
116
172
 
117
173
  $\mathbf{A_{amn}^{(p)}}$ **- Arithmetic minimum mean**
118
174
 
175
+ Tags: `averaging` `symmetric` `conjunctive if p = 0` `aggregation interval: any [a,b] ⊂ ℝ` `p ∈ [0,1]`
176
+
119
177
  $$A_{amn}^{(p)}(x_1,...,x_n)=\frac{p}{n}\sum \limits_{k=1}^{n} x_k+
120
178
  (1-p) \min \limits_{1 \leq k \leq n}x_k, p \in [0, 1]$$
121
179
 
122
180
  $\mathbf{A_{amx}^{(p)}}$ **- Arithmetic maximum mean**
123
181
 
182
+ Tags: `averaging` `symmetric` `disjunctive if p = 0` `aggregation interval: any [a,b] ⊂ ℝ` `p ∈ [0,1]`
183
+
124
184
  $$A_{amx}^{(p)}(x_1,...,x_n)=\frac{p}{n}\sum \limits_{k=1}^{n} x_k+
125
185
  (1-p) \max \limits_{1\leq k \leq n}x_k, p \in [0, 1]$$
126
186
 
@@ -133,6 +193,8 @@ arithmetic mean of the given values.
133
193
 
134
194
  $\mathbf{A_{md}}$ **- Median - ordered weighted aggregation**
135
195
 
196
+ Tags: `averaging` `symmetric` `aggregation interval: any [a,b] ⊂ ℝ`
197
+
136
198
  $$A_{md}(x_1,\dots,x_n) =
137
199
  \begin{cases}
138
200
  y_{(n+1)/2},&\text{if $n$ is odd}\\
@@ -141,10 +203,14 @@ y_{(n+1)/2},&\text{if $n$ is odd}\\
141
203
 
142
204
  $\mathbf{A_{ol}}$ **- Olimpic aggregation**
143
205
 
206
+ Tags: `averaging` `symmetric` `aggregation interval: any [a,b] ⊂ ℝ`
207
+
144
208
  $$ A_{ol}(x_1,\dots,x_n) = \frac{1}{n-2} \sum \limits_{k=2}^{n-1} y_k, \quad \text{where } \{y_1, \dots, y_n\} = \{x_1, \dots, x_n\},\ y_1 \leq y_2 \leq \dots \leq y_n.$$
145
209
 
146
210
  $\mathbf{A_{oln}^{(p)}}$ **- Olimpic aggregation**
147
211
 
212
+ Tags: `averaging` `symmetric` `aggregation interval: any [a,b] ⊂ ℝ` `p ∈ ℕ, p ≥ 1`
213
+
148
214
  We can specify how many greatest and smallest records remove
149
215
 
150
216
  $$ A_{oln}^{(p)}(x_1,\dots,x_n) = \frac{1}{n-2p} \sum \limits_{k=p+1}^{n-p} y_k, \quad \text{where } \{y_1, \dots, y_n\} = \{x_1, \dots, x_n\},\ y_1 \leq y_2 \leq \dots \leq y_n, p \in \mathbb{N}, p\geq 1$$
@@ -152,18 +218,26 @@ $$ A_{oln}^{(p)}(x_1,\dots,x_n) = \frac{1}{n-2p} \sum \limits_{k=p+1}^{n-p} y_k
152
218
  --------------------
153
219
 
154
220
  $\mathbf{A_{ln}}$ **- Logaritmic aggregation [2]**
221
+
222
+ Tags: `averaging (continuous formula)` `symmetric` `aggregation interval (after continuous extension): any [a,b] ⊂ (0,∞)`
223
+
155
224
  $$
156
225
  A_{ln}\left(x_1, x_2, \ldots, x_n\right)=(n-1) ! \sum_{i=1}^n \frac{x_i}{\prod_{\substack{j=1 \\ j \neq i}}^n \log \left(x_i / x_j\right)}
157
226
  $$
158
227
 
228
+ The formula has a continuous averaging extension when input values coincide,
229
+ but the current implementation does not handle ties: a zero denominator makes
230
+ it return `0`.
231
+
159
232
  ### $\mathbf{A^{(p)}_{A_1,A_2}}$ - Convex combinations of aggregation functions
160
233
 
234
+ Tags: `aggregation interval: common interval of A₁ and A₂` `averaging if both inputs are averaging` `p ∈ [0,1]`
235
+
161
236
  We can construct covex combination of aggregation functions as $A^{(p)}_{A_1,A_2}=pA_1+(1-p)A_2$, where $A_1, A_2$ are aggregation functions and $p \in [0,1]$.
162
237
 
163
238
 
164
239
 
165
240
  ## References
166
241
 
167
- 1. Beliakov, G., Bustince, H., and Calvo, T.: A practical Guide to Averaging Functions.
168
- Berlin: Springer Vol. 329, 2016.
242
+ 1. Beliakov, G., Bustince, H., and Calvo, T.: *A Practical Guide to Averaging Functions*. Berlin: Springer, vol. 329, 2016.
169
243
  2. [Mustonen, Seppo. (2010). Logarithmic mean for several arguments. ](https://www.researchgate.net/publication/228886844_Logarithmic_mean_for_several_arguments)