mean_y_vs_x

halotools.mock_observables.mean_y_vs_x(x, y, error_estimator=u'error_on_mean', **kwargs)[source] [edit on github]

Estimate the mean value of the property y as a function of x for an input sample of galaxies/halos, optionally returning an error estimate.

The mean_y_vs_x function is just a convenience wrapper around scipy.stats.binned_statistic and np.histogram.

See also Galaxy Catalog Analysis Example: Galaxy properties as a function of halo mass.

Parameters:

x : array_like

Array storing values of the independent variable of the sample.

y : array_like

Array storing values of the dependent variable of the sample.

bins : array_like, optional

Bins of the input x. Defaults are set by scipy.stats.binned_statistic.

error_estimator : string, optional

If set to error_on_mean, function will also return an array storing \(\sigma_{y}/\sqrt{N}\), where \(\sigma_{y}\) is the standard deviation of y in the bin and \(\sqrt{N}\) is the counts in each bin.

If set to variance, function will also return an array storing \(\sigma_{y}\).

Default is error_on_mean

Returns:

bin_midpoints : array_like

Midpoints of the x-bins.

mean : array_like

Mean of y estimated in bins

err : array_like

Error on y estimated in bins

Examples

>>> from halotools.sim_manager import FakeSim
>>> halocat = FakeSim()
>>> halos = halocat.halo_table
>>> halo_mass, mean_spin, err = mean_y_vs_x(halos['halo_mvir'], halos['halo_spin'])