[Python] How to find a least-squares fit of a set of data to a sum of sines with bounded...

Discussão em 'Python' iniciado por Stack, Fevereiro 2, 2025.

  1. Stack

    Stack Membro Participativo

    I have an array of data x. I want to find a least-squares fit of x to yᵢ=Σₖ₌₀ᵐ Aₖ sin(2π Bₖ/S*i+C)+D, where Aₖ≥0, Lₖ≤Bₖ≤Uₖ, 0≤C≤2π-0.1 (so we won't have to deal with boundary conditions), and -∞≤D≤∞. S and m are known constants. I was thinking of using scipy.optimize.curve_fit, but even with the bounds on B_k, any iterative fit could be ill-conditioned.

    Continue reading...

Compartilhe esta Página