Thread Subject: moving average

Subject: moving average

From: MZ

Date: 20 Aug, 2009 04:45:54

Message: 1 of 1

I have paired (x,y) data. I want to compute a sort of moving average on
it, and I want values returned at the same values of x. The kink is
that the x data is not equally spaced.

I've solved the problem this way:

y =
ksdensity(x,x,'kernel','box','weights',y)./ksdensity(x,x,'kernel','box');

But it's dreadfully slow. I have to call ksdensity twice, once with
weighting and once without. The first one is to basically sum the
points within a kernel and the second one is to count the points within
a kernel. (ie. mean=sum/N)

[The size of the kernel isn't terribly important, so I've stuck with the
defaults.]

Is there a better way to do this? I thought about rounding +
convolution, but it would require interpolation and I'm not sure how
willing I am to put up with roundoff error. Although at this stage, it
might be worth it...

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com