anaflow.tools.mean¶
Anaflow subpackage providing several mean calculating routines.
The following functions are provided
annular_fmean (func, val_arr, f_def, f_inv[, …]) |
Calculating the annular generalized f-mean. |
annular_amean (func, val_arr[, ann_dim, arg_dict]) |
Calculating the annular arithmetic mean. |
annular_gmean (func, val_arr[, ann_dim, arg_dict]) |
Calculating the annular geometric mean. |
annular_hmean (func, val_arr[, ann_dim, arg_dict]) |
Calculating the annular harmonic mean. |
annular_pmean (func, val_arr[, p, ann_dim, …]) |
Calculating the annular p-mean. |
-
annular_fmean
(func, val_arr, f_def, f_inv, ann_dim=2, arg_dict=None, **kwargs)[source]¶ Calculating the annular generalized f-mean.
Calculating the annular generalized f-mean of a radial symmetric function for given consecutive radii defining annuli by the following formula
Parameters: - func (
callable
) – Function that should be used ( in the formula). The first argument needs to be the radial variable:func(r, **kwargs)
- val_arr (
numpy.ndarray
) – Radii defining the annuli. - ann_dim (
float
, optional) – The dimension of the annuli. Default:2.0
- f_def (
callable
) – Function defining the f-mean. - f_inv (
callable
) – Inverse of the function defining the f-mean. - arg_dict (
dict
orNone
, optional) – Keyword-arguments given as a dictionary that are forwarded to the function given infunc
. Will be merged with**kwargs
. This is designed for overlapping keywords inannular_fmean
andfunc
. Default:None
- **kwargs – Keyword-arguments that are forwarded to the function given in
func
. Will be merged witharg_dict
Returns: Array with all calculated arithmetic means
Return type: Raises: ValueError
– If func is not callable.ValueError
– If f_def is not callable.ValueError
– If f_inv is not callable.ValueError
– Ifval_arr
has less than 2 values.ValueError
– Ifval_arr
is not sorted in incresing order.
Notes
If the last value in val_arr is “inf”, the given function should provide a value for “inf” as input:
func(float("inf"))
- func (
-
annular_amean
(func, val_arr, ann_dim=2, arg_dict=None, **kwargs)[source]¶ Calculating the annular arithmetic mean.
Calculating the annular arithmetic mean of a radial symmetric function for given consecutive radii defining annuli by the following formula
Parameters: - func (
callable
) – Function that should be used ( in the formula). The first argument needs to be the radial variable:func(r, **kwargs)
- val_arr (
numpy.ndarray
) – Radii defining the annuli. - ann_dim (
float
, optional) – The dimension of the annuli. Default:2.0
- arg_dict (
dict
orNone
, optional) – Keyword-arguments given as a dictionary that are forwarded to the function given infunc
. Will be merged with**kwargs
. This is designed for overlapping keywords inannular_amean
andfunc
. Default:None
- **kwargs – Keyword-arguments that are forwarded to the function given in
func
. Will be merged witharg_dict
Returns: Array with all calculated arithmetic means
Return type: Raises: ValueError
– If func is not callable.ValueError
– Ifval_arr
has less than 2 values.ValueError
– Ifval_arr
is not sorted in incresing order.
Notes
If the last value in val_arr is “inf”, the given function should provide a value for “inf” as input:
func(float("inf"))
- func (
-
annular_gmean
(func, val_arr, ann_dim=2, arg_dict=None, **kwargs)[source]¶ Calculating the annular geometric mean.
Calculating the annular geometric mean of a radial symmetric function for given consecutive radii defining annuli by the following formula
Parameters: - func (
callable
) – Function that should be used ( in the formula). The first argument needs to be the radial variable:func(r, **kwargs)
- val_arr (
numpy.ndarray
) – Radii defining the annuli. - ann_dim (
float
, optional) – The dimension of the annuli. Default:2.0
- arg_dict (
dict
orNone
, optional) – Keyword-arguments given as a dictionary that are forwarded to the function given infunc
. Will be merged with**kwargs
. This is designed for overlapping keywords inannular_gmean
andfunc
. Default:None
- **kwargs – Keyword-arguments that are forwarded to the function given in
func
. Will be merged witharg_dict
Returns: Array with all calculated geometric means
Return type: Raises: ValueError
– If func is not callable.ValueError
– Ifval_arr
has less than 2 values.ValueError
– Ifval_arr
is not sorted in incresing order.
Notes
If the last value in val_arr is “inf”, the given function should provide a value for “inf” as input:
func(float("inf"))
Examples
>>> f = lambda x: x**2 >>> annular_gmean(f, [1,2,3]) array([ 2.33588885, 6.33423311])
- func (
-
annular_hmean
(func, val_arr, ann_dim=2, arg_dict=None, **kwargs)[source]¶ Calculating the annular harmonic mean.
Calculating the annular harmonic mean of a radial symmetric function for given consecutive radii defining annuli by the following formula
Parameters: - func (
callable
) – Function that should be used ( in the formula). The first argument needs to be the radial variable:func(r, **kwargs)
- val_arr (
numpy.ndarray
) – Radii defining the annuli. - ann_dim (
float
, optional) – The dimension of the annuli. Default:2.0
- arg_dict (
dict
orNone
, optional) – Keyword-arguments given as a dictionary that are forwarded to the function given infunc
. Will be merged with**kwargs
. This is designed for overlapping keywords inannular_hmean
andfunc
. Default:None
- **kwargs – Keyword-arguments that are forwarded to the function given in
func
. Will be merged witharg_dict
Returns: Array with all calculated geometric means
Return type: Raises: ValueError
– If func is not callable.ValueError
– Ifval_arr
has less than 2 values.ValueError
– Ifval_arr
is not sorted in incresing order.
Notes
If the last value in val_arr is “inf”, the given function should provide a value for “inf” as input:
func(float("inf"))
- func (
-
annular_pmean
(func, val_arr, p=2.0, ann_dim=2, arg_dict=None, **kwargs)[source]¶ Calculating the annular p-mean.
Calculating the annular p-mean of a radial symmetric function for given consecutive radii defining annuli by the following formula
Parameters: - func (
callable
) – Function that should be used ( in the formula). The first argument needs to be the radial variable:func(r, **kwargs)
- val_arr (
numpy.ndarray
) – Radii defining the annuli. - p (
float
, optional) – The potency defining the p-mean. Default:2.0
- ann_dim (
float
, optional) – The dimension of the annuli. Default:2.0
- arg_dict (
dict
orNone
, optional) – Keyword-arguments given as a dictionary that are forwarded to the function given infunc
. Will be merged with**kwargs
. This is designed for overlapping keywords inannular_pmean
andfunc
. Default:None
- **kwargs – Keyword-arguments that are forwarded to the function given in
func
. Will be merged witharg_dict
Returns: Array with all calculated p-means
Return type: Raises: ValueError
– If func is not callable.ValueError
– Ifval_arr
has less than 2 values.ValueError
– Ifval_arr
is not sorted in incresing order.
Notes
If the last value in val_arr is “inf”, the given function should provide a value for “inf” as input:
func(float("inf"))
- func (