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 statistics for 2 arrays


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.

  • ‘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

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, optional

Numerical 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 and y. By default, this variable is set to average, which means that the values are those of the averages of the bins in x and y.

return_perc : bool, optional

If 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 default


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 of y

x_bins_data : array_like, optional

Elements of x in each bin with spacing of base. Only returned if arr_digit == ‘y’ or ‘o’

y_bins_data : array_like, optional

Elements of y in each bin with spacing of base. Only returned if arr_digit == ‘y’ or ‘o’

perc_lims : array_like, shape(N,3)

Percentiles in each bin of x_stat. Only returned if arr_digit == ‘y’ or ‘o’