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

plot cost function fo estimate multiple parameters #929

Closed
kikiggg opened this issue Jan 22, 2023 · 1 comment
Closed

plot cost function fo estimate multiple parameters #929

kikiggg opened this issue Jan 22, 2023 · 1 comment

Comments

@kikiggg
Copy link

kikiggg commented Jan 22, 2023

using DifferentialEquations, RecursiveArrayTools, Plots, DiffEqParamEstim

function f2(du,u,p,t)
    du[1] = dx = p[1]*u[1] - p[2]*u[1]*u[2]
    du[2] = dy = -p[3]*u[2] + p[4]*u[1]*u[2]
  end
  
  u0 = [1.0;1.0]
  tspan = (0.0,10.0)
  p = [1.5,1.0,3.0,1.0]
  prob = ODEProblem(f2,u0,tspan,p)

  sol = solve(prob,Tsit5())
t = collect(range(0,stop=10,length=200))

randomized = VectorOfArray([(sol(t[i]) + .01randn(2)) for i in 1:length(t)])
data = convert(Array,randomized)

vals = 0.0:0.1:10.0

plot(vals,[cost_function(i) for i in vals],yscale=:log10,  xaxis = "Parameter", yaxis = "Cost", 
title = "Parameter Cost Function", lw = 3)

hi im learning parameter estimation but problem is plotting cost function with multiple parameters as a example.
With Boundserror could not be plotted
im literally noob with code, i was trying tof fix it but i could not...
How can i get plot ?

@ChrisRackauckas
Copy link
Member

Discourse or Slack is a better place for this question as it's not a bug report. https://discourse.julialang.org/

But what you need to do is define your cost function and then pass it the array of parameters to evaluate at.

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

2 participants