I don't know how to phrase this, but an example:
x = [1 4 4 5 5 5];
y = [5 1 3 3 4 5];
and then I'd like output
xs = [1 4 5];
ys = [5 2 4];
frequencies = [1 2 3]
(because the average 'y' at x=1 is 5
, and the average 'y' at x=4 is (1+3)/2 = 2
, and the average 'y' at x=5 is (3+4+5)/3 = 4
).
I can compute this in a clumsy way but maybe there's a nice solution.