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

Can KDE solve the overlapping oscillations issue? #30

Closed
voytek opened this issue Sep 16, 2017 · 1 comment
Closed

Can KDE solve the overlapping oscillations issue? #30

voytek opened this issue Sep 16, 2017 · 1 comment

Comments

@voytek
Copy link
Contributor

voytek commented Sep 16, 2017

Okay, the overlapping oscillations issue is really annoying. As much as I want to avoid an iterative procedure that requires more than one call to the gaussian multi-fitting function, we may need to, in some cases.

My proposed solution is to take the gaussian output from from FOOOF--which may have many noisy overlapping gaussian fits--and do kernel density estimation on that output. It looks like this on the right:

KDE from Wikipedia

This integrates those overlapping gaussians, and then we can try running FOOOF on that, again.

seaborn has some nice KDE code that only has a scipy dependency, so it doesn't change our dependencies at all.

from scipy import stats, integrate

support = np.linspace(np.min(frequency_vector), np.max(frequency_vector), np.size(frequency_vector))
bandwidth = 1.06 * x.std() * x.size ** (-1 / 2.)
kernels = []
for i in x:
    kernel = stats.norm(i, bandwidth).pdf(support)
    kernels.append(kernel)

density = np.sum(kernels, axis=0)
density /= integrate.trapz(density, support)
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