Statistics¶
concrete_fhe_toolkit.ml.stats ¶
Deprecated location: these helpers moved to concrete_fhe_toolkit.stats.
This module re-exports them for backwards compatibility.
array_count_greater ¶
array_count_greater(array: Union[ndarray, List[Any]], threshold: Any) -> Any
Count how many elements are strictly greater than a threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
Union[ndarray, List[Any]]
|
The encrypted array or list of elements. |
required |
threshold
|
Any
|
The value to compare each element against. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The count of elements that are strictly greater than the threshold. |
Example
from concrete_fhe_toolkit.stats import array_count_greater
print(array_count_greater([1, 5, 3], threshold=2)) # 2
Source code in src/concrete_fhe_toolkit/stats.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
array_max ¶
array_max(elements: Union[ndarray, List[Any]]) -> Any
Find the maximum value in an encrypted array using a tournament reduction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elements
|
Union[ndarray, List[Any]]
|
The encrypted array or list of elements. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The maximum value found in the array. |
Example
from concrete_fhe_toolkit.stats import array_max
print(array_max([1, 5, 3])) # 5
Source code in src/concrete_fhe_toolkit/stats.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
array_mean ¶
array_mean(array: Union[ndarray, List[Any]]) -> Any
Calculate the floor mean of an encrypted array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
Union[ndarray, List[Any]]
|
The encrypted array or list of elements. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The integer floor mean of the elements. |
Example
from concrete_fhe_toolkit.stats import array_mean
print(array_mean([2, 4, 6])) # 4
Source code in src/concrete_fhe_toolkit/stats.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
array_min ¶
array_min(elements: Union[ndarray, List[Any]]) -> Any
Find the minimum value in an encrypted array using a tournament reduction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elements
|
Union[ndarray, List[Any]]
|
The encrypted array or list of elements. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The minimum value found in the array. |
Example
from concrete_fhe_toolkit.stats import array_min
print(array_min([1, 5, 3])) # 1
Source code in src/concrete_fhe_toolkit/stats.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
array_range ¶
array_range(array: Union[ndarray, List[Any]]) -> Any
Calculate the range (max - min) of an encrypted array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
Union[ndarray, List[Any]]
|
The encrypted array or list of elements. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The difference between the maximum and minimum values in the array. |
Example
from concrete_fhe_toolkit.stats import array_range
print(array_range([1, 5, 3])) # 4
Source code in src/concrete_fhe_toolkit/stats.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
array_variance ¶
array_variance(array: Union[ndarray, List[Any]]) -> Any
Calculate the floor variance of an encrypted array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
Union[ndarray, List[Any]]
|
The encrypted array or list of elements. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The integer floor variance of the elements. |
Example
from concrete_fhe_toolkit.stats import array_variance
print(array_variance([2, 4, 6])) # 2
Source code in src/concrete_fhe_toolkit/stats.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |