d3.selectAll("#tt2").transition().duration("50").remove());
    }
    return update_hist;
};

// [kernelDensityEstimation(data, bandwith] returns the function x -> kde(x)
//    for [data]. The kernel function used is a gaussian.
function kernelDensityEstimation(X, bandwidth) {
    //gaussian constante
    const a = 1/(2*bandwidth*bandwidth);
    const b = bandwidth * SQRT_2PI;
    const gaussianKernel =
	  function (x) {
	      return Math.exp(-a * x * x) / b;
	  };

    return function (x) {
        let i 