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

Expose Stopping criteria for sift function #19

Open
felixcremer opened this issue Apr 30, 2021 · 3 comments
Open

Expose Stopping criteria for sift function #19

felixcremer opened this issue Apr 30, 2021 · 3 comments

Comments

@felixcremer
Copy link
Owner

felixcremer commented Apr 30, 2021

There are different stopping criteria in use and it would be good to allow the user to set the stopping criteria as a function.
It might be enough to add the stof function as a keyword argument in the sift function.

One example for another stopping criteria as mentioned in #14

1. What is the stopping criterion for sifting implemented and where can I find it? For my current need I would like to use the [threshold criteria](http://perso.ens-lyon.fr/patrick.flandrin/NSIP03.pdf), which may be a nice addition to the package.
@henry2004y
Copy link
Contributor

The state.s, which is used for the stopping criterion, is now calculated here:

state.s =sum(abs,subs)

and I guess this same concept is also used in other places:
s =sum(abs, iter.yvec)

elseif sum(abs,imf_prev[1])>0.0 && !ismonotonic(imf_prev[1])

To expose the stopping criteria in the linked paper, we do not need the absolute sum of the decomposed data. Instead, it requires the evaluation of the mode amplitude a(t) = (e(t)max− e(t)min)/2, where e(t)max and e(t)min are the upper and lower envelopes, and the evaluation function v(t)= |m(t)/a(t)|, where m(t) is the mean between these envelopes. We define 3 parameters, theta1, theta1, and alpha. The sifting algorithm is iterated until v(t) < theta1, for some assigned fraction (1 −alpha) of the total duration, while v(t)< theta2 for the fraction alpha of the total duration.

As you mentioned, we can add another keyword argument stop for passing a function. I will try to experiment on this.

@henry2004y
Copy link
Contributor

henry2004y commented Apr 30, 2021

I am having some difficulties figuring out how to pass parameters.
The envelopes I need are calculated here:

maxTS = EmpiricalModeDecomposition.interpolate([first(state.xvec); state.xvec[state.maxes]; last(state.xvec)],[smax; state.yvec[state.maxes]; emax],state.xvec,DierckXInterp())

but not stored as intermediate variables.
Also, to keep the original criterion working, tol needs to be passed to the stop function, but right now it only accepts the intermediate var struct SiftState.

function sift(yvec, xvec=1:length(yvec), tol=0.1, stop_steps=4;
    stop=stop_default)
    imf = nothing
    num_steps = 0
    for (i, step) in enumerate(halt(SiftIterable(yvec, xvec, stop_steps), stop))
        #@show sum(abs, step.yvec)
        imf = step.yvec
        num_steps = i
    end
    #@show num_steps
    imf
end

"Default stopping criteria for sift."
function stop_default(state::SiftState)
    ϵ = var(state.yvec) * 0.1 # tol
    state.s <= ϵ
end

Any ideas?

@henry2004y
Copy link
Contributor

I just took a brief look at the latest implementation of CG in IterativeSolver.jl. The structure looks to be in a better shape from which we can more or less borrow.

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

2 participants