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