Skip to content

Conversation

@elavallee
Copy link
Contributor

Please review my change to add a threshold to the PowerSpectrum estimator. The optional threshold is named: $\delta$. I updated the docstring, and I was able to pass all the tests locally. However, I did not add any new tests, which is more challenging. For an example of how to use the new feature, please see the code below.
`

using DynamicalSystems, ComplexityMeasures

N1, N2, a = 101, 100001, 10

for N in (N1, N2)
    println("N: $(N)")
    t = LinRange(0, 2*a*π, N)
    x = sin.(t) # periodic
    y = sin.(t .+ cos.(t/0.5)) # periodic, complex spectrum
    z = sin.(rand(1:15, N) ./ rand(1:10, N)) # random
    w, t = trajectory(Systems.lorenz(), N÷10; Δt = 0.1, Ttr = 100) # chaotic
    w    = w[:, 1]

    for q in (x, y, z, w)
        p, ~ = probabilities_and_outcomes(PowerSpectrum(100.0), q)
        h = entropy(p)
        println("entropy: $(h).")
    end
end

that adds a threshold for "small" amplitudes.

See Issue JuliaDynamics#104.
feature.

* Changed the default threshold from 5.0 to 0.0

* Renamed y to amp_squared to make it more clear

* Vectorized the setting of amplitudes to zero
Copy link
Member

@Datseris Datseris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some simplifying and performance comments

@Datseris
Copy link
Member

Datseris commented Jan 9, 2026

Thanks for the PR @elavallee , in addition please increment the minor version (middle number) at Project.toml file by 1 and add an entry about this change in the CHANGELOG.md file!

elavallee and others added 6 commits January 24, 2026 12:20
Co-authored-by: George Datseris <datseris.george@gmail.com>
Co-authored-by: George Datseris <datseris.george@gmail.com>
*Updated the minor version number.

*Updated the changelog.
@elavallee
Copy link
Contributor Author

Hi @Datseris, I appreciate your changes. I've incorporated them. I also updated the minor version number and the CHANGELOG.,md. Thank you.

Updated version number and added a new feature description for the PowerSpectrum estimator.
Copy link
Member

@Datseris Datseris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry @elavallee , I forgot something in my review. There are no tests for this new feature... Can we please add a test? For example testing that the probabilities for the signal x = cos.(range(0, 2π; length = 10000) .+ 1e-2 .* randn(10000) with some δ = 0.1 are all 0 except from a single probability?

This functionality should be tested. Even though I have no doubt the code is correct as it is, it helps for forwards maintainance if all parts of the code are test covered.

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

Successfully merging this pull request may close these issues.

2 participants