The following reducer should accomplish what you want:
Plot.binX({
y: (a, bin) => {
return a.length / pts.length / (bin.x2 - bin.x1);
}
}
Here it is in action:
Note that the data consists of 5000 points generated by d3.randomNormal()
and the curve is a graph of the standard normal, illustrating that the technique works.