aggregationslib 0.2.6__tar.gz → 0.2.7__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 (98) hide show
  1. {aggregationslib-0.2.6/aggregationslib.egg-info → aggregationslib-0.2.7}/PKG-INFO +23 -12
  2. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/README.md +70 -14
  3. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/README.rst +17 -11
  4. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregation_classification.html +14 -14
  5. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/aggregation.py +35 -13
  6. aggregationslib-0.2.7/aggregationslib/cli.py +81 -0
  7. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/decimalaggregations.py +38 -18
  8. aggregationslib-0.2.7/aggregationslib/ndarray.py +200 -0
  9. {aggregationslib-0.2.6 → aggregationslib-0.2.7/aggregationslib.egg-info}/PKG-INFO +23 -12
  10. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib.egg-info/SOURCES.txt +17 -1
  11. aggregationslib-0.2.7/aggregationslib.egg-info/entry_points.txt +2 -0
  12. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib.egg-info/requires.txt +6 -0
  13. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib.egg-info/scm_file_list.json +16 -1
  14. aggregationslib-0.2.7/aggregationslib.egg-info/scm_version.json +8 -0
  15. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib.egg-info/top_level.txt +1 -0
  16. aggregationslib-0.2.7/apps/shiny/README.md +118 -0
  17. aggregationslib-0.2.7/apps/shiny/app.py +513 -0
  18. aggregationslib-0.2.7/apps/shiny/column-selection.js +128 -0
  19. aggregationslib-0.2.7/apps/shiny/core.py +170 -0
  20. aggregationslib-0.2.7/apps/shiny/evaluation.py +98 -0
  21. aggregationslib-0.2.7/apps/shiny/example.csv +21 -0
  22. {aggregationslib-0.2.6/docs/assets → aggregationslib-0.2.7}/diagram-aggregation-classification.svg +18 -18
  23. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/diagram-klasyfikacja-agregacji.svg +22 -22
  24. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/aggregation_classification.html +14 -14
  25. {aggregationslib-0.2.6 → aggregationslib-0.2.7/docs/assets}/diagram-aggregation-classification.svg +18 -18
  26. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/diagram-klasyfikacja-agregacji.svg +22 -22
  27. {aggregationslib-0.2.6 → aggregationslib-0.2.7/docs}/klasyfikacja_agregacji.html +14 -14
  28. {aggregationslib-0.2.6/docs → aggregationslib-0.2.7}/klasyfikacja_agregacji.html +14 -14
  29. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/pyproject.toml +8 -1
  30. aggregationslib-0.2.7/tests/data/README.md +54 -0
  31. aggregationslib-0.2.7/tests/data/wolfram_measure_reference.json +1983 -0
  32. aggregationslib-0.2.7/tests/test_exponential_cardinality.py +53 -0
  33. aggregationslib-0.2.7/tests/test_ndarray.py +243 -0
  34. aggregationslib-0.2.7/tests/test_shiny_app.py +101 -0
  35. aggregationslib-0.2.7/tests/test_shiny_evaluation.py +63 -0
  36. aggregationslib-0.2.7/tests/test_wolfram_measures.py +111 -0
  37. aggregationslib-0.2.6/aggregationslib.egg-info/scm_version.json +0 -8
  38. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/.gitignore +0 -0
  39. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/LICENSE +0 -0
  40. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/README.pl.md +0 -0
  41. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/__init__.py +0 -0
  42. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/aggregations.py +0 -0
  43. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/conjuctive/__init__.py +0 -0
  44. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/conjuctive/purepython.py +0 -0
  45. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/disjunctive/__init__.py +0 -0
  46. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/example.py +0 -0
  47. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/feature_selection/__init__.py +0 -0
  48. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/feature_selection/binary_fuzzy_entropy.py +0 -0
  49. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/feature_selection/fuzzy_com_entropy.py +0 -0
  50. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/models/__init__.py +0 -0
  51. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/models/ensemble/__init__.py +0 -0
  52. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/models/ensemble/aggregation_regressor.py +0 -0
  53. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/models/single/__init__.py +0 -0
  54. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib/purepython.py +0 -0
  55. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/aggregationslib.egg-info/dependency_links.txt +0 -0
  56. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/assets/icons/icon.ico +0 -0
  57. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/assets/icons/icon.png +0 -0
  58. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/assets/icons/icon.svg +0 -0
  59. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/build_docs.ps1 +0 -0
  60. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/commands.md +0 -0
  61. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/diagram-implikacja-agregacja.svg +0 -0
  62. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/diagram-odwzorowanie.svg +0 -0
  63. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/.nojekyll +0 -0
  64. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/aggregation-classes.md +0 -0
  65. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/aggregation-plots.md +0 -0
  66. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregation-surfaces-all.png +0 -0
  67. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregation-surfaces.png +0 -0
  68. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_amn_p=0.5.png +0 -0
  69. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_amx_p=0.5.png +0 -0
  70. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_ar.png +0 -0
  71. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_ex2_p=2,q=2.png +0 -0
  72. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_ex3_p=2,q=1.5.png +0 -0
  73. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_ex_r=1.png +0 -0
  74. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_gm.png +0 -0
  75. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_hm.png +0 -0
  76. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_lm_r=2.png +0 -0
  77. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_lo.png +0 -0
  78. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_md.png +0 -0
  79. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_mn.png +0 -0
  80. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_mx.png +0 -0
  81. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_ol.png +0 -0
  82. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_oln_p=1.png +0 -0
  83. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_pr.png +0 -0
  84. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_pw_r=2.png +0 -0
  85. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/aggregations/A_qd.png +0 -0
  86. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/assets/site.css +0 -0
  87. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/en/index.html +0 -0
  88. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/fuzzy-integrals.md +0 -0
  89. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/index.html +0 -0
  90. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/docs/pl/index.html +0 -0
  91. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/generate_aggregation_plots.py +0 -0
  92. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/setup.cfg +0 -0
  93. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/tests/__init__.py +0 -0
  94. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/tests/data/wolfram_integral_reference.json +0 -0
  95. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/tests/test_aggregations.py +0 -0
  96. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/tests/test_decimal_exponential_mean.py +0 -0
  97. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/tests/test_decimal_fuzzy_integrals.py +0 -0
  98. {aggregationslib-0.2.6 → aggregationslib-0.2.7}/tests/test_fuzzy_integrals.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aggregationslib
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: Python implementation of Arithmetic, quasi arithmetic and other aggregating functions
5
5
  Author: wgalka
