Stats_one_arr

cosmo_utils.utils.stats_funcs.Stats_one_arr(x, y, base=1.0, arr_len=0, arr_digit='n', statfunc=<function nanmean>, bin_statval='average', return_perc=False, failval=nan, type_sigma='std', return_dict=False)[source] [edit on github]

Calculates statistics 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

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’, ‘center’} 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

type_sigma : {‘perc’, ‘std’} string, optional (default = ‘std’)

Option for calculating either percentiles or standard deviations. This variable is set to std by default.

Options:
  • perc : calculates percentiles
  • std : uses standard deviations as 1-, 2-, and 3-sigmas

return_dict : bool, optional

If True, the function returns a dict with the binned statistics and more. This variable is set to False by default.

Returns:

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’