Giter VIP home page Giter VIP logo

Comments (6)

jakevdp avatar jakevdp commented on September 25, 2024

Interesting – thanks for putting this together.

Given how complex the various routines are that lead to this, I think the most fruitful way to track down the bug will be to make sure each component is well tested. My suspicion from playing around with the nfft is that there may be corner cases where the fast summations do not accuratly approximate the true summations – if we could add an option to build the periodogram using direct summations, that could help.

It might also be some kind of interaction between errors in root finding and errors in summation approximation. But I wouldn't dive into those kind of second order effects until each component is understood and validated by comprehensive unit tests.

from fasttemplateperiodogram.

johnh2o2 avatar johnh2o2 commented on September 25, 2024

Hi Jake,

Thanks for the feedback -- the computations above (which use the new fit_template function) only use direct_summations, so this is independent of the NFFT. I suspect there may be some numerical instabilities somewhere that cause the problem at certain phase shifts. Root finding from computed coefficients is known to be unstable with certain algorithms and with certain classes of polynomials (closely spaced roots, large variations in coefficient amplitudes, etc), so that may explain some of the problem.

However, I'm still currently baffled by why the reported fit parameters should be inconsistent with the reported periodogram value, since they both are computed from the same set of variables, and the periodogram computation depends explicitly on the phase shift.

I'll keep adding tests and digging deeper. I'm working on reviewing a JOSS article at the moment, so I'll get back to this a bit later tonight, but feel free to poke around if you have any ideas.

John

from fasttemplateperiodogram.

johnh2o2 avatar johnh2o2 commented on September 25, 2024

Another note -- this branch implements unit tests that compare direct_summations against fast_summations, and everything passes. Doesn't have any bearing on this problem (I don't think), but that should give some additional peace of mind about the NFFT operations. And, since they're unit tested, you can run amok with any speedup ideas for the fast_summations function if you feel like it.

from fasttemplateperiodogram.

jakevdp avatar jakevdp commented on September 25, 2024

Ah, I missed that part. Good to know.

from fasttemplateperiodogram.

johnh2o2 avatar johnh2o2 commented on September 25, 2024

Long story short, I tracked this down to a couple of issues.

  • One was a mistake in the PseudoPolynomial.root_finding_poly() method. Originally, the method would return (1 - x^2)p^2(x) - q^2(x), however, this should be p^2(x) - (1 - x^2)q^2(x).

  • The phase shift parameter, which has caused much grief, was also incorrect, and this was a result of the affine transformation of the observation times to the (-1/2, 1/2) range that was required by NFFT. I had hacked together what I thought was a fix, but this should really be taken care of by the fast_summations function. Now, the results of the NFFT are multiplied by a set of twiddle factors, which correct for the transformation.

Everything should now be fixed as of commit b30e775ef1684c64d3e5574dce30bd7ad8d6241a.

from fasttemplateperiodogram.

jakevdp avatar jakevdp commented on September 25, 2024

Great! Glad to hear you were able to track-down these problems.

from fasttemplateperiodogram.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.