aggregationslib 0.1.3__tar.gz → 0.1.5.dev1__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.
- aggregationslib-0.1.5.dev1/PKG-INFO +210 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/README.md +21 -17
- aggregationslib-0.1.5.dev1/README.rst +193 -0
- aggregationslib-0.1.5.dev1/aggregationslib.egg-info/PKG-INFO +210 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib.egg-info/SOURCES.txt +1 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/pyproject.toml +1 -1
- aggregationslib-0.1.3/PKG-INFO +0 -185
- aggregationslib-0.1.3/aggregationslib.egg-info/PKG-INFO +0 -185
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/.github/workflows/python-publish.yml +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/.gitignore +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/LICENSE +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib/__init__.py +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib/aggregation.py +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib/aggregations.py +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib/conjuctive/__init__.py +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib/conjuctive/purepython.py +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib/decimalaggregations.py +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib/disjunctive/__init__.py +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib/example.py +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib/purepython.py +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib.egg-info/dependency_links.txt +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib.egg-info/requires.txt +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib.egg-info/top_level.txt +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/setup.cfg +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/tests/__init__.py +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/tests/test_aggregations.py +0 -0
- {aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/tests/test_decimal_exponential_mean.py +0 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: aggregationslib
|
|
3
|
+
Version: 0.1.5.dev1
|
|
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: Download, https://github.com/wgalka/Means/releases/latest
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.12
|
|
11
|
+
Description-Content-Type: text/x-rst
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: numpy>=2.2.2
|
|
14
|
+
Requires-Dist: pynverse
|
|
15
|
+
Provides-Extra: test
|
|
16
|
+
Requires-Dist: pytest>=8.3.4; extra == "test"
|
|
17
|
+
|
|
18
|
+
Means
|
|
19
|
+
=====
|
|
20
|
+
|
|
21
|
+
Means, Aggregation functions…
|
|
22
|
+
|
|
23
|
+
Aggregations functions are: - Conjuctive - the final aggregated value
|
|
24
|
+
will always be influenced by the smallest value among the inputs. -
|
|
25
|
+
Disjnuctive - the aggregated value will always be influenced by the
|
|
26
|
+
largest value among the inputs.
|
|
27
|
+
|
|
28
|
+
Example 1:
|
|
29
|
+
^^^^^^^^^^
|
|
30
|
+
|
|
31
|
+
.. code:: pycon
|
|
32
|
+
|
|
33
|
+
# example data
|
|
34
|
+
data = [0.2, 0.6, 0.7]
|
|
35
|
+
# configure function parameters
|
|
36
|
+
func1 = A_amn(p=0.5)
|
|
37
|
+
# use aggregation funciton
|
|
38
|
+
print(func1(data))
|
|
39
|
+
|
|
40
|
+
# Combine two aggregations - arithmetic mean and minimum
|
|
41
|
+
func2 = Combine2Aggregations(A_ar(), min)
|
|
42
|
+
# use combination of aggregation funciton
|
|
43
|
+
print(func2(data))
|
|
44
|
+
|
|
45
|
+
Example2:
|
|
46
|
+
^^^^^^^^^
|
|
47
|
+
|
|
48
|
+
To get information about aggregation function you can use ``__str__()``
|
|
49
|
+
or ‘**repr**\ ()’ methods.
|
|
50
|
+
|
|
51
|
+
.. code:: pycon
|
|
52
|
+
|
|
53
|
+
func1 = A_amn(p=0.5)
|
|
54
|
+
print(func1)
|
|
55
|
+
>>>A_amn(0.5)
|
|
56
|
+
|
|
57
|
+
func2 = Combine2Aggregations(A_ar(), A_md())
|
|
58
|
+
print(func2)
|
|
59
|
+
>>>A_armd
|
|
60
|
+
|
|
61
|
+
func3 = Combine2Aggregations(A_ar(), A_pw(r=3))
|
|
62
|
+
print(func3.__repr__()) # function parameters are printed in order: func1, func2
|
|
63
|
+
>>>A_arpw(r=3)
|
|
64
|
+
|
|
65
|
+
``exponential(y, r=1)`` is given by equation
|
|
66
|
+
|
|
67
|
+
.. math::
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
A_6^{(r)}(x_1,...,x_n)= \frac{1}{r}\ln
|
|
71
|
+
\Big(\frac{1}{n} \sum \limits_{k=1}^{n} e^{rx_k}\Big), where
|
|
72
|
+
r \in \mathbb{R}, r \neq 0
|
|
73
|
+
|
|
74
|
+
Aggregation functions
|
|
75
|
+
---------------------
|
|
76
|
+
|
|
77
|
+
Aggregation function [1] is a mapping :math:`A:[0,1]^n\to[0,1]`,
|
|
78
|
+
:math:`n \in \mathbb{N}`, :math:`n\ge 2` which is is increasing and
|
|
79
|
+
fulfills two boundary conditions, namely :math:`A(0,\dots,0) = 0`,
|
|
80
|
+
:math:`A(1,\dots,1) = 1`.
|
|
81
|
+
|
|
82
|
+
The floowoing aggregation functions are implemented in this library:
|
|
83
|
+
|
|
84
|
+
**Arithmetic mean**
|
|
85
|
+
|
|
86
|
+
.. math:: A_{ar}(x_1,...,x_n)=\frac{1}{n}\sum \limits_{k=1}^{n} x_k
|
|
87
|
+
|
|
88
|
+
**Quadratic mean**
|
|
89
|
+
|
|
90
|
+
.. math::
|
|
91
|
+
|
|
92
|
+
A_{qd}(x_1,...,x_n)=\sqrt{\frac{1}{n}\sum
|
|
93
|
+
\limits_{k=1}^{n} x_k^2}
|
|
94
|
+
|
|
95
|
+
**Product aggregation**
|
|
96
|
+
|
|
97
|
+
.. math:: A_{\text{pr}}(x_1, x_2, \dots, x_n) = \prod_{k=1}^n x_k
|
|
98
|
+
|
|
99
|
+
**Geometric mean**
|
|
100
|
+
|
|
101
|
+
.. math::
|
|
102
|
+
|
|
103
|
+
A_{gm}(x_1,...,x_n)=\sqrt[n]{\prod
|
|
104
|
+
\limits_{k=1}^{n} x_k}
|
|
105
|
+
|
|
106
|
+
**Harmonic mean**
|
|
107
|
+
|
|
108
|
+
.. math::
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
A_{hm}(x_1,...,x_n) =
|
|
112
|
+
\begin{cases}
|
|
113
|
+
0, & \text{if } \exists k,\, 1 \leq k \leq n : x_k = 0 \\
|
|
114
|
+
\frac{n}{\sum\limits_{k=1}^{n} \frac{1}{x_k}}, & \text{otherwise}
|
|
115
|
+
\end{cases}
|
|
116
|
+
|
|
117
|
+
**Power mean**
|
|
118
|
+
|
|
119
|
+
.. math::
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
A_{pw}^{(r)}(x_1,...,x_n) =
|
|
123
|
+
\begin{cases}
|
|
124
|
+
0, & r < 0, \; \exists k,\, 1 \leq k \leq n : x_k = 0 \\
|
|
125
|
+
\Big(\frac{1}{n} \sum\limits_{k=1}^{n} x_k^r \Big)^{\frac{1}{r}}, & \text{otherwise}
|
|
126
|
+
\end{cases}
|
|
127
|
+
|
|
128
|
+
special cases of power means :math:`A_{\text{pw}}^r` [1] are: -
|
|
129
|
+
Arithmetic Mean where r=1; - Quadratic Mean where r=2; - Harmonic Mean
|
|
130
|
+
where r=-1; - Geometric Mean obtained as the limit
|
|
131
|
+
:math:`\lim_{r \to 0} A_{\text{pw}}^r`.
|
|
132
|
+
|
|
133
|
+
--------------
|
|
134
|
+
|
|
135
|
+
**Exponential mean**
|
|
136
|
+
|
|
137
|
+
.. math::
|
|
138
|
+
|
|
139
|
+
A_{ex}^{(r)}(x_1,...,x_n)= \frac{1}{r}\ln
|
|
140
|
+
\Big(\frac{1}{n} \sum \limits_{k=1}^{n} e^{rx_k}\Big), \text{where
|
|
141
|
+
} r \in \mathbb{R}$, $r \neq 0
|
|
142
|
+
|
|
143
|
+
**Lehmer mean**
|
|
144
|
+
|
|
145
|
+
.. math:: A_{lm}(x_1,...,x_n)= \frac{\sum \limits_{k=1}^{n}x_k^r}{\sum \limits_{k=1}^{n}x_k^{r-1}}
|
|
146
|
+
|
|
147
|
+
**Arithmetic minimum mean**
|
|
148
|
+
|
|
149
|
+
.. math::
|
|
150
|
+
|
|
151
|
+
A_{amn}^{(p)}(x_1,...,x_n)=\frac{p}{n}\sum \limits_{k=1}^{n} x_k+
|
|
152
|
+
(1-p) \min \limits_{1 \leq k \leq n}x_k,
|
|
153
|
+
|
|
154
|
+
**Arithmetic maximum mean**
|
|
155
|
+
|
|
156
|
+
.. math::
|
|
157
|
+
|
|
158
|
+
A_{amx}^{(p)}(x_1,...,x_n)=\frac{p}{n}\sum \limits_{k=1}^{n} x_k+
|
|
159
|
+
(1-p) \max \limits_{1\leq k \leq n}x_k,
|
|
160
|
+
|
|
161
|
+
OWA
|
|
162
|
+
~~~
|
|
163
|
+
|
|
164
|
+
In the case of n = 2 (when only two values are aggregated) the
|
|
165
|
+
calculation of the median and the Olympic aggregation are reduced to the
|
|
166
|
+
case of calculating the arithmetic mean of the given values.
|
|
167
|
+
|
|
168
|
+
**Median - ordered weighted aggregation**
|
|
169
|
+
|
|
170
|
+
.. math::
|
|
171
|
+
|
|
172
|
+
A_{md}(x_1,\dots,x_n) =
|
|
173
|
+
\begin{cases}
|
|
174
|
+
y_{(n+1)/2},&\text{if $n$ is odd}\\
|
|
175
|
+
\frac{y_{n/2}+y_{(n/2)+1}}{2},&\text{if $n$ is even}
|
|
176
|
+
\end{cases},
|
|
177
|
+
|
|
178
|
+
**Olimpic aggregation**
|
|
179
|
+
|
|
180
|
+
.. 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.
|
|
181
|
+
|
|
182
|
+
:math:`\mathbf{A_{oln}^{p}}` **- Olimpic aggregation**
|
|
183
|
+
|
|
184
|
+
We can specify how many greatest and smallest records remove
|
|
185
|
+
|
|
186
|
+
.. math:: A_{oln}^{p}(x_1,\dots,x_n) = \frac{1}{n-2p} \sum \limits_{k=p}^{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.
|
|
187
|
+
|
|
188
|
+
--------------
|
|
189
|
+
|
|
190
|
+
:math:`\mathbf{A_{ln}}` **- Logaritmic aggregation**
|
|
191
|
+
|
|
192
|
+
https://www.researchgate.net/publication/228886844_Logarithmic_mean_for_several_arguments
|
|
193
|
+
|
|
194
|
+
.. math::
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
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)}
|
|
198
|
+
|
|
199
|
+
:math:`A^p_{A_1,A_2}` - convex combinations of aggregation functions
|
|
200
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
201
|
+
|
|
202
|
+
We can construct covex combination of aggregation functions as
|
|
203
|
+
:math:`A^p_{A_1,A_2}=pA_1+(1-p)A_2`, where :math:`A_1, A_2` are
|
|
204
|
+
aggregation functions and :math:`p \in [0,1]`.
|
|
205
|
+
|
|
206
|
+
References
|
|
207
|
+
----------
|
|
208
|
+
|
|
209
|
+
1. Beliakov, G., Bustince, H., and Calvo, T.: A practical Guide to
|
|
210
|
+
Averaging Functions. Berlin: Springer Vol. 329, 2016.
|
|
@@ -74,29 +74,33 @@ $$A_{gm}(x_1,...,x_n)=\sqrt[n]{\prod
|
|
|
74
74
|
|
|
75
75
|
**Harmonic mean**
|
|
76
76
|
|
|
77
|
+
|
|
78
|
+
|
|
77
79
|
$$
|
|
78
|
-
A_{hm}(x_1,...,x_n)=
|
|
79
|
-
\
|
|
80
|
-
\
|
|
81
|
-
0, & \exists k,\, 1 \leq k \leq n : x_k = 0 \\
|
|
80
|
+
A_{hm}(x_1,...,x_n) =
|
|
81
|
+
\begin{cases}
|
|
82
|
+
0, & \text{if } \exists k,\, 1 \leq k \leq n : x_k = 0 \\
|
|
82
83
|
\frac{n}{\sum\limits_{k=1}^{n} \frac{1}{x_k}}, & \text{otherwise}
|
|
83
|
-
\end{
|
|
84
|
-
\right.
|
|
84
|
+
\end{cases}
|
|
85
85
|
$$
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
**Power mean**
|
|
89
89
|
|
|
90
|
-
$$
|
|
91
|
-
|
|
92
|
-
\
|
|
93
|
-
\
|
|
90
|
+
$$
|
|
91
|
+
A_{pw}^{(r)}(x_1,...,x_n) =
|
|
92
|
+
\begin{cases}
|
|
93
|
+
0, & r < 0, \; \exists k,\, 1 \leq k \leq n : x_k = 0 \\
|
|
94
|
+
\Big(\frac{1}{n} \sum\limits_{k=1}^{n} x_k^r \Big)^{\frac{1}{r}}, & \text{otherwise}
|
|
95
|
+
\end{cases}
|
|
96
|
+
$$
|
|
97
|
+
|
|
94
98
|
|
|
95
99
|
special cases of power means $A_{\text{pw}}^r$ [1] are:
|
|
96
|
-
- Arithmetic Mean
|
|
97
|
-
- Quadratic Mean
|
|
98
|
-
- Harmonic Mean
|
|
99
|
-
- Geometric Mean
|
|
100
|
+
- Arithmetic Mean where r=1;
|
|
101
|
+
- Quadratic Mean where r=2;
|
|
102
|
+
- Harmonic Mean where r=-1;
|
|
103
|
+
- Geometric Mean obtained as the limit $\lim_{r \to 0} A_{\text{pw}}^r$.
|
|
100
104
|
|
|
101
105
|
|
|
102
106
|
----
|
|
@@ -140,7 +144,7 @@ y_{(n+1)/2},&\text{if $n$ is odd}\\
|
|
|
140
144
|
|
|
141
145
|
$$ 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.$$
|
|
142
146
|
|
|
143
|
-
|
|
147
|
+
$\mathbf{A_{oln}^{p}}$ **- Olimpic aggregation**
|
|
144
148
|
|
|
145
149
|
We can specify how many greatest and smallest records remove
|
|
146
150
|
|
|
@@ -148,12 +152,12 @@ $$ A_{oln}^{p}(x_1,\dots,x_n) = \frac{1}{n-2p} \sum \limits_{k=p}^{n-p} y_k, \q
|
|
|
148
152
|
|
|
149
153
|
--------------------
|
|
150
154
|
|
|
151
|
-
|
|
155
|
+
$\mathbf{A_{ln}}$ **- Logaritmic aggregation**
|
|
152
156
|
|
|
153
157
|
https://www.researchgate.net/publication/228886844_Logarithmic_mean_for_several_arguments
|
|
154
158
|
|
|
155
159
|
$$
|
|
156
|
-
|
|
160
|
+
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
161
|
$$
|
|
158
162
|
|
|
159
163
|
### $A^p_{A_1,A_2}$ - convex combinations of aggregation functions
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
Means
|
|
2
|
+
=====
|
|
3
|
+
|
|
4
|
+
Means, Aggregation functions…
|
|
5
|
+
|
|
6
|
+
Aggregations functions are: - Conjuctive - the final aggregated value
|
|
7
|
+
will always be influenced by the smallest value among the inputs. -
|
|
8
|
+
Disjnuctive - the aggregated value will always be influenced by the
|
|
9
|
+
largest value among the inputs.
|
|
10
|
+
|
|
11
|
+
Example 1:
|
|
12
|
+
^^^^^^^^^^
|
|
13
|
+
|
|
14
|
+
.. code:: pycon
|
|
15
|
+
|
|
16
|
+
# example data
|
|
17
|
+
data = [0.2, 0.6, 0.7]
|
|
18
|
+
# configure function parameters
|
|
19
|
+
func1 = A_amn(p=0.5)
|
|
20
|
+
# use aggregation funciton
|
|
21
|
+
print(func1(data))
|
|
22
|
+
|
|
23
|
+
# Combine two aggregations - arithmetic mean and minimum
|
|
24
|
+
func2 = Combine2Aggregations(A_ar(), min)
|
|
25
|
+
# use combination of aggregation funciton
|
|
26
|
+
print(func2(data))
|
|
27
|
+
|
|
28
|
+
Example2:
|
|
29
|
+
^^^^^^^^^
|
|
30
|
+
|
|
31
|
+
To get information about aggregation function you can use ``__str__()``
|
|
32
|
+
or ‘**repr**\ ()’ methods.
|
|
33
|
+
|
|
34
|
+
.. code:: pycon
|
|
35
|
+
|
|
36
|
+
func1 = A_amn(p=0.5)
|
|
37
|
+
print(func1)
|
|
38
|
+
>>>A_amn(0.5)
|
|
39
|
+
|
|
40
|
+
func2 = Combine2Aggregations(A_ar(), A_md())
|
|
41
|
+
print(func2)
|
|
42
|
+
>>>A_armd
|
|
43
|
+
|
|
44
|
+
func3 = Combine2Aggregations(A_ar(), A_pw(r=3))
|
|
45
|
+
print(func3.__repr__()) # function parameters are printed in order: func1, func2
|
|
46
|
+
>>>A_arpw(r=3)
|
|
47
|
+
|
|
48
|
+
``exponential(y, r=1)`` is given by equation
|
|
49
|
+
|
|
50
|
+
.. math::
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
A_6^{(r)}(x_1,...,x_n)= \frac{1}{r}\ln
|
|
54
|
+
\Big(\frac{1}{n} \sum \limits_{k=1}^{n} e^{rx_k}\Big), where
|
|
55
|
+
r \in \mathbb{R}, r \neq 0
|
|
56
|
+
|
|
57
|
+
Aggregation functions
|
|
58
|
+
---------------------
|
|
59
|
+
|
|
60
|
+
Aggregation function [1] is a mapping :math:`A:[0,1]^n\to[0,1]`,
|
|
61
|
+
:math:`n \in \mathbb{N}`, :math:`n\ge 2` which is is increasing and
|
|
62
|
+
fulfills two boundary conditions, namely :math:`A(0,\dots,0) = 0`,
|
|
63
|
+
:math:`A(1,\dots,1) = 1`.
|
|
64
|
+
|
|
65
|
+
The floowoing aggregation functions are implemented in this library:
|
|
66
|
+
|
|
67
|
+
**Arithmetic mean**
|
|
68
|
+
|
|
69
|
+
.. math:: A_{ar}(x_1,...,x_n)=\frac{1}{n}\sum \limits_{k=1}^{n} x_k
|
|
70
|
+
|
|
71
|
+
**Quadratic mean**
|
|
72
|
+
|
|
73
|
+
.. math::
|
|
74
|
+
|
|
75
|
+
A_{qd}(x_1,...,x_n)=\sqrt{\frac{1}{n}\sum
|
|
76
|
+
\limits_{k=1}^{n} x_k^2}
|
|
77
|
+
|
|
78
|
+
**Product aggregation**
|
|
79
|
+
|
|
80
|
+
.. math:: A_{\text{pr}}(x_1, x_2, \dots, x_n) = \prod_{k=1}^n x_k
|
|
81
|
+
|
|
82
|
+
**Geometric mean**
|
|
83
|
+
|
|
84
|
+
.. math::
|
|
85
|
+
|
|
86
|
+
A_{gm}(x_1,...,x_n)=\sqrt[n]{\prod
|
|
87
|
+
\limits_{k=1}^{n} x_k}
|
|
88
|
+
|
|
89
|
+
**Harmonic mean**
|
|
90
|
+
|
|
91
|
+
.. math::
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
A_{hm}(x_1,...,x_n) =
|
|
95
|
+
\begin{cases}
|
|
96
|
+
0, & \text{if } \exists k,\, 1 \leq k \leq n : x_k = 0 \\
|
|
97
|
+
\frac{n}{\sum\limits_{k=1}^{n} \frac{1}{x_k}}, & \text{otherwise}
|
|
98
|
+
\end{cases}
|
|
99
|
+
|
|
100
|
+
**Power mean**
|
|
101
|
+
|
|
102
|
+
.. math::
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
A_{pw}^{(r)}(x_1,...,x_n) =
|
|
106
|
+
\begin{cases}
|
|
107
|
+
0, & r < 0, \; \exists k,\, 1 \leq k \leq n : x_k = 0 \\
|
|
108
|
+
\Big(\frac{1}{n} \sum\limits_{k=1}^{n} x_k^r \Big)^{\frac{1}{r}}, & \text{otherwise}
|
|
109
|
+
\end{cases}
|
|
110
|
+
|
|
111
|
+
special cases of power means :math:`A_{\text{pw}}^r` [1] are: -
|
|
112
|
+
Arithmetic Mean where r=1; - Quadratic Mean where r=2; - Harmonic Mean
|
|
113
|
+
where r=-1; - Geometric Mean obtained as the limit
|
|
114
|
+
:math:`\lim_{r \to 0} A_{\text{pw}}^r`.
|
|
115
|
+
|
|
116
|
+
--------------
|
|
117
|
+
|
|
118
|
+
**Exponential mean**
|
|
119
|
+
|
|
120
|
+
.. math::
|
|
121
|
+
|
|
122
|
+
A_{ex}^{(r)}(x_1,...,x_n)= \frac{1}{r}\ln
|
|
123
|
+
\Big(\frac{1}{n} \sum \limits_{k=1}^{n} e^{rx_k}\Big), \text{where
|
|
124
|
+
} r \in \mathbb{R}$, $r \neq 0
|
|
125
|
+
|
|
126
|
+
**Lehmer mean**
|
|
127
|
+
|
|
128
|
+
.. math:: A_{lm}(x_1,...,x_n)= \frac{\sum \limits_{k=1}^{n}x_k^r}{\sum \limits_{k=1}^{n}x_k^{r-1}}
|
|
129
|
+
|
|
130
|
+
**Arithmetic minimum mean**
|
|
131
|
+
|
|
132
|
+
.. math::
|
|
133
|
+
|
|
134
|
+
A_{amn}^{(p)}(x_1,...,x_n)=\frac{p}{n}\sum \limits_{k=1}^{n} x_k+
|
|
135
|
+
(1-p) \min \limits_{1 \leq k \leq n}x_k,
|
|
136
|
+
|
|
137
|
+
**Arithmetic maximum mean**
|
|
138
|
+
|
|
139
|
+
.. math::
|
|
140
|
+
|
|
141
|
+
A_{amx}^{(p)}(x_1,...,x_n)=\frac{p}{n}\sum \limits_{k=1}^{n} x_k+
|
|
142
|
+
(1-p) \max \limits_{1\leq k \leq n}x_k,
|
|
143
|
+
|
|
144
|
+
OWA
|
|
145
|
+
~~~
|
|
146
|
+
|
|
147
|
+
In the case of n = 2 (when only two values are aggregated) the
|
|
148
|
+
calculation of the median and the Olympic aggregation are reduced to the
|
|
149
|
+
case of calculating the arithmetic mean of the given values.
|
|
150
|
+
|
|
151
|
+
**Median - ordered weighted aggregation**
|
|
152
|
+
|
|
153
|
+
.. math::
|
|
154
|
+
|
|
155
|
+
A_{md}(x_1,\dots,x_n) =
|
|
156
|
+
\begin{cases}
|
|
157
|
+
y_{(n+1)/2},&\text{if $n$ is odd}\\
|
|
158
|
+
\frac{y_{n/2}+y_{(n/2)+1}}{2},&\text{if $n$ is even}
|
|
159
|
+
\end{cases},
|
|
160
|
+
|
|
161
|
+
**Olimpic aggregation**
|
|
162
|
+
|
|
163
|
+
.. 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.
|
|
164
|
+
|
|
165
|
+
:math:`\mathbf{A_{oln}^{p}}` **- Olimpic aggregation**
|
|
166
|
+
|
|
167
|
+
We can specify how many greatest and smallest records remove
|
|
168
|
+
|
|
169
|
+
.. math:: A_{oln}^{p}(x_1,\dots,x_n) = \frac{1}{n-2p} \sum \limits_{k=p}^{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.
|
|
170
|
+
|
|
171
|
+
--------------
|
|
172
|
+
|
|
173
|
+
:math:`\mathbf{A_{ln}}` **- Logaritmic aggregation**
|
|
174
|
+
|
|
175
|
+
https://www.researchgate.net/publication/228886844_Logarithmic_mean_for_several_arguments
|
|
176
|
+
|
|
177
|
+
.. math::
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
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)}
|
|
181
|
+
|
|
182
|
+
:math:`A^p_{A_1,A_2}` - convex combinations of aggregation functions
|
|
183
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
184
|
+
|
|
185
|
+
We can construct covex combination of aggregation functions as
|
|
186
|
+
:math:`A^p_{A_1,A_2}=pA_1+(1-p)A_2`, where :math:`A_1, A_2` are
|
|
187
|
+
aggregation functions and :math:`p \in [0,1]`.
|
|
188
|
+
|
|
189
|
+
References
|
|
190
|
+
----------
|
|
191
|
+
|
|
192
|
+
1. Beliakov, G., Bustince, H., and Calvo, T.: A practical Guide to
|
|
193
|
+
Averaging Functions. Berlin: Springer Vol. 329, 2016.
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: aggregationslib
|
|
3
|
+
Version: 0.1.5.dev1
|
|
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: Download, https://github.com/wgalka/Means/releases/latest
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.12
|
|
11
|
+
Description-Content-Type: text/x-rst
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: numpy>=2.2.2
|
|
14
|
+
Requires-Dist: pynverse
|
|
15
|
+
Provides-Extra: test
|
|
16
|
+
Requires-Dist: pytest>=8.3.4; extra == "test"
|
|
17
|
+
|
|
18
|
+
Means
|
|
19
|
+
=====
|
|
20
|
+
|
|
21
|
+
Means, Aggregation functions…
|
|
22
|
+
|
|
23
|
+
Aggregations functions are: - Conjuctive - the final aggregated value
|
|
24
|
+
will always be influenced by the smallest value among the inputs. -
|
|
25
|
+
Disjnuctive - the aggregated value will always be influenced by the
|
|
26
|
+
largest value among the inputs.
|
|
27
|
+
|
|
28
|
+
Example 1:
|
|
29
|
+
^^^^^^^^^^
|
|
30
|
+
|
|
31
|
+
.. code:: pycon
|
|
32
|
+
|
|
33
|
+
# example data
|
|
34
|
+
data = [0.2, 0.6, 0.7]
|
|
35
|
+
# configure function parameters
|
|
36
|
+
func1 = A_amn(p=0.5)
|
|
37
|
+
# use aggregation funciton
|
|
38
|
+
print(func1(data))
|
|
39
|
+
|
|
40
|
+
# Combine two aggregations - arithmetic mean and minimum
|
|
41
|
+
func2 = Combine2Aggregations(A_ar(), min)
|
|
42
|
+
# use combination of aggregation funciton
|
|
43
|
+
print(func2(data))
|
|
44
|
+
|
|
45
|
+
Example2:
|
|
46
|
+
^^^^^^^^^
|
|
47
|
+
|
|
48
|
+
To get information about aggregation function you can use ``__str__()``
|
|
49
|
+
or ‘**repr**\ ()’ methods.
|
|
50
|
+
|
|
51
|
+
.. code:: pycon
|
|
52
|
+
|
|
53
|
+
func1 = A_amn(p=0.5)
|
|
54
|
+
print(func1)
|
|
55
|
+
>>>A_amn(0.5)
|
|
56
|
+
|
|
57
|
+
func2 = Combine2Aggregations(A_ar(), A_md())
|
|
58
|
+
print(func2)
|
|
59
|
+
>>>A_armd
|
|
60
|
+
|
|
61
|
+
func3 = Combine2Aggregations(A_ar(), A_pw(r=3))
|
|
62
|
+
print(func3.__repr__()) # function parameters are printed in order: func1, func2
|
|
63
|
+
>>>A_arpw(r=3)
|
|
64
|
+
|
|
65
|
+
``exponential(y, r=1)`` is given by equation
|
|
66
|
+
|
|
67
|
+
.. math::
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
A_6^{(r)}(x_1,...,x_n)= \frac{1}{r}\ln
|
|
71
|
+
\Big(\frac{1}{n} \sum \limits_{k=1}^{n} e^{rx_k}\Big), where
|
|
72
|
+
r \in \mathbb{R}, r \neq 0
|
|
73
|
+
|
|
74
|
+
Aggregation functions
|
|
75
|
+
---------------------
|
|
76
|
+
|
|
77
|
+
Aggregation function [1] is a mapping :math:`A:[0,1]^n\to[0,1]`,
|
|
78
|
+
:math:`n \in \mathbb{N}`, :math:`n\ge 2` which is is increasing and
|
|
79
|
+
fulfills two boundary conditions, namely :math:`A(0,\dots,0) = 0`,
|
|
80
|
+
:math:`A(1,\dots,1) = 1`.
|
|
81
|
+
|
|
82
|
+
The floowoing aggregation functions are implemented in this library:
|
|
83
|
+
|
|
84
|
+
**Arithmetic mean**
|
|
85
|
+
|
|
86
|
+
.. math:: A_{ar}(x_1,...,x_n)=\frac{1}{n}\sum \limits_{k=1}^{n} x_k
|
|
87
|
+
|
|
88
|
+
**Quadratic mean**
|
|
89
|
+
|
|
90
|
+
.. math::
|
|
91
|
+
|
|
92
|
+
A_{qd}(x_1,...,x_n)=\sqrt{\frac{1}{n}\sum
|
|
93
|
+
\limits_{k=1}^{n} x_k^2}
|
|
94
|
+
|
|
95
|
+
**Product aggregation**
|
|
96
|
+
|
|
97
|
+
.. math:: A_{\text{pr}}(x_1, x_2, \dots, x_n) = \prod_{k=1}^n x_k
|
|
98
|
+
|
|
99
|
+
**Geometric mean**
|
|
100
|
+
|
|
101
|
+
.. math::
|
|
102
|
+
|
|
103
|
+
A_{gm}(x_1,...,x_n)=\sqrt[n]{\prod
|
|
104
|
+
\limits_{k=1}^{n} x_k}
|
|
105
|
+
|
|
106
|
+
**Harmonic mean**
|
|
107
|
+
|
|
108
|
+
.. math::
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
A_{hm}(x_1,...,x_n) =
|
|
112
|
+
\begin{cases}
|
|
113
|
+
0, & \text{if } \exists k,\, 1 \leq k \leq n : x_k = 0 \\
|
|
114
|
+
\frac{n}{\sum\limits_{k=1}^{n} \frac{1}{x_k}}, & \text{otherwise}
|
|
115
|
+
\end{cases}
|
|
116
|
+
|
|
117
|
+
**Power mean**
|
|
118
|
+
|
|
119
|
+
.. math::
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
A_{pw}^{(r)}(x_1,...,x_n) =
|
|
123
|
+
\begin{cases}
|
|
124
|
+
0, & r < 0, \; \exists k,\, 1 \leq k \leq n : x_k = 0 \\
|
|
125
|
+
\Big(\frac{1}{n} \sum\limits_{k=1}^{n} x_k^r \Big)^{\frac{1}{r}}, & \text{otherwise}
|
|
126
|
+
\end{cases}
|
|
127
|
+
|
|
128
|
+
special cases of power means :math:`A_{\text{pw}}^r` [1] are: -
|
|
129
|
+
Arithmetic Mean where r=1; - Quadratic Mean where r=2; - Harmonic Mean
|
|
130
|
+
where r=-1; - Geometric Mean obtained as the limit
|
|
131
|
+
:math:`\lim_{r \to 0} A_{\text{pw}}^r`.
|
|
132
|
+
|
|
133
|
+
--------------
|
|
134
|
+
|
|
135
|
+
**Exponential mean**
|
|
136
|
+
|
|
137
|
+
.. math::
|
|
138
|
+
|
|
139
|
+
A_{ex}^{(r)}(x_1,...,x_n)= \frac{1}{r}\ln
|
|
140
|
+
\Big(\frac{1}{n} \sum \limits_{k=1}^{n} e^{rx_k}\Big), \text{where
|
|
141
|
+
} r \in \mathbb{R}$, $r \neq 0
|
|
142
|
+
|
|
143
|
+
**Lehmer mean**
|
|
144
|
+
|
|
145
|
+
.. math:: A_{lm}(x_1,...,x_n)= \frac{\sum \limits_{k=1}^{n}x_k^r}{\sum \limits_{k=1}^{n}x_k^{r-1}}
|
|
146
|
+
|
|
147
|
+
**Arithmetic minimum mean**
|
|
148
|
+
|
|
149
|
+
.. math::
|
|
150
|
+
|
|
151
|
+
A_{amn}^{(p)}(x_1,...,x_n)=\frac{p}{n}\sum \limits_{k=1}^{n} x_k+
|
|
152
|
+
(1-p) \min \limits_{1 \leq k \leq n}x_k,
|
|
153
|
+
|
|
154
|
+
**Arithmetic maximum mean**
|
|
155
|
+
|
|
156
|
+
.. math::
|
|
157
|
+
|
|
158
|
+
A_{amx}^{(p)}(x_1,...,x_n)=\frac{p}{n}\sum \limits_{k=1}^{n} x_k+
|
|
159
|
+
(1-p) \max \limits_{1\leq k \leq n}x_k,
|
|
160
|
+
|
|
161
|
+
OWA
|
|
162
|
+
~~~
|
|
163
|
+
|
|
164
|
+
In the case of n = 2 (when only two values are aggregated) the
|
|
165
|
+
calculation of the median and the Olympic aggregation are reduced to the
|
|
166
|
+
case of calculating the arithmetic mean of the given values.
|
|
167
|
+
|
|
168
|
+
**Median - ordered weighted aggregation**
|
|
169
|
+
|
|
170
|
+
.. math::
|
|
171
|
+
|
|
172
|
+
A_{md}(x_1,\dots,x_n) =
|
|
173
|
+
\begin{cases}
|
|
174
|
+
y_{(n+1)/2},&\text{if $n$ is odd}\\
|
|
175
|
+
\frac{y_{n/2}+y_{(n/2)+1}}{2},&\text{if $n$ is even}
|
|
176
|
+
\end{cases},
|
|
177
|
+
|
|
178
|
+
**Olimpic aggregation**
|
|
179
|
+
|
|
180
|
+
.. 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.
|
|
181
|
+
|
|
182
|
+
:math:`\mathbf{A_{oln}^{p}}` **- Olimpic aggregation**
|
|
183
|
+
|
|
184
|
+
We can specify how many greatest and smallest records remove
|
|
185
|
+
|
|
186
|
+
.. math:: A_{oln}^{p}(x_1,\dots,x_n) = \frac{1}{n-2p} \sum \limits_{k=p}^{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.
|
|
187
|
+
|
|
188
|
+
--------------
|
|
189
|
+
|
|
190
|
+
:math:`\mathbf{A_{ln}}` **- Logaritmic aggregation**
|
|
191
|
+
|
|
192
|
+
https://www.researchgate.net/publication/228886844_Logarithmic_mean_for_several_arguments
|
|
193
|
+
|
|
194
|
+
.. math::
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
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)}
|
|
198
|
+
|
|
199
|
+
:math:`A^p_{A_1,A_2}` - convex combinations of aggregation functions
|
|
200
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
201
|
+
|
|
202
|
+
We can construct covex combination of aggregation functions as
|
|
203
|
+
:math:`A^p_{A_1,A_2}=pA_1+(1-p)A_2`, where :math:`A_1, A_2` are
|
|
204
|
+
aggregation functions and :math:`p \in [0,1]`.
|
|
205
|
+
|
|
206
|
+
References
|
|
207
|
+
----------
|
|
208
|
+
|
|
209
|
+
1. Beliakov, G., Bustince, H., and Calvo, T.: A practical Guide to
|
|
210
|
+
Averaging Functions. Berlin: Springer Vol. 329, 2016.
|
|
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "aggregationslib"
|
|
9
9
|
description = "Python implementation of Arithmetic, quasi arithmetic and other aggregating functions"
|
|
10
|
-
readme = "README.
|
|
10
|
+
readme = "README.rst"
|
|
11
11
|
license = { file = "LICENSE" }
|
|
12
12
|
requires-python = ">=3.12"
|
|
13
13
|
authors = [
|
aggregationslib-0.1.3/PKG-INFO
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.2
|
|
2
|
-
Name: aggregationslib
|
|
3
|
-
Version: 0.1.3
|
|
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: Download, https://github.com/wgalka/Means/releases/latest
|
|
8
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
9
|
-
Classifier: Operating System :: OS Independent
|
|
10
|
-
Requires-Python: >=3.12
|
|
11
|
-
Description-Content-Type: text/markdown
|
|
12
|
-
License-File: LICENSE
|
|
13
|
-
Requires-Dist: numpy>=2.2.2
|
|
14
|
-
Requires-Dist: pynverse
|
|
15
|
-
Provides-Extra: test
|
|
16
|
-
Requires-Dist: pytest>=8.3.4; extra == "test"
|
|
17
|
-
|
|
18
|
-
# Means
|
|
19
|
-
Means, Aggregation functions...
|
|
20
|
-
|
|
21
|
-
Aggregations functions are:
|
|
22
|
-
- Conjuctive - the final aggregated value will always be influenced by the smallest value among the inputs.
|
|
23
|
-
- Disjnuctive - the aggregated value will always be influenced by the largest value among the inputs.
|
|
24
|
-
|
|
25
|
-
#### Example 1:
|
|
26
|
-
|
|
27
|
-
```pycon
|
|
28
|
-
# example data
|
|
29
|
-
data = [0.2, 0.6, 0.7]
|
|
30
|
-
# configure function parameters
|
|
31
|
-
func1 = A_amn(p=0.5)
|
|
32
|
-
# use aggregation funciton
|
|
33
|
-
print(func1(data))
|
|
34
|
-
|
|
35
|
-
# Combine two aggregations - arithmetic mean and minimum
|
|
36
|
-
func2 = Combine2Aggregations(A_ar(), min)
|
|
37
|
-
# use combination of aggregation funciton
|
|
38
|
-
print(func2(data))
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
#### Example2:
|
|
42
|
-
To get information about aggregation function you can use `__str__()` or '__repr__()' methods.
|
|
43
|
-
|
|
44
|
-
```pycon
|
|
45
|
-
func1 = A_amn(p=0.5)
|
|
46
|
-
print(func1)
|
|
47
|
-
>>>A_amn(0.5)
|
|
48
|
-
|
|
49
|
-
func2 = Combine2Aggregations(A_ar(), A_md())
|
|
50
|
-
print(func2)
|
|
51
|
-
>>>A_armd
|
|
52
|
-
|
|
53
|
-
func3 = Combine2Aggregations(A_ar(), A_pw(r=3))
|
|
54
|
-
print(func3.__repr__()) # function parameters are printed in order: func1, func2
|
|
55
|
-
>>>A_arpw(r=3)
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
`exponential(y, r=1)` is given by equation
|
|
59
|
-
|
|
60
|
-
$$
|
|
61
|
-
A_6^{(r)}(x_1,...,x_n)= \frac{1}{r}\ln
|
|
62
|
-
\Big(\frac{1}{n} \sum \limits_{k=1}^{n} e^{rx_k}\Big), where
|
|
63
|
-
r \in \mathbb{R}, r \neq 0
|
|
64
|
-
$$
|
|
65
|
-
|
|
66
|
-
## Aggregation functions
|
|
67
|
-
|
|
68
|
-
Aggregation function [1] is a mapping
|
|
69
|
-
$A:[0,1]^n\to[0,1]$, $n \in \mathbb{N}$, $n\ge 2$ which is is increasing and
|
|
70
|
-
fulfills two boundary conditions, namely $A(0,\dots,0) = 0$, $A(1,\dots,1) = 1$.
|
|
71
|
-
|
|
72
|
-
The floowoing aggregation functions are implemented in this library:
|
|
73
|
-
|
|
74
|
-
**Arithmetic mean**
|
|
75
|
-
|
|
76
|
-
$$A_{ar}(x_1,...,x_n)=\frac{1}{n}\sum \limits_{k=1}^{n} x_k$$
|
|
77
|
-
|
|
78
|
-
**Quadratic mean**
|
|
79
|
-
|
|
80
|
-
$$A_{qd}(x_1,...,x_n)=\sqrt{\frac{1}{n}\sum
|
|
81
|
-
\limits_{k=1}^{n} x_k^2}$$
|
|
82
|
-
|
|
83
|
-
**Product aggregation**
|
|
84
|
-
|
|
85
|
-
$$A_{\text{pr}}(x_1, x_2, \dots, x_n) = \prod_{k=1}^n x_k$$
|
|
86
|
-
|
|
87
|
-
**Geometric mean**
|
|
88
|
-
|
|
89
|
-
$$A_{gm}(x_1,...,x_n)=\sqrt[n]{\prod
|
|
90
|
-
\limits_{k=1}^{n} x_k}$$
|
|
91
|
-
|
|
92
|
-
**Harmonic mean**
|
|
93
|
-
|
|
94
|
-
$$
|
|
95
|
-
A_{hm}(x_1,...,x_n)=
|
|
96
|
-
\left\{
|
|
97
|
-
\begin{array}{ll}
|
|
98
|
-
0, & \exists k,\, 1 \leq k \leq n : x_k = 0 \\
|
|
99
|
-
\frac{n}{\sum\limits_{k=1}^{n} \frac{1}{x_k}}, & \text{otherwise}
|
|
100
|
-
\end{array}
|
|
101
|
-
\right.
|
|
102
|
-
$$
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
**Power mean**
|
|
106
|
-
|
|
107
|
-
$$A_{pw}^{(r)}(x_1,...,x_n)=\left\{ \begin{array}{ll}
|
|
108
|
-
0, & r<0, \; \exists k,\, 1 \leq k \leq n : x_k = 0 \\
|
|
109
|
-
\Big(\frac{1}{n}\sum \limits_{k=1}^{n} x_k^r\Big)^{\frac{1}{r}},& \text{otherwise}
|
|
110
|
-
\end{array} \right.$$
|
|
111
|
-
|
|
112
|
-
special cases of power means $A_{\text{pw}}^r$ [1] are:
|
|
113
|
-
- Arithmetic Mean $A_{\text{ar}}$, where $r=1$;
|
|
114
|
-
- Quadratic Mean $A_{\text{qd}}$, where $r=2$;
|
|
115
|
-
- Harmonic Mean $A_{\text{hm}}$, where $r=-1$;
|
|
116
|
-
- Geometric Mean $A_{\text{gm}}$, obtained as the limit $\lim_{r \to 0} A_{\text{pw}}^r$.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
----
|
|
120
|
-
|
|
121
|
-
**Exponential mean**
|
|
122
|
-
|
|
123
|
-
$$A_{ex}^{(r)}(x_1,...,x_n)= \frac{1}{r}\ln
|
|
124
|
-
\Big(\frac{1}{n} \sum \limits_{k=1}^{n} e^{rx_k}\Big), \text{where
|
|
125
|
-
} r \in \mathbb{R}$, $r \neq 0$$
|
|
126
|
-
|
|
127
|
-
**Lehmer mean**
|
|
128
|
-
|
|
129
|
-
$$ A_{lm}(x_1,...,x_n)= \frac{\sum \limits_{k=1}^{n}x_k^r}{\sum \limits_{k=1}^{n}x_k^{r-1}} $$
|
|
130
|
-
|
|
131
|
-
**Arithmetic minimum mean**
|
|
132
|
-
|
|
133
|
-
$$A_{amn}^{(p)}(x_1,...,x_n)=\frac{p}{n}\sum \limits_{k=1}^{n} x_k+
|
|
134
|
-
(1-p) \min \limits_{1 \leq k \leq n}x_k,$$
|
|
135
|
-
|
|
136
|
-
**Arithmetic maximum mean**
|
|
137
|
-
|
|
138
|
-
$$A_{amx}^{(p)}(x_1,...,x_n)=\frac{p}{n}\sum \limits_{k=1}^{n} x_k+
|
|
139
|
-
(1-p) \max \limits_{1\leq k \leq n}x_k,$$
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
### OWA
|
|
143
|
-
|
|
144
|
-
In the case of n = 2 (when only two values are aggregated) the
|
|
145
|
-
calculation of the median and the Olympic aggregation are reduced to the case of calculating the
|
|
146
|
-
arithmetic mean of the given values.
|
|
147
|
-
|
|
148
|
-
**Median - ordered weighted aggregation**
|
|
149
|
-
|
|
150
|
-
$$A_{md}(x_1,\dots,x_n) =
|
|
151
|
-
\begin{cases}
|
|
152
|
-
y_{(n+1)/2},&\text{if $n$ is odd}\\
|
|
153
|
-
\frac{y_{n/2}+y_{(n/2)+1}}{2},&\text{if $n$ is even}
|
|
154
|
-
\end{cases},$$
|
|
155
|
-
|
|
156
|
-
**Olimpic aggregation**
|
|
157
|
-
|
|
158
|
-
$$ 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.$$
|
|
159
|
-
|
|
160
|
-
**Olimpic aggregation**
|
|
161
|
-
|
|
162
|
-
We can specify how many greatest and smallest records remove
|
|
163
|
-
|
|
164
|
-
$$ A_{oln}^{p}(x_1,\dots,x_n) = \frac{1}{n-2p} \sum \limits_{k=p}^{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.$$
|
|
165
|
-
|
|
166
|
-
--------------------
|
|
167
|
-
|
|
168
|
-
**$A_{ln}$ - Logaritmic aggregation**
|
|
169
|
-
|
|
170
|
-
https://www.researchgate.net/publication/228886844_Logarithmic_mean_for_several_arguments
|
|
171
|
-
|
|
172
|
-
$$
|
|
173
|
-
L\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)}
|
|
174
|
-
$$
|
|
175
|
-
|
|
176
|
-
### $A^p_{A_1,A_2}$ - convex combinations of aggregation functions
|
|
177
|
-
|
|
178
|
-
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]$.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
## References
|
|
183
|
-
|
|
184
|
-
1. Beliakov, G., Bustince, H., and Calvo, T.: A practical Guide to Averaging Functions.
|
|
185
|
-
Berlin: Springer Vol. 329, 2016.
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.2
|
|
2
|
-
Name: aggregationslib
|
|
3
|
-
Version: 0.1.3
|
|
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: Download, https://github.com/wgalka/Means/releases/latest
|
|
8
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
9
|
-
Classifier: Operating System :: OS Independent
|
|
10
|
-
Requires-Python: >=3.12
|
|
11
|
-
Description-Content-Type: text/markdown
|
|
12
|
-
License-File: LICENSE
|
|
13
|
-
Requires-Dist: numpy>=2.2.2
|
|
14
|
-
Requires-Dist: pynverse
|
|
15
|
-
Provides-Extra: test
|
|
16
|
-
Requires-Dist: pytest>=8.3.4; extra == "test"
|
|
17
|
-
|
|
18
|
-
# Means
|
|
19
|
-
Means, Aggregation functions...
|
|
20
|
-
|
|
21
|
-
Aggregations functions are:
|
|
22
|
-
- Conjuctive - the final aggregated value will always be influenced by the smallest value among the inputs.
|
|
23
|
-
- Disjnuctive - the aggregated value will always be influenced by the largest value among the inputs.
|
|
24
|
-
|
|
25
|
-
#### Example 1:
|
|
26
|
-
|
|
27
|
-
```pycon
|
|
28
|
-
# example data
|
|
29
|
-
data = [0.2, 0.6, 0.7]
|
|
30
|
-
# configure function parameters
|
|
31
|
-
func1 = A_amn(p=0.5)
|
|
32
|
-
# use aggregation funciton
|
|
33
|
-
print(func1(data))
|
|
34
|
-
|
|
35
|
-
# Combine two aggregations - arithmetic mean and minimum
|
|
36
|
-
func2 = Combine2Aggregations(A_ar(), min)
|
|
37
|
-
# use combination of aggregation funciton
|
|
38
|
-
print(func2(data))
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
#### Example2:
|
|
42
|
-
To get information about aggregation function you can use `__str__()` or '__repr__()' methods.
|
|
43
|
-
|
|
44
|
-
```pycon
|
|
45
|
-
func1 = A_amn(p=0.5)
|
|
46
|
-
print(func1)
|
|
47
|
-
>>>A_amn(0.5)
|
|
48
|
-
|
|
49
|
-
func2 = Combine2Aggregations(A_ar(), A_md())
|
|
50
|
-
print(func2)
|
|
51
|
-
>>>A_armd
|
|
52
|
-
|
|
53
|
-
func3 = Combine2Aggregations(A_ar(), A_pw(r=3))
|
|
54
|
-
print(func3.__repr__()) # function parameters are printed in order: func1, func2
|
|
55
|
-
>>>A_arpw(r=3)
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
`exponential(y, r=1)` is given by equation
|
|
59
|
-
|
|
60
|
-
$$
|
|
61
|
-
A_6^{(r)}(x_1,...,x_n)= \frac{1}{r}\ln
|
|
62
|
-
\Big(\frac{1}{n} \sum \limits_{k=1}^{n} e^{rx_k}\Big), where
|
|
63
|
-
r \in \mathbb{R}, r \neq 0
|
|
64
|
-
$$
|
|
65
|
-
|
|
66
|
-
## Aggregation functions
|
|
67
|
-
|
|
68
|
-
Aggregation function [1] is a mapping
|
|
69
|
-
$A:[0,1]^n\to[0,1]$, $n \in \mathbb{N}$, $n\ge 2$ which is is increasing and
|
|
70
|
-
fulfills two boundary conditions, namely $A(0,\dots,0) = 0$, $A(1,\dots,1) = 1$.
|
|
71
|
-
|
|
72
|
-
The floowoing aggregation functions are implemented in this library:
|
|
73
|
-
|
|
74
|
-
**Arithmetic mean**
|
|
75
|
-
|
|
76
|
-
$$A_{ar}(x_1,...,x_n)=\frac{1}{n}\sum \limits_{k=1}^{n} x_k$$
|
|
77
|
-
|
|
78
|
-
**Quadratic mean**
|
|
79
|
-
|
|
80
|
-
$$A_{qd}(x_1,...,x_n)=\sqrt{\frac{1}{n}\sum
|
|
81
|
-
\limits_{k=1}^{n} x_k^2}$$
|
|
82
|
-
|
|
83
|
-
**Product aggregation**
|
|
84
|
-
|
|
85
|
-
$$A_{\text{pr}}(x_1, x_2, \dots, x_n) = \prod_{k=1}^n x_k$$
|
|
86
|
-
|
|
87
|
-
**Geometric mean**
|
|
88
|
-
|
|
89
|
-
$$A_{gm}(x_1,...,x_n)=\sqrt[n]{\prod
|
|
90
|
-
\limits_{k=1}^{n} x_k}$$
|
|
91
|
-
|
|
92
|
-
**Harmonic mean**
|
|
93
|
-
|
|
94
|
-
$$
|
|
95
|
-
A_{hm}(x_1,...,x_n)=
|
|
96
|
-
\left\{
|
|
97
|
-
\begin{array}{ll}
|
|
98
|
-
0, & \exists k,\, 1 \leq k \leq n : x_k = 0 \\
|
|
99
|
-
\frac{n}{\sum\limits_{k=1}^{n} \frac{1}{x_k}}, & \text{otherwise}
|
|
100
|
-
\end{array}
|
|
101
|
-
\right.
|
|
102
|
-
$$
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
**Power mean**
|
|
106
|
-
|
|
107
|
-
$$A_{pw}^{(r)}(x_1,...,x_n)=\left\{ \begin{array}{ll}
|
|
108
|
-
0, & r<0, \; \exists k,\, 1 \leq k \leq n : x_k = 0 \\
|
|
109
|
-
\Big(\frac{1}{n}\sum \limits_{k=1}^{n} x_k^r\Big)^{\frac{1}{r}},& \text{otherwise}
|
|
110
|
-
\end{array} \right.$$
|
|
111
|
-
|
|
112
|
-
special cases of power means $A_{\text{pw}}^r$ [1] are:
|
|
113
|
-
- Arithmetic Mean $A_{\text{ar}}$, where $r=1$;
|
|
114
|
-
- Quadratic Mean $A_{\text{qd}}$, where $r=2$;
|
|
115
|
-
- Harmonic Mean $A_{\text{hm}}$, where $r=-1$;
|
|
116
|
-
- Geometric Mean $A_{\text{gm}}$, obtained as the limit $\lim_{r \to 0} A_{\text{pw}}^r$.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
----
|
|
120
|
-
|
|
121
|
-
**Exponential mean**
|
|
122
|
-
|
|
123
|
-
$$A_{ex}^{(r)}(x_1,...,x_n)= \frac{1}{r}\ln
|
|
124
|
-
\Big(\frac{1}{n} \sum \limits_{k=1}^{n} e^{rx_k}\Big), \text{where
|
|
125
|
-
} r \in \mathbb{R}$, $r \neq 0$$
|
|
126
|
-
|
|
127
|
-
**Lehmer mean**
|
|
128
|
-
|
|
129
|
-
$$ A_{lm}(x_1,...,x_n)= \frac{\sum \limits_{k=1}^{n}x_k^r}{\sum \limits_{k=1}^{n}x_k^{r-1}} $$
|
|
130
|
-
|
|
131
|
-
**Arithmetic minimum mean**
|
|
132
|
-
|
|
133
|
-
$$A_{amn}^{(p)}(x_1,...,x_n)=\frac{p}{n}\sum \limits_{k=1}^{n} x_k+
|
|
134
|
-
(1-p) \min \limits_{1 \leq k \leq n}x_k,$$
|
|
135
|
-
|
|
136
|
-
**Arithmetic maximum mean**
|
|
137
|
-
|
|
138
|
-
$$A_{amx}^{(p)}(x_1,...,x_n)=\frac{p}{n}\sum \limits_{k=1}^{n} x_k+
|
|
139
|
-
(1-p) \max \limits_{1\leq k \leq n}x_k,$$
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
### OWA
|
|
143
|
-
|
|
144
|
-
In the case of n = 2 (when only two values are aggregated) the
|
|
145
|
-
calculation of the median and the Olympic aggregation are reduced to the case of calculating the
|
|
146
|
-
arithmetic mean of the given values.
|
|
147
|
-
|
|
148
|
-
**Median - ordered weighted aggregation**
|
|
149
|
-
|
|
150
|
-
$$A_{md}(x_1,\dots,x_n) =
|
|
151
|
-
\begin{cases}
|
|
152
|
-
y_{(n+1)/2},&\text{if $n$ is odd}\\
|
|
153
|
-
\frac{y_{n/2}+y_{(n/2)+1}}{2},&\text{if $n$ is even}
|
|
154
|
-
\end{cases},$$
|
|
155
|
-
|
|
156
|
-
**Olimpic aggregation**
|
|
157
|
-
|
|
158
|
-
$$ 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.$$
|
|
159
|
-
|
|
160
|
-
**Olimpic aggregation**
|
|
161
|
-
|
|
162
|
-
We can specify how many greatest and smallest records remove
|
|
163
|
-
|
|
164
|
-
$$ A_{oln}^{p}(x_1,\dots,x_n) = \frac{1}{n-2p} \sum \limits_{k=p}^{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.$$
|
|
165
|
-
|
|
166
|
-
--------------------
|
|
167
|
-
|
|
168
|
-
**$A_{ln}$ - Logaritmic aggregation**
|
|
169
|
-
|
|
170
|
-
https://www.researchgate.net/publication/228886844_Logarithmic_mean_for_several_arguments
|
|
171
|
-
|
|
172
|
-
$$
|
|
173
|
-
L\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)}
|
|
174
|
-
$$
|
|
175
|
-
|
|
176
|
-
### $A^p_{A_1,A_2}$ - convex combinations of aggregation functions
|
|
177
|
-
|
|
178
|
-
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]$.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
## References
|
|
183
|
-
|
|
184
|
-
1. Beliakov, G., Bustince, H., and Calvo, T.: A practical Guide to Averaging Functions.
|
|
185
|
-
Berlin: Springer Vol. 329, 2016.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib/conjuctive/purepython.py
RENAMED
|
File without changes
|
|
File without changes
|
{aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib/disjunctive/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aggregationslib-0.1.3 → aggregationslib-0.1.5.dev1}/aggregationslib.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|