6
6
  Project-URL: Homepage, https://github.com/wgalka/Means
@@ -12,12 +12,17 @@ Requires-Python: >=3.14
12
12
  Description-Content-Type: text/x-rst
13
13
  License-File: LICENSE
14
14
  Requires-Dist: numpy>=2.2.2
15
+ Requires-Dist: packaging
15
16
  Requires-Dist: pynverse
16
17
  Requires-Dist: scikit-learn
17
18
  Requires-Dist: pandas
18
19
  Requires-Dist: scipy
19
20
  Provides-Extra: test
20
21
  Requires-Dist: pytest>=8.3.4; extra == "test"
22
+ Provides-Extra: app
23
+ Requires-Dist: shiny<2,>=1.9; extra == "app"
24
+ Requires-Dist: pygments<3,>=2.19; extra == "app"
25
+ Requires-Dist: matplotlib<4,>=3.9; extra == "app"
21
26
  Dynamic: license-file
22
27
 
23
28
  Means
@@ -30,12 +35,15 @@ Documentation:
30
35
  - English: https://wgalka.github.io/Means/en/
31
36
  - Polski: https://wgalka.github.io/Means/pl/
32
37
 
33
- Aggregations functions are:
38
+ Aggregation functions can be classified in several ways. A familiar distinction
39
+ is between three types of behaviour:
34
40
 
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.
41
+ - Conjunctive — an AND-like combination of the inputs.
42
+ - Averaging — a result between the smallest and largest input values.
43
+ - Disjunctive — an OR-like combination of the inputs.
44
+
45
+ These are not the only possibilities: aggregation functions can also exhibit
46
+ mixed behaviour. The diagram below presents a broader classification.
39
47
 
40
48
  .. image:: https://raw.githubusercontent.com/wgalka/Means/main/docs/assets/diagram-aggregation-classification.svg
41
49
  :alt: Classification of aggregation functions
@@ -106,7 +114,7 @@ intervals. ``[0,1]`` means only the unit interval. These are
106
114
  mathematical properties; most callable objects do not validate input
107
115
  bounds at runtime. Some tags depend on parameters or the fuzzy measure.
108
116
 
109
- :math:`\mathbf{A_{ch}^{(\mu)}}` **- Choquet integral [1]**
117
+ :math:`\mathbf{A_{ch}^{(\mu)}}` **- Discrete Choquet integral [1]**
110
118
 
111
119
  Tags: ``averaging`` ``aggregation interval: [0,1]``
112
120
  ``symmetric if μ is symmetric``
@@ -142,8 +150,10 @@ Each constructor returns a monotone fuzzy measure with
142
150
  :math:`\mu(A)=\sum_{j=1}^{|A|}w_j`. The normalized weights are applied
143
151
  by descending value rank, so the first belongs to the largest value;
144
152
  with the Choquet integral this capacity gives the OWA aggregation.
145
- - **Exponential cardinality**: :math:`\mu(A)=(|A|/n)^q` is not
146
- implemented yet; choosing ``q`` is future work.
153
+ - **Exponential cardinality** (``exponential_cardinality_measure(n, q=1)``):
154
+ :math:`\mu(A)=(|A|/n)^q`, where ``q`` must be finite and :math:`q>0`.
155
+ For :math:`q=1`, this is the uniform/cardinality measure, and the discrete
156
+ Choquet integral equals the arithmetic mean.
147
157
 
148
158
  The constructors are in ``aggregationslib.aggregation``; Decimal
149
159
  equivalents are available in ``aggregationslib.decimalaggregations``.
@@ -157,7 +167,7 @@ two-argument function ``O(x, mu)`` as ``quasi_overlap`` to
157
167
  ``choquet_integral`` or ``A_ch``. The default remains the classical
158
168
  product-based Choquet integral.
159
169
 
160
- :math:`\mathbf{A_{sg}^{(\mu)}}` **- Sugeno integral [1]**
170
+ :math:`\mathbf{A_{sg}^{(\mu)}}` **- Discrete Sugeno integral [1]**
161
171
 
162
172
  Tags: ``averaging`` ``aggregation interval: [0,1]``
163
173
  ``symmetric if μ is symmetric``
@@ -196,8 +206,9 @@ available in ``aggregationslib.aggregation`` and
196
206
  by descending value rank, so the first belongs to the largest value.
197
207
  In the Sugeno integral this capacity is used in the max–min formula;
198
208
  the result is not the OWA aggregation.
199
- - **Exponential cardinality**: :math:`\mu(A)=(|A|/n)^q` is not
200
- implemented yet; choosing ``q`` is future work.
209
+ - **Exponential cardinality** (``exponential_cardinality_measure(n, q=1)``):
210
+ :math:`\mu(A)=(|A|/n)^q`, where ``q`` must be finite and :math:`q>0`.
211
+ For :math:`q=1`, this is the uniform/cardinality measure.
201
212
 
