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

Contact us at files@mathworks.com