Amazing performance, great to have the grid input option. Sad about meshgrid (Y,X,Z) instead of ndgrid (X,Y,Z) type output though, can't simply convert to list doing IN(:).
Sept 2013 update indicates normals should point in, but help still says out...

Thanks, very useful. Strangely I get very different results on Matlab 2011b and 2013b with the same data. On the recent version, the density distribution is more smooth and has a stronger tendency to not go to 0 at the ends of the distribution. I'm guessing this is due to changes in a Matlab function. Any ideas?

Quick and practical, but doesn't properly take into account repeated median values, e.g. [1, 2, 2, 2, 2] would have the first 3 quartiles equal to 2, but this code would give [1, 2, NaN].

Nice code, thanks! Just for fun, slight to medium speed improvement (sorry my k = your N):

%instead of:
%[Y{k:-1:1}] = ndgrid(X) ;
%Y = reshape(cat(k+1,Y{:}),[],k) ;
%fill Y directly:
nX = numel(X);
Y(nX^k, k) = X(1); % Initialize to give shape and data type.
s(1:k-1) = {ones(1, nX)};
for i = 1:k
Y( ((i-1)*nX^k + 1) : (i*nX^k) ) = X(s{1:i-1}, :, s{i:k-1});
X = permute(X, [1:i-1, i+1, i]);
end
% This has inverse order for the combinations as you had, easy to change.

Thanks, very useful. Strangely I get very different results on Matlab 2011b and 2013b with the same data. On the recent version, the density distribution is more smooth and has a stronger tendency to not go to 0 at the ends of the distribution. I'm guessing this is due to changes in a Matlab function. Any ideas?

5

11 Aug 2014

Kernel Density Estimator
Reliable and extremely fast kernel density estimator for one-dimensional data

Dear Botev,
my data does not have meaning on negative values, but constructing histograms using kde returns frequencies on negative values and even if I determine the lower limit of x on zero, it returns on zero a big value. (i expect my histogram to start like x^2).
Thanks

Comment only