202
213
  :math:`\mathbf{A_{ar}}` **- Arithmetic mean**
203
214
 
@@ -6,14 +6,20 @@ Documentation:
6
6
  - English: https://wgalka.github.io/Means/en/
7
7
  - Polski: https://wgalka.github.io/Means/pl/
8
8
 
9
- Aggregations functions are:
10
- - Conjuctive - the final aggregated value will always be influenced by the smallest value among the inputs.
11
- - Disjnuctive - the aggregated value will always be influenced by the largest value among the inputs.
12
-
13
- [![Classification of aggregation functions](https://raw.githubusercontent.com/wgalka/Means/main/docs/assets/diagram-aggregation-classification.svg)](https://wgalka.github.io/Means/aggregation_classification.html)
14
-
15
- *Diagram elaborated on the basis of: A. Pradera, G. Beliakov, H. Bustince, B. De Baets, "A review of the relationships between implication, negation and aggregation functions from the point of view of material implication", Information Sciences 329 (2016) 357–380, [DOI: 10.1016/j.ins.2015.09.033](https://doi.org/10.1016/j.ins.2015.09.033).*
16
-
9
+ Aggregation functions can be classified in several ways. A familiar distinction
10
+ is between three types of behaviour:
11
+
12
+ - Conjunctive — an AND-like combination of the inputs.
13
+ - Averaging — a result between the smallest and largest input values.
14
+ - Disjunctive — an OR-like combination of the inputs.
15
+
16
+ These are not the only possibilities: aggregation functions can also exhibit
17
+ mixed behaviour. The diagram below presents a broader classification.
18
+
19
+ [![Classification of aggregation functions](https://raw.githubusercontent.com/wgalka/Means/main/docs/assets/diagram-aggregation-classification.svg)](https://wgalka.github.io/Means/aggregation_classification.html)
20
+
21
+ *Diagram elaborated on the basis of: A. Pradera, G. Beliakov, H. Bustince, B. De Baets, "A review of the relationships between implication, negation and aggregation functions from the point of view of material implication", Information Sciences 329 (2016) 357–380, [DOI: 10.1016/j.ins.2015.09.033](https://doi.org/10.1016/j.ins.2015.09.033).*
22
+
17
23
  An interactive version of this diagram is available at: https://wgalka.github.io/Means/aggregation_classification.html
18
24
 
19
25
  #### Example 1:
@@ -51,6 +57,47 @@ print(func3.__repr__()) # function parameters are printed in order: func1, func2
51
57
 
52
58
 
53
59
 
60
+ ## Multidimensional arrays
61
+
62
+ `aggregationslib.ndarray` provides the same `A_...` objects as
63
+ `aggregationslib.aggregations`, with additional constructor options `axis`
64
+ and `keepdims`. It applies the existing vector implementation separately
65
+ to each vector along the selected axis.
66
+
67
+ ```python
68
+ import numpy as np
69
+ from aggregationslib.ndarray import A_ar, A_ch
70
+ from aggregationslib import weighted_measure
71
+
72
+ X = np.array([[0.2, 0.6, 0.9], [0.9, 0.2, 0.6]])
73
+ A_ar(axis=1)(X) # shape (2,): one value per row
74
+ A_ar(axis=0)(X) # shape (3,): one value per column
75
+ A_ar(axis=1, keepdims=True)(X) # shape (2, 1)
76
+ A_ar()(X) # scalar: aggregate all elements
77
+
78
+ mu = weighted_measure([0.5, 0.3, 0.2])
79
+ A_ch(measure=mu, axis=-1)(X) # array([0.46, 0.63])
80
+ ```
81
+
82
+ `axis=None` (the default) flattens the input in C order. An integer axis,
83
+ including a negative index, reduces that axis; tuples of axes are not
84
+ supported. For an input of shape `(m, n)`, `axis=1` returns shape `(m,)`,
85
+ including `(1,)` when there is just one row. `keepdims=True` retains reduced
86
+ dimensions with length one. A complete reduction returns a scalar unless
87
+ `keepdims=True`.
88
+
89
+ Choquet and Sugeno use the same measure for each vector. Its size must match
90
+ the selected axis length, or the total element count for `axis=None`.
91
+ Choquet's `quasi_overlap` continues to accept scalar callbacks.
92
+ `Combine2Aggregations` accepts vector callables or objects from this module;
93
+ the combination's own `axis` and `keepdims` control the reduction.
94
+
95
+ Empty vectors are rejected. An empty batch of nonempty vectors returns an
96
+ empty floating-point array of the appropriate shape. The mathematical
97
+ domains, parameter rules and numerical behavior are inherited from the
98
+ vector implementations. This module uses iteration over vectors, not
99
+ vectorized implementations of the aggregation formulas.
100
+
54
101
  ## Aggregation functions
55
102
 
56
103
  An aggregation function on the unit interval [1] is an increasing mapping
@@ -71,7 +118,7 @@ intervals. `[0,1]` means only the unit interval. These are mathematical
71
118
  properties; most callable objects do not validate input bounds at runtime.
72
119
  Some tags depend on parameters or the fuzzy measure.
73
120
 
74
- $\mathbf{A_{ch}^{(\mu)}}$ **- Choquet integral [1]**
121
+ $\mathbf{A_{ch}^{(\mu)}}$ **- Discrete Choquet integral [1]**
75
122
 
76
123
  Tags: `averaging` `aggregation interval: [0,1]` `symmetric if μ is symmetric`
77
124
 
@@ -102,8 +149,10 @@ $\mu(\emptyset)=0$ and $\mu(N)=1$.
102
149
  $\mu(A)=\sum_{j=1}^{|A|}w_j$. The normalized weights are applied by
103
150
  descending value rank, so the first belongs to the largest value; with the
104
151
  Choquet integral this capacity gives the OWA aggregation.
105
- - **Exponential cardinality**: $\mu(A)=(|A|/n)^q$ is not implemented yet;
106
- choosing `q` is future work.
152
+ - **Exponential cardinality** (`exponential_cardinality_measure(n, q=1)`):
153
+ $\mu(A)=(|A|/n)^q$, where `q` must be finite and $q>0$.
154
+ For $q=1$, this is the uniform/cardinality measure, and the discrete
155
+ Choquet integral equals the arithmetic mean.
107
156
 
108
157
  The constructors are in `aggregationslib.aggregation`; Decimal equivalents
109
158
  are available in `aggregationslib.decimalaggregations`.
@@ -115,7 +164,7 @@ For the quasi-overlap generalization from Equation (9), pass a two-argument
115
164
  function `O(x, mu)` as `quasi_overlap` to `choquet_integral` or `A_ch`. The
116
165
  default remains the classical product-based Choquet integral.
117
166
 
118
- $\mathbf{A_{sg}^{(\mu)}}$ **- Sugeno integral [1]**
167
+ $\mathbf{A_{sg}^{(\mu)}}$ **- Discrete Sugeno integral [1]**
119
168
 
120
169
  Tags: `averaging` `aggregation interval: [0,1]` `symmetric if μ is symmetric`
121
170
 
@@ -149,8 +198,9 @@ $\mu(\emptyset)=0$ and $\mu(N)=1$. The same constructors are available in
149
198
  descending value rank, so the first belongs to the largest value. In the
150
199
  Sugeno integral this capacity is used in the max–min formula; the result is
151
200
  not the OWA aggregation.
152
- - **Exponential cardinality**: $\mu(A)=(|A|/n)^q$ is not implemented yet;
153
- choosing `q` is future work.
201
+ - **Exponential cardinality** (`exponential_cardinality_measure(n, q=1)`):
202
+ $\mu(A)=(|A|/n)^q$, where `q` must be finite and $q>0$.
203
+ For $q=1$, this is the uniform/cardinality measure.
154
204
 
155
205
  $\mathbf{A_{ar}}$ **- Arithmetic mean**
156
206
 
@@ -305,3 +355,9 @@ We can construct covex combination of aggregation functions as $A^{(p)}_{A_1,A_2
305
355
 
306
356
  1. Beliakov, G., Bustince, H., and Calvo, T.: *A Practical Guide to Averaging Functions*. Berlin: Springer, vol. 329, 2016.
307
357
  2. [Mustonen, Seppo. (2010). Logarithmic mean for several arguments. ](https://www.researchgate.net/publication/228886844_Logarithmic_mean_for_several_arguments)
358
+ # Shiny app
359
+
360
+ A local interface lets you upload a CSV table, select columns and an
361
+ aggregation, add input vectors, and download row-wise results. It also
362
+ generates the equivalent Python code using `aggregationslib.ndarray`.
363
+ See [setup and usage](apps/shiny/README.md).
@@ -8,12 +8,15 @@ Documentation:
8
8
  - English: https://wgalka.github.io/Means/en/
9
9
  - Polski: https://wgalka.github.io/Means/pl/
10
10
 
11
- Aggregations functions are:
11
+ Aggregation functions can be classified in several ways. A familiar distinction
12
+ is between three types of behaviour:
12
13
 
13
- - Conjuctive - the final aggregated value will always be influenced by
14
- the smallest value among the inputs.
15
- - Disjnuctive - the aggregated value will always be influenced by the
16
- largest value among the inputs.
14
+ - Conjunctive — an AND-like combination of the inputs.
15
+ - Averaging — a result between the smallest and largest input values.
16
+ - Disjunctive — an OR-like combination of the inputs.
17
+
18
+ These are not the only possibilities: aggregation functions can also exhibit
19
+ mixed behaviour. The diagram below presents a broader classification.
17
20
 
18
21
  .. image:: https://raw.githubusercontent.com/wgalka/Means/main/docs/assets/diagram-aggregation-classification.svg
19
22
  :alt: Classification of aggregation functions
@@ -84,7 +87,7 @@ intervals. ``[0,1]`` means only the unit interval. These are
84
87
  mathematical properties; most callable objects do not validate input
85
88
  bounds at runtime. Some tags depend on parameters or the fuzzy measure.
86
89
 
87
- :math:`\mathbf{A_{ch}^{(\mu)}}` **- Choquet integral [1]**
90
+ :math:`\mathbf{A_{ch}^{(\mu)}}` **- Discrete Choquet integral [1]**
88
91
 
89
92
  Tags: ``averaging`` ``aggregation interval: [0,1]``
90
93
  ``symmetric if μ is symmetric``
@@ -120,8 +123,10 @@ Each constructor returns a monotone fuzzy measure with
120
123
  :math:`\mu(A)=\sum_{j=1}^{|A|}w_j`. The normalized weights are applied
121
124
  by descending value rank, so the first belongs to the largest value;
122
125
  with the Choquet integral this capacity gives the OWA aggregation.
123
- - **Exponential cardinality**: :math:`\mu(A)=(|A|/n)^q` is not
124
- implemented yet; choosing ``q`` is future work.
126
+ - **Exponential cardinality** (``exponential_cardinality_measure(n, q=1)``):
127
+ :math:`\mu(A)=(|A|/n)^q`, where ``q`` must be finite and :math:`q>0`.
128
+ For :math:`q=1`, this is the uniform/cardinality measure, and the discrete
129
+ Choquet integral equals the arithmetic mean.
125
130
 
126
131
  The constructors are in ``aggregationslib.aggregation``; Decimal
127
132
  equivalents are available in ``aggregationslib.decimalaggregations``.
@@ -135,7 +140,7 @@ two-argument function ``O(x, mu)`` as ``quasi_overlap`` to
135
140
  ``choquet_integral`` or ``A_ch``. The default remains the classical
136
141
  product-based Choquet integral.
137
142
 
138
- :math:`\mathbf{A_{sg}^{(\mu)}}` **- Sugeno integral [1]**
143
+ :math:`\mathbf{A_{sg}^{(\mu)}}` **- Discrete Sugeno integral [1]**
139
144
 
140
145
  Tags: ``averaging`` ``aggregation interval: [0,1]``
141
146
  ``symmetric if μ is symmetric``
@@ -174,8 +179,9 @@ available in ``aggregationslib.aggregation`` and
174
179
  by descending value rank, so the first belongs to the largest value.
175
180
  In the Sugeno integral this capacity is used in the max–min formula;
176
181
  the result is not the OWA aggregation.
177
- - **Exponential cardinality**: :math:`\mu(A)=(|A|/n)^q` is not
178
- implemented yet; choosing ``q`` is future work.
182
+ - **Exponential cardinality** (``exponential_cardinality_measure(n, q=1)``):
183
+ :math:`\mu(A)=(|A|/n)^q`, where ``q`` must be finite and :math:`q>0`.
184
+ For :math:`q=1`, this is the uniform/cardinality measure.
179
185
 
180
186
  :math:`\mathbf{A_{ar}}` **- Arithmetic mean**
181
187
 
@@ -185,10 +185,10 @@
185
185
  <clipPath id="clip-0Strict"><path d="M 1722 58 H 1185 V 255 H 845 V 588 H 1190 V 902 H 1722 Z"/></clipPath>
186
186
  <clipPath id="clip-0Div"><ellipse cx="615" cy="615" rx="565" ry="115" transform="rotate(21.5 615 615)"/></clipPath>
187
187
  <clipPath id="clip-1Div"><ellipse cx="1185" cy="615" rx="565" ry="115" transform="rotate(-21.5 1185 615)"/></clipPath>
188
- <clipPath id="clip-NC"><path d="M 235 370 L 766 568 L 766 768 L 235 515 Z"/></clipPath>
189
- <clipPath id="clip-SNC"><path d="M 355 505 L 766 576 L 766 738 Z"/></clipPath>
190
- <clipPath id="clip-EM"><path d="M 1565 370 L 1034 568 L 1034 768 L 1565 515 Z"/></clipPath>
191
- <clipPath id="clip-SEM"><path d="M 1445 505 L 1034 576 L 1034 738 Z"/></clipPath>
188
+ <clipPath id="clip-NC"><path d="M 245 408 L 766 570 L 766 766 L 245 535 Z"/></clipPath>
189
+ <clipPath id="clip-SNC"><path d="M 340 495 L 766 576 L 766 742 Z"/></clipPath>
190
+ <clipPath id="clip-EM"><path d="M 1555 408 L 1034 570 L 1034 766 L 1555 535 Z"/></clipPath>
191
+ <clipPath id="clip-SEM"><path d="M 1460 495 L 1034 576 L 1034 742 Z"/></clipPath>
192
192
  <clipPath id="clip-NE1"><rect x="105" y="465" width="350" height="380" rx="44"/></clipPath>
193
193
  <clipPath id="clip-NE0"><rect x="1345" y="465" width="350" height="380" rx="44"/></clipPath>
194
194
 
@@ -248,19 +248,19 @@
248
248
  fill="#ffedd5" fill-opacity="0.36" stroke="#9a3412" stroke-width="3.5"/>
249
249
 
250
250
  <path id="shape-NC" onclick="toggleProperty('NC')" class="region-shape"
251
- d="M 235 370 L 766 568 L 766 768 L 235 515 Z"
251
+ d="M 245 408 L 766 570 L 766 766 L 245 535 Z"
252
252
  fill="#dcfce7" fill-opacity="0.52" stroke="#16a34a" stroke-width="4" stroke-linejoin="round"/>
253
253
 
254
254
  <path id="shape-SNC" onclick="toggleProperty('SNC')" class="region-shape"
255
- d="M 355 505 L 766 576 L 766 738 Z"
255
+ d="M 340 495 L 766 576 L 766 742 Z"
256
256
  fill="#ecfccb" fill-opacity="0.68" stroke="#65a30d" stroke-width="4" stroke-linejoin="round"/>
257
257
 
258
258
  <path id="shape-EM" onclick="toggleProperty('EM')" class="region-shape"
259
- d="M 1565 370 L 1034 568 L 1034 768 L 1565 515 Z"
259
+ d="M 1555 408 L 1034 570 L 1034 766 L 1555 535 Z"
260
260
  fill="#ffedd5" fill-opacity="0.55" stroke="#ea580c" stroke-width="4" stroke-linejoin="round"/>
261
261
 
262
262
  <path id="shape-SEM" onclick="toggleProperty('SEM')" class="region-shape"
263
- d="M 1445 505 L 1034 576 L 1034 738 Z"
263
+ d="M 1460 495 L 1034 576 L 1034 742 Z"
264
264
  fill="#fef9c3" fill-opacity="0.72" stroke="#ca8a04" stroke-width="4" stroke-linejoin="round"/>
265
265
 
266
266
  <!-- 4. Semi-copulas & Dual semi-copulas -->
@@ -361,38 +361,38 @@
361
361
  </g>
362
362
 
363
363
  <!-- 0Div, NC, S-NC Labels -->
364
- <g id="label-0Div" onclick="toggleProperty('0Div')" class="region-shape" transform="translate(155, 375)" filter="url(#badge-shadow)">
364
+ <g id="label-0Div" onclick="toggleProperty('0Div')" class="region-shape" transform="translate(175, 428)" filter="url(#badge-shadow)">
365
365
  <rect x="-56" y="-20" width="112" height="42" rx="9" fill="#eff6ff" stroke="#2563eb" stroke-width="2"/>
366
366
  <text x="0" y="-1" text-anchor="middle" class="badge-text" fill="#1d4ed8">0Div</text>
367
367
  <text x="0" y="15" text-anchor="middle" class="badge-sub" fill="#2563eb">A(a,b) = 0</text>
368
368
  </g>
369
369
 
370
- <g id="label-NC" onclick="toggleProperty('NC')" class="region-shape" transform="translate(305, 435)" filter="url(#badge-shadow)">
370
+ <g id="label-NC" onclick="toggleProperty('NC')" class="region-shape" transform="translate(312, 475)" filter="url(#badge-shadow)">
371
371
  <rect x="-64" y="-20" width="128" height="42" rx="9" fill="#f0fdf4" stroke="#16a34a" stroke-width="2"/>
372
372
  <text x="0" y="-1" text-anchor="middle" class="badge-text" fill="#15803d">NC</text>
373
373
  <text x="0" y="15" text-anchor="middle" class="badge-sub" fill="#16a34a">A(x,N(x)) = 0</text>
374
374
  </g>
375
375
 
376
- <g id="label-SNC" onclick="toggleProperty('SNC')" class="region-shape" transform="translate(500, 575)" filter="url(#badge-shadow)">
376
+ <g id="label-SNC" onclick="toggleProperty('SNC')" class="region-shape" transform="translate(500, 565)" filter="url(#badge-shadow)">
377
377
  <rect x="-72" y="-20" width="144" height="42" rx="9" fill="#f7fee7" stroke="#65a30d" stroke-width="2"/>
378
378
  <text x="0" y="-1" text-anchor="middle" class="badge-text" fill="#4d7c0f">S-NC</text>
379
379
  <text x="0" y="15" text-anchor="middle" class="badge-sub" fill="#65a30d">y≤N(x) ⇔ A=0</text>
380
380
  </g>
381
381
 
382
382
  <!-- 1Div, EM, S-EM Labels -->
383
- <g id="label-1Div" onclick="toggleProperty('1Div')" class="region-shape" transform="translate(1645, 375)" filter="url(#badge-shadow)">
383
+ <g id="label-1Div" onclick="toggleProperty('1Div')" class="region-shape" transform="translate(1625, 428)" filter="url(#badge-shadow)">
384
384
  <rect x="-72" y="-20" width="144" height="42" rx="9" fill="#fff7ed" stroke="#9a3412" stroke-width="2"/>
385
385
  <text x="0" y="-1" text-anchor="middle" class="badge-text" fill="#9a3412" id="title-1Div">1Div</text>
386
386
  <text x="0" y="15" text-anchor="middle" class="badge-sub" fill="#9a3412" id="sub-1Div">A(a,b) = 1</text>
387
387
  </g>
388
388
 
389
- <g id="label-EM" onclick="toggleProperty('EM')" class="region-shape" transform="translate(1495, 435)" filter="url(#badge-shadow)">
389
+ <g id="label-EM" onclick="toggleProperty('EM')" class="region-shape" transform="translate(1488, 475)" filter="url(#badge-shadow)">
390
390
  <rect x="-76" y="-20" width="152" height="42" rx="9" fill="#fff7ed" stroke="#ea580c" stroke-width="2"/>
391
391
  <text x="0" y="-1" text-anchor="middle" class="badge-text" fill="#c2410c" id="title-EM">EM</text>
392
392
  <text x="0" y="15" text-anchor="middle" class="badge-sub" fill="#ea580c" id="sub-EM">A(x,N(x)) = 1</text>
393
393
  </g>
394
394
 
395
- <g id="label-SEM" onclick="toggleProperty('SEM')" class="region-shape" transform="translate(1300, 575)" filter="url(#badge-shadow)">
395
+ <g id="label-SEM" onclick="toggleProperty('SEM')" class="region-shape" transform="translate(1300, 565)" filter="url(#badge-shadow)">
396
396
  <rect x="-82" y="-20" width="164" height="42" rx="9" fill="#fefce8" stroke="#ca8a04" stroke-width="2"/>
397
397
  <text x="0" y="-1" text-anchor="middle" class="badge-text" fill="#a16207" id="title-SEM">S-EM</text>
398
398
  <text x="0" y="15" text-anchor="middle" class="badge-sub" fill="#ca8a04" id="sub-SEM">y≥N(x) ⇔ A=1</text>
@@ -339,6 +339,25 @@ def uniform_measure(n: int) -> FuzzyMeasure:
339
339
  return _capacity_from_function(n, lambda subset: len(subset) / n)
340
340
 
341
341
 
342
+ def exponential_cardinality_measure(n: int, q: object = 1) -> FuzzyMeasure:
343
+ """Return ``mu(A) = (|A| / n)**q`` for finite ``q > 0``.
344
+
345
+ For q=1 this is the uniform measure. Increasing q cannot increase
346
+ either classical integral; only Choquet reduces to arithmetic mean at q=1.
347
+ """
348
+ n = _measure_size(n)
349
+ if isinstance(q, (bool, np.bool_)):
350
+ raise TypeError("q must be a real number, not bool")
351
+ try:
352
+ q = float(q)
353
+ except (ValueError, TypeError, OverflowError) as exc:
354
+ raise ValueError("q must be finite and greater than 0") from exc
355
+ if not isfinite(q) or q <= 0:
356
+ raise ValueError("q must be finite and greater than 0")
357
+ levels = [(size / n) ** q for size in range(n + 1)]
358
+ return _capacity_from_function(n, lambda subset: levels[len(subset)])
359
+
360
+
342
361
  def relative_measure(n: int) -> FuzzyMeasure:
343
362
  """Return the relative capacity with singleton weights 1, ..., n."""
344
363
  n = _measure_size(n)
@@ -372,6 +391,15 @@ def owa_measure(weights: object) -> FuzzyMeasure:
372
391
  )
373
392
 
374
393
 
394
+ def _lambda_capacity(weights, parameter):
395
+ # Equivalent to (prod(1 + parameter*w) - 1) / parameter,
396
+ # without cancellation or division by a parameter close to zero.
397
+ value = 0.0
398
+ for weight in weights:
399
+ value = value * (1.0 + parameter * float(weight)) + float(weight)
400
+ return value
401
+
402
+
375
403
  def _sugeno_lambda(weights: np.ndarray) -> float:
376
404
  total = math.fsum(float(weight) for weight in weights)
377
405
  if total == 1.0:
@@ -384,19 +412,17 @@ def _sugeno_lambda(weights: np.ndarray) -> float:
384
412
  "singleton weights do not define a normalized k-fuzzy measure"
385
413
  )
386
414
 
387
- def log_gap(value):
388
- return math.fsum(
389
- math.log1p(value * float(weight)) for weight in weights
390
- ) - math.log1p(value)
415
+ def gap(value):
416
+ return _lambda_capacity(weights, value) - 1.0
391
417
 
392
418
  lower, upper = 0.0, 1.0
393
- while log_gap(upper) <= 0.0:
419
+ while gap(upper) <= 0.0:
394
420
  upper *= 2.0
395
421
  if not isfinite(upper):
396
422
  raise ValueError("could not find the k-fuzzy measure parameter")
397
423
  for _ in range(100):
398
424
  middle = (lower + upper) / 2.0
399
- if log_gap(middle) < 0.0:
425
+ if gap(middle) < 0.0:
400
426
  lower = middle
401
427
  else:
402
428
  upper = middle
@@ -406,13 +432,12 @@ def _sugeno_lambda(weights: np.ndarray) -> float:
406
432
  return -1.0
407
433
 
408
434
  def gap(value):
409
- product = math.prod(1.0 + value * float(weight) for weight in weights)
410
- return product - (1.0 + value)
435
+ return _lambda_capacity(weights, value) - 1.0
411
436
 
412
437
  lower, upper = -1.0, 0.0
413
438
  for _ in range(100):
414
439
  middle = (lower + upper) / 2.0
415
- if gap(middle) > 0.0:
440
+ if gap(middle) < 0.0:
416
441
  lower = middle
417
442
  else:
418
443
  upper = middle
@@ -438,10 +463,7 @@ def k_fuzzy_measure(singleton_weights: object) -> FuzzyMeasure:
438
463
  subset_weights = [float(vector[index]) for index in subset]
439
464
  if parameter == 0.0:
440
465
  return math.fsum(subset_weights)
441
- if parameter == -1.0:
442
- return 1.0 - math.prod(1.0 - weight for weight in subset_weights)
443
- product = math.prod(1.0 + parameter * weight for weight in subset_weights)
444
- return (product - 1.0) / parameter
466
+ return _lambda_capacity(subset_weights, parameter)
445
467
 
446
468
  values = {}
447
469
  for mask in range(1 << n):
@@ -0,0 +1,81 @@
1
+ """Command line entry point for the Shiny interface."""
2
+
3
+ import argparse
4
+ from importlib import invalidate_caches
5
+ from importlib.metadata import PackageNotFoundError, requires, version
6
+ from pathlib import Path
7
+ import site
8
+ import subprocess
9
+ import sys
10
+ import tomllib
11
+
12
+ from packaging.requirements import Requirement
13
+
14
+
15
+ def _missing_app_requirements():
16
+ try:
17
+ requirements = requires("aggregationslib") or []
18
+ except PackageNotFoundError:
19
+ # Support running the CLI as a module from a source checkout.
20
+ pyproject = Path(__file__).resolve().parents[1] / "pyproject.toml"
21
+ with pyproject.open("rb") as file:
22
+ extras = tomllib.load(file)["project"]["optional-dependencies"]["app"]
23
+ requirements = [f'{item}; extra == "app"' for item in extras]
24
+
25
+ missing = []
26
+ for item in requirements:
27
+ requirement = Requirement(item)
28
+ marker = requirement.marker
29
+ if not marker or not marker.evaluate({"extra": "app"}) or marker.evaluate({"extra": ""}):
30
+ continue
31
+ try:
32
+ if requirement.specifier.contains(version(requirement.name), prereleases=True):
33
+ continue
34
+ except PackageNotFoundError:
35
+ pass
36
+ requirement.marker = None
37
+ missing.append(str(requirement))
38
+ return missing
39
+
40
+
41
+ def main():
42
+ parser = argparse.ArgumentParser(prog="agglib")
43
+ commands = parser.add_subparsers(dest="command", required=True)
44
+ commands.add_parser("start", aliases=["serve"], help="Open the local Shiny app")
45
+ parser.parse_args()
46
+
47
+ missing = _missing_app_requirements()
48
+ if missing:
49
+ if not sys.stdin.isatty():
50
+ parser.exit(
51
+ 1,
52
+ 'Run agglib start in a terminal or install the app with '
53
+ 'python -m pip install "aggregationslib[app]".\n',
54
+ )
55
+ try:
56
+ answer = input("Install the graphical interface? [Y/n] ").strip().lower()
57
+ except EOFError:
58
+ return
59
+ except KeyboardInterrupt:
60
+ parser.exit(130, "\n")
61
+ if answer not in {"", "y", "yes"}:
62
+ return
63
+
64
+ try:
65
+ subprocess.run([sys.executable, "-m", "pip", "install", *missing], check=True)
66
+ except subprocess.CalledProcessError as exc:
67
+ parser.exit(exc.returncode, "Could not install the graphical interface dependencies.\n")
68
+ if site.ENABLE_USER_SITE:
69
+ user_site = site.getusersitepackages()
70
+ if user_site not in sys.path and Path(user_site).is_dir():
71
+ site.addsitedir(user_site)
72
+ invalidate_caches()
73
+
74
+ from shiny import run_app
75
+ from apps.shiny.app import app
76
+
77
+ run_app(app, host="127.0.0.1", launch_browser=True)
78
+
79
+
80
+ if __name__ == "__main__":
81
+ main()
@@ -340,6 +340,32 @@ def uniform_measure(n):
340
340
  )
341
341
 
342
342
 
343
+ def exponential_cardinality_measure(n, q=1, *, allow_float=False):
344
+ """Return ``mu(A) = (|A| / n)**q`` using Decimal arithmetic only.
345
+
346
+ q must be finite and positive; floats require allow_float=True and
347
+ are converted through str. The active Decimal context sets precision.
348
+ """
349
+ n = _decimal_measure_size(n)
350
+ _validate_allow_float(allow_float)
351
+ if isinstance(q, bool):
352
+ raise TypeError("q must be a real number, not bool")
353
+ if not isinstance(q, (Decimal, Integral, str, float)):
354
+ raise TypeError("q must be a Decimal, integer, or decimal string")
355
+ if isinstance(q, float):
356
+ if not allow_float:
357
+ raise TypeError("float q requires allow_float=True")
358
+ q = str(q)
359
+ try:
360
+ q = q if isinstance(q, Decimal) else Decimal(str(q))
361
+ except (InvalidOperation, ValueError, TypeError) as exc:
362
+ raise ValueError("q must be finite and greater than 0") from exc
363
+ if not q.is_finite() or q <= _UNIT_ZERO:
364
+ raise ValueError("q must be finite and greater than 0")
365
+ levels = [_UNIT_ZERO] + [(Decimal(size) / Decimal(n)) ** q for size in range(1, n)] + [_UNIT_ONE]
366
+ return _decimal_measure_from_function(n, lambda subset: levels[len(subset)])
367
+
368
+
343
369
  def relative_measure(n):
344
370
  """Return the relative capacity with singleton weights 1, ..., n."""
345
371
  n = _decimal_measure_size(n)
@@ -382,6 +408,14 @@ def owa_measure(weights, *, allow_float=False):
382
408
  )
383
409
 
384
410
 
411
+ def _decimal_lambda_capacity(weights, parameter):
412
+ # Evaluate the product quotient without subtracting nearly equal numbers.
413
+ value = _UNIT_ZERO
414
+ for weight in weights:
415
+ value = value * (_UNIT_ONE + parameter * weight) + weight
416
+ return value
417
+
418
+
385
419
  def _decimal_sugeno_lambda(weights):
386
420
  total = sum(weights, _UNIT_ZERO)
387
421
  if total == _UNIT_ONE:
@@ -395,10 +429,7 @@ def _decimal_sugeno_lambda(weights):
395
429
  )
396
430
 
397
431
  def gap(value):
398
- product = _UNIT_ONE
399
- for weight in weights:
400
- product *= _UNIT_ONE + value * weight
401
- return product - _UNIT_ONE - value
432
+ return _decimal_lambda_capacity(weights, value) - _UNIT_ONE
402
433
 
403
434
  lower, upper = _UNIT_ZERO, _UNIT_ONE
404
435
  while gap(upper) <= _UNIT_ZERO:
@@ -420,10 +451,7 @@ def _decimal_sugeno_lambda(weights):
420
451
  return -_UNIT_ONE
421
452
 
422
453
  def gap(value):
423
- product = _UNIT_ONE
424
- for weight in weights:
425
- product *= _UNIT_ONE + value * weight
426
- return product - _UNIT_ONE - value
454
+ return _decimal_lambda_capacity(weights, value) - _UNIT_ONE
427
455
 
428
456
  lower, upper = -_UNIT_ONE, _UNIT_ZERO
429
457
  for _ in range(200):
@@ -433,7 +461,7 @@ def _decimal_sugeno_lambda(weights):
433
461
  middle_gap = gap(middle)
434
462
  if middle_gap == _UNIT_ZERO:
435
463
  return middle
436
- if middle_gap > _UNIT_ZERO:
464
+ if middle_gap < _UNIT_ZERO:
437
465
  lower = middle
438
466
  else:
439
467
  upper = middle
@@ -458,15 +486,7 @@ def k_fuzzy_measure(singleton_weights, *, allow_float=False):
458
486
  subset_weights = [vector[index] for index in subset]
459
487
  if parameter == _UNIT_ZERO:
460
488
  return sum(subset_weights, _UNIT_ZERO)
461
- if parameter == -_UNIT_ONE:
462
- product = _UNIT_ONE
463
- for weight in subset_weights:
464
- product *= _UNIT_ONE - weight
465
- return _UNIT_ONE - product
466
- product = _UNIT_ONE
467
- for weight in subset_weights:
468
- product *= _UNIT_ONE + parameter * weight
469
- return (product - _UNIT_ONE) / parameter
489
+ return _decimal_lambda_capacity(subset_weights, parameter)
470
490
 
471
491
  return _decimal_measure_from_function(len(vector), capacity)
472
492