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

Complex functions fix #253

Open
OrlowskiWojtek opened this issue Aug 1, 2024 · 0 comments
Open

Complex functions fix #253

OrlowskiWojtek opened this issue Aug 1, 2024 · 0 comments

Comments

@OrlowskiWojtek
Copy link

When trying to perform fit on complex function (returning complex value) there is no method for max and min between complex value and float value. My code:

function fit_arx(freqs, T::Vector{ComplexF64})
    
    function arx_model(x,p)
        return @. 1 / ((1 + 1im* x / p[1]) * (1 + 1im* x / p[2]))
    end

    p0 = [1.95 + 0im, 20.2 + 0im]

    curve_fit(arx_model, freqs, T, p0)    
end

resulting a bug:
ERROR: MethodError: no method matching isless(::Float64, ::ComplexF64)...

possible fix:
in levenberg_marquardt.jl in increase and dreacre of trust region radius (lines 262 and 266) switch

            if rho > good_step_quality
                # increase trust region radius
                lambda = max(lambda_decrease * lambda, MIN_LAMBDA)
            end
        else
            # decrease trust region radius
            lambda = min(lambda_increase * lambda, MAX_LAMBDA)
        end

to

            if rho > good_step_quality
                # increase trust region radius
                lambda = max(abs(lambda_decrease * lambda), MIN_LAMBDA)
            end
        else
            # decrease trust region radius
            lambda = min(abs(lambda_increase * lambda), MAX_LAMBDA)
        end
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

1 participant