Defines algebra common utilities objects that don”t belong to any algebra specific category.
Integer threshold value.
INTEGER_THRESHOLD : numeric
Returns the steps of given distribution.
Parameters: | distribution (array_like) – Distribution to retrieve the steps. |
---|---|
Returns: | Distribution steps. |
Return type: | tuple |
Examples
Uniformly spaced variable:
>>> y = np.array([1, 2, 3, 4, 5])
>>> steps(y)
(1,)
Non-uniformly spaced variable:
>>> y = np.array([1, 2, 3, 4, 8])
>>> steps(y)
(1, 4)
Returns closest \(y\) variable element to reference \(x\) variable.
Parameters: |
|
---|---|
Returns: | Closest \(y\) variable element. |
Return type: | numeric |
Examples
>>> y = np.array([24.31357115, 63.62396289, 55.71528816, 62.70988028, 46.84480573, 25.40026416])
>>> closest(y, 63)
62.70988028
Converts given \(x\) variable to ndarray.
Parameters: |
|
---|---|
Returns: | \(x\) variable converted to ndarray. |
Return type: | ndarray |
Examples
>>> to_ndarray(1)
array([ 1.])
Returns if given distribution is uniform.
Parameters: | distribution (array_like) – Distribution to check for uniformity. |
---|---|
Returns: | Is distribution uniform. |
Return type: | bool |
Examples
Uniformly spaced variable:
>>> y = np.array([1, 2, 3, 4, 5])
>>> is_uniform(y)
True
Non-uniformly spaced variable:
>>> y = np.array([1, 2, 3.1415, 4, 5])
>>> is_uniform(y)
False
Returns if given \(x\) variable is iterable.
Parameters: | x (object) – Variable to check the iterability. |
---|---|
Returns: | \(x\) variable iterability. |
Return type: | bool |
Examples
>>> is_iterable([1, 2, 3])
True
>>> is_iterable(1)
False
Returns if given \(x\) variable is a number.
Parameters: | x (object) – Variable to check. |
---|---|
Returns: | Is \(x\) variable a number. |
Return type: | bool |
See also
Examples
>>> is_numeric(1)
True
>>> is_numeric((1,))
False
Returns if given \(x\) variable is an integer under given threshold.
Parameters: | x (object) – Variable to check. |
---|---|
Returns: | Is \(x\) variable an integer. |
Return type: | bool |
Notes
See also
Examples
>>> is_integer(1)
True
>>> is_integer(1.01)
False
Normalises given array_like \(x\) variable values and optionally clip them between.
Parameters: |
|
---|---|
Returns: | Normalised \(x\) variable. |
Return type: | ndarray |
Examples
>>> x = np.array([0.48224885, 0.31651974, 0.22070513])
>>> normalise(x)
array([ 1. , 0.6563411..., 0.4576581...])