Skip to main content
12-Amethyst
October 4, 2013
Solved

Smoothing Data with a Variable Window

  • October 4, 2013
  • 1 reply
  • 3335 views

Hi everybody,

I am confronted with the following need (extracted from NUREG-0800, SRP, 3.7.1)

"At any frequency f , the average PSD is computed over a frequency band width of ±20 percent, centered on the frequency

f (e.g., 4 Hz to 6 Hz band width for f = 5 Hz).

Now I have a vector of equispaced points in frequency, resulting from a PSD. Say for example f=0.1, 0.2, 0.3 ... 50 Hz, and the corresponding Power Spectral Densities.

If I use the medsmooth function, I have to specify the window width, and it would be a constant window. What I need is a window that, for example, around

1 Hz is (1.2-0.8)/0.1 = 4 points and around 20 Hz should be (24-16)/0.1 = 80 points ...

Does it exist in Mathcad function for smoothing a data vector where I can specify the window width as a percent of the data value itself? Or have I to program it by myself? I have already looked at the various "smoothing" functions and quick sheets, but I do not find anything appropriate.

Thanks a lot in advance for any hints.

Best regards

Best answer by Werner_E

Here is what I came up with.

BTW, your output vector is one element less than the input!

1 reply

25-Diamond I
October 4, 2013

Don't think that we have a rountine built into Mathcad which does what you want, but it shouldn't be difficult to write it.

Does it exist in Mathcad function for smoothing a data vector where I can specify the window width as a percent of the data value itself?

What you mean is that you are smoothing vector vy but the value in another vector vx determines the window size, right. So the routine would have three parameters, vx, vy and the percentage p.

Can you provide a sheet with sample data?

12-Amethyst
October 4, 2013

Hallo Werner,

yes, that is what I mean. This is my solution (the data are random, it is a sheet that I developed for myself in order to test the function before I go and use it).

I do not like the repeated usage of medsmooth inside the loop although...

Werner_E25-Diamond IAnswer
25-Diamond I
October 4, 2013

Here is what I came up with.

BTW, your output vector is one element less than the input!