Stats_one_arr¶
-
cosmo_utils.utils.stats_funcs.
Stats_one_arr
(x, y, base=1.0, arr_len=0, arr_digit='n', weights=None, statfunc=<function nanmean>, bin_statval='average', return_perc=False, failval=nan)[source] [edit on github]¶ Calculates statists for 2 arrays
Parameters: x, y : array_like, shape(N,)
Sets of elements for the 1st and 2nd observable
base : float, optional
Bin width in units of
x
. This variable is set to 1. by default.arr_len : int, optional
Minimum number of elements in each bin of
x
arr_digit : {‘n’, ‘y’, ‘o’} str, optional
Option for which elements to return.
- Options:
- ‘n’ : Returns
x_stat
,y_stat
,y_std
,y_std_err
- ‘y’ : Returns
x_stat
,y_stat
,y_std
,y_std_err
,x_bins_data
,y_bins_data
- ‘o’ : Returns
x_bins_data
,y_bins_data
- ‘n’ : Returns
weights : array_like or NoneType, optional
Array of weights for values in
y
. This is set to None by default.statfunc : {
numpy.nanmean
,numpy.nanmedian
} statistical func, optionalNumerical function used to calculate on bins of data. By default, this variable is set to
numpy.nanmean
bin_statval : {‘average’, ‘left’, ‘right’} str, optional
Option for where to put the bin values of
x
andy
. By default, this variable is set toaverage
, which means that the values are those of the averages of the bins inx
andy
.return_perc :
bool
, optionalIf true, it also returns the
percentiles
of the data. Last item in the return list. This variable is set to False by default.failval : int, float, NoneType, or NaN, optional
This is the value used when no data is available for the bin. This is set to
numpy.nan
by defaultReturns: x_stat, y_stat : array_like
Binned array of elements from
x
y_std : array_like
Standard deviation of the binned array in
x
y_std_err : array_like
Error in the
statfunc
ofy
x_bins_data : array_like, optional
Elements of
x
in each bin with spacing ofbase
. Only returned ifarr_digit
== ‘y’ or ‘o’y_bins_data : array_like, optional
Elements of
y
in each bin with spacing ofbase
. Only returned ifarr_digit
== ‘y’ or ‘o’perc_lims : array_like, shape(N,3)
Percentiles in each bin of
x_stat
. Only returned ifarr_digit
== ‘y’ or ‘o’