Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Correct syntax for ksdensity() function

Asked by John on 21 Mar 2012

Hello,

I'm trying to use the kernal smoothing density function

http://www.mathworks.co.uk/help/toolbox/stats/ksdensity.html

What would the correct syntax be if I'm trying to smooth a vector x, with kernel epanechnikov with a width of 3?

Is it something like this?

[...] = ksdensity(x,kernel,epanechnikov,width, 3)

What would go on the right hand side of the equal sign?

Sincere thanks

John

0 Comments

John

Tags

Products

No products are associated with this question.

1 Answer

Answer by Peter Perkins on 21 Mar 2012

John, all you are missing is quotes:

ksdensity(x,'kernel','epanechnikov','width',3)

BUT: you say, "if I'm trying to smooth a vector", which makes me think that maybe you're thinking that this is kernel smoothing, rather than kernel density estimation. KSDENSITY takes one vector containing a sample from some unknown distribution, and returns an estimate of the density of that distibution. Kernel smoothing, which KSDENSITY doesn't do, is a non-parametric regression method that takes two (or maybe more) vectors.

Hope this helps.

1 Comment

John on 22 Mar 2012

Hi Peter,

Thank you for your reply and for pointing out that KSDENSITY cannot be used for smoothing.

I am trying to smooth two vectors. I have a recording of time (sec) and speed and I'm trying to smooth the curve.

Here is an example http://dl.dropbox.com/u/54057365/All/kernel.JPG

Is it possible to do this in Matlab?

Thank you

Kind Regards

John

Peter Perkins

Contact us