Take the following example from the documentation:
rng = np.random.default_rng(seed=3576)
windspeed = 8 * rng.random(500)
boatspeed = .3 * windspeed**.5 + .2 * rng.random(500)
bin_means, bin_edges, binnumber = stats.binned_statistic(windspeed,
boatspeed, statistic='median', bins=[1,2,3,4,5,6,7])
The first value in bin_means (actually the median is calculated in this case) is 0.48067334, which is the 90th value in the array boatspeed.
I'm really confused as to how this method takes the array of bins and maps it onto the value vector (boatspeed in this case). How does the 90th entry belong to a bin starting from "1" and ending at "2"? Could someone please give an intuitive example or explanation?
It's also not clear to me what the windspeed vector is needed for. According to the documentation, this is "a sequence of values to be binned", but the statistic is being calculated on the second vector, boatspeed, which to me means that we are actually binning boatspeed and windspeed doesn't seem to be used/needed.
Cheers!