Skip to content

variable for intercept is being ignored during optimization? #167

@lmiq

Description

@lmiq
julia> using Plots, LsqFit

julia> x = collect(1:10); y = x.^2; scatter(x,y)

julia> @. model(x,p) = p[1]*x^2 + p[2]
model (generic function with 1 method)

julia> p0 = [ 5. , -20. ];

julia> fit = curve_fit(model, x, y, p0);

julia> plot!(x,model(x,fit.param),label="no bounds")

julia> fit = curve_fit(model, x, y, p0, upper=[+Inf,-20.]);

julia> plot!(x,model(x,fit.param),label="with bounds")

Results in:

image

I was expecting a greater slope for the result of the fitting, such to minimize the residue. Actually, one gets exactly the same function as the unbounded case, except shifted such that the constant parameter is satisfied.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions