atoti.array module¶
-
atoti.array.
len
(measure)¶ Return a measure equal to the number of elements of the passed array measure.
- Return type
-
atoti.array.
max
(measure)¶ Return a measure equal to the maximum element of the passed array measure.
The max of an empty array is
None
.- Return type
-
atoti.array.
mean
(measure)¶ Return a measure equal to the mean of all the elements of the passed array measure.
The mean of an empty array is 0.
- Return type
-
atoti.array.
min
(measure)¶ Return a measure equal to the minimum element of the passed array measure.
The min of an empty array is
None
.- Return type
-
atoti.array.
n_greatest
(measure, n)¶ Return an array measure containing the
n
greatest elements of the passed array measure.- Return type
-
atoti.array.
n_greatest_indices
(measure, n)¶ Return an array measure containing the indices of the
n
greatest elements of the passed array measure.Example
The following example creates a measure that returns the 3 greatest indices of an array:
m["array"] = [ 400, 200, 100, 500, 300] m["3 greatest indices"] = atoti.array.n_greatest_indices(m["array"], 3)
This measure will return
[3, 0, 4]
because the greatest values are500
at index 3, then400
at index 0 and300
at index 4.- Return type
-
atoti.array.
n_lowest
(measure, n)¶ Return an array measure containing the
n
lowest elements of the passed array measure.- Return type
-
atoti.array.
n_lowest_indices
(measure, n)¶ Return an array measure containing the indices of the
n
lowest elements of the passed array measure.Example
The following example creates a measure that returns the 3 lowest indices of an array:
m["array"] = [ 400, 200, 100, 500, 300] m["3 lowest indices"] = atoti.array.n_lowest_indices(m["array"], 3)
This measure will return
[2, 1, 4]
because the lowest values are100
at index 2, then200
at index 1 and300
at index 4.- Return type
-
atoti.array.
negative_values
(measure)¶ Return a measure where all the elements > 0 of the passed array measure are replaced by 0.
- Return type
-
atoti.array.
nth_greatest
(measure, n)¶ Return a measure equal to the
n
-th greatest element of the passed array measure.- Return type
-
atoti.array.
nth_lowest
(measure, n)¶ Return a measure equal to the
n
-th lowest element of the passed array measure.- Return type
-
atoti.array.
positive_values
(measure)¶ Return a measure where all the elements < 0 of the passed array measure are replaced by 0.
- Return type
-
atoti.array.
prefix_sum
(measure)¶ Return a measure equal to the sum of the previous elements in the passed array measure.
Example
If an array has the following values:
[2.0, 1.0, 0.0, 3.0]
, the returned array will be:[2.0, 3.0, 3.0, 6.0]
.- Return type
-
atoti.array.
prod
(measure)¶ Return a measure equal to the product of all the elements of the passed array measure.
The product of an empty array is 1.
- Return type
-
atoti.array.
quantile
(measure, q, *, mode='inc', interpolation='linear')¶ Return a measure equal to the requested quantile of the elements of the passed array measure.
Here is how to obtain the same behaviour as these standard quantile calculation methods:
R-1:
mode="centered"
andinterpolation="lower"
R-2:
mode="centered"
andinterpolation="midpoint"
R-3:
mode="simple"
andinterpolation="nearest"
R-4:
mode="simple"
andinterpolation="linear"
R-5:
mode="centered"
andinterpolation="linear"
R-6 (similar to Excel’s
PERCENTILE.EXC
):mode="exc"
andinterpolation="linear"
R-7 (similar to Excel’s
PERCENTILE.INC
):mode="inc"
andinterpolation="linear"
R-8 and R-9 are not supported
The formulae given for the calculation of the quantile index assume a 1-based indexing system.
- Parameters
measure (
Measure
) – The measure to get the quantile of.q (
Union
[float
,Measure
]) – The quantile to take. Must be between0
and1
. For instance,0.95
is the 95th percentile and0.5
is the median.mode (
Literal
[‘simple’, ‘centered’, ‘inc’, ‘exc’]) –The method used to calculate the index of the quantile. Available options are, when searching for the
q
quantile of a vectorX
:simple
:len(X) * q
centered
:len(X) * q + 0.5
exc
:(len(X) + 1) * q
inc
:(len(X) - 1) * q + 1
interpolation (
Literal
[‘linear’, ‘higher’, ‘lower’, ‘nearest’, ‘midpoint’]) –If the quantile index is not an integer, the interpolation decides what value is returned. The different options are, considering a quantile index
k
withi < k < j
for a sorted vectorX
:linear
:v = X[i] + (X[j] - X[i]) * (k - i)
lowest
:v = X[i]
highest
:v = X[j]
nearest
:v = X[i]
orv = X[j]
depending on which ofi
orj
is closest tok
midpoint
:v = (X[i] + X[j]) / 2
- Return type
-
atoti.array.
quantile_index
(measure, q, *, mode='inc', interpolation='lower')¶ Return a measure equal to the index of requested quantile of the elements of the passed array measure.
- Parameters
measure (
Measure
) – The measure to get the quantile of.q (
Union
[float
,Measure
]) – The quantile to take. Must be between0
and1
. For instance,0.95
is the 95th percentile and0.5
is the median.mode (
Literal
[‘simple’, ‘centered’, ‘inc’, ‘exc’]) –The method used to calculate the index of the quantile. Available options are, when searching for the
q
quantile of a vectorX
:simple
:len(X) * q
centered
:len(X) * q + 0.5
exc
:(len(X) + 1) * q
inc
:(len(X) - 1) * q + 1
interpolation (
Literal
[‘higher’, ‘lower’, ‘nearest’]) –If the quantile index is not an integer, the interpolation decides what value is returned. The different options are, considering a quantile index
k
withi < k < j
for the original vectorX
and the sorted vectorY
:lowest
: the index inX
ofY[i]
highest
: the index inX
ofY[j]
nearest
: the index inX
ofY[i]
orY[j]
depending on which ofi
orj
is closest tok
- Return type
-
atoti.array.
sort
(measure, *, ascending=True)¶ Return an array measure with the elements of the passed array measure sorted.
-
atoti.array.
std
(measure, *, mode='sample')¶ Return a measure equal to the standard deviation of the elements of the passed array measure.
- Parameters
measure (
Measure
) – The measure to get the standard deviation of.mode (
Literal
[‘sample’, ‘population’]) –One of the supported modes:
The
sample
standard deviation, similar to Excel’sSTDEV.S
, is \(\sqrt{\frac{\sum_{i=0}^{n} (X_i - m)^{2}}{n - 1}}\) wherem
is the sample mean andn
the size of the sample. Use this mode if the data represents a sample of the population.The
population
standard deviation, similar to Excel’sSTDEV.P
is \(\sqrt{\frac{\sum_{i=0}^{n}(X_i - m)^{2}}{n}}\) wherem
is the mean of theXi
elements andn
the size of the population. Use this mode if the data represents the entire population.
- Return type
-
atoti.array.
sum
(measure)¶ Return a measure equal to the sum of all the elements of the passed array measure.
The sum of an empty array is 0.
- Return type
-
atoti.array.
var
(measure, *, mode='sample')¶ Return a measure equal to the variance of the elements of the passed array measure.
- Parameters
measure (
Measure
) – The measure to get the variance of.mode (
Literal
[‘sample’, ‘population’]) –One of the supported modes:
The
sample
variance, similar to Excel’sVAR.S
, is \(\frac{\sum_{i=0}^{n} (X_i - m)^{2}}{n - 1}\) wherem
is the sample mean andn
the size of the sample. Use this mode if the data represents a sample of the population.The
population
variance, similar to Excel’sVAR.P
is \(\frac{\sum_{i=0}^{n}(X_i - m)^{2}}{n}\) wherem
is the mean of theXi
elements andn
the size of the population. Use this mode if the data represents the entire population.
- Return type