function [X,P,I] = kde_cluster(D)

x_range = size(D,1);
n_curves = size(D,2);

n_x = 50;

X = zeros(x_range,n_x);
P = zeros(x_range,n_x);
for i=1:x_range
    
    [X(i,:), P(i,:)] = kde( squeeze(D(i,:))' , zeros(n_curves,1), 0.2);
    P(i,:) = P(i,:)./sum(P(i,:));
end

I = repmat([1:x_range]',1,n_x);

I=I';
X=X';
P=P';
plot3(I,X,P);


end