Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smoothing #112

Closed
parpwhick opened this issue Jun 23, 2015 · 2 comments
Closed

Smoothing #112

parpwhick opened this issue Jun 23, 2015 · 2 comments

Comments

@parpwhick
Copy link

A newbie request: something I'm using very often is smoothing some time signals, using the recipes provided in the Scipy Cookbook.

Can you implement some kind of smooth function here in DSP? I suppose many other people would be looking for it, using some simple window function. The conv function doesn't support the mode=same keyword as the Python version to make a direct translation, and I'm not signal-savy enough to make my own.

@JayKickliter
Copy link
Member

At first glance it looks they are doing something like filtfilt which filters in both directions to keep the output aligned with input. We should everything in DSP.jl to do this. I'll look a little closer later today.

@parpwhick
Copy link
Author

Thanks, I didn't know about filtfilt. Trying all the combinations I got this to work and give satisfactory results:

function smooth(x::Vector, window_len::Int=7, window::Symbol=:lanczos)
    w = getfield(DSP.Windows, window)(window_len)
    return DSP.filtfilt(w ./ sum(w), [1.0], x)
end

Still, a version by someone who knows what that means would be useful in the module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants