mean_y_vs_x¶
- halotools.mock_observables.mean_y_vs_x(x, y, error_estimator='error_on_mean', **kwargs)[source]¶
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 aroundscipy.stats.binned_statistic
andnp.histogram
.See also Galaxy Catalog Analysis Example: Galaxy properties as a function of halo mass.
- Parameters:
- xarray_like
Array storing values of the independent variable of the sample.
- yarray_like
Array storing values of the dependent variable of the sample.
- binsarray_like, optional
Bins of the input x. Defaults are set by
scipy.stats.binned_statistic
.- error_estimatorstring, 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_midpointsarray_like
Midpoints of the x-bins.
- meanarray_like
Mean of y estimated in bins
- errarray_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'])