Scilab:Lotka Volterra模型Scilab上的参数估计 [英] Scilab: Parameters estimation on Lotka Volterra model Scilab

查看:212
本文介绍了Scilab:Lotka Volterra模型Scilab上的参数估计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图重现以下链接的脚本: 带有Scilab的Lotka Volterra模型的参数估计

I have tried to reproduce the script of the following link: Parameters estimation on Lotka Volterra model with Scilab

我在结果中得到的错误与其中描述的相似. 您可以指导我正确运行脚本. 格拉西亚斯 爱马仕(Hermes)

And I get similar errors in the results to those described in it.. You could guide me to run the script without errors. Gracias Hermes

推荐答案

Scilab 5.5.1或更小版本的解决方案

问题在于,求解器以某种方式到达无法求解每个t上的ode的点,并在某个点处停止.因此,您的y_calc的大小小于y_exp的大小.

Solution for Scilab 5.5.1 or smaller

The problem is that the solver somehow reach a point where it cannot solve the ode on every t and stops at a certain point. Thus your y_calc is smaller than y_exp in size.

如果这对您来说不是问题,请将Differences函数第6行的diffmat更改为

If this is not a problem for you, change diffmat on line 6 of the Differences function to

diffmat = y_calc' - y_exp(1:size(y_calc',1),:)

Scilab 6.0.0或更高版本的解决方案

ode函数现在在Scilab 6.X.X中无法计算时会引发错误.

Solution for Scilab 6.0.0 or greater

The ode function now raise an error when it fails to compute in Scilab 6.X.X.

使用try ... catch ... end语句,我们可以让程序处理它.

Using the try ... catch ... end statements, we can let the program deal with it.

所以一个错误的解决方案(我将在后面解释原因)将Differences函数的第5行更改为

So a wrong (and i will explain why after) solution is changing line 5 of Differences function to

try // test if ode works normally
  [y_calc,odew,odeiw]=ode(y0',t0,t,list(LotkaVolterra,c,n,m,e)) 
catch // if an error is raised
  y_calc = y_exp' // Put a value when the computations fails
end
diffmat = y_calc' - y_exp(1:size(y_calc',1),:)

您仍然会收到ode的警告.

You would still get warning from ode.

由于您要一个正在运行的程序,因此我使用了try catch语句来抛弃该错误并使程序继续运行.你不应该.这意味着您的问题定义不正确:参数选择不正确或无法数字求解.我建议研究程序背后的数学原理,并找出为什么某些参数可能破坏ode算法的原因.

Since you asked for a running program, i've used the try catch statement to toss away the error and let the program continue. You should not. It means that your problem is ill defined: the parameters are poorly chosen or it's not numerically solvable. I recommend to work on the mathematics behind the program and find why some parameters may break the ode algorithm.

还有另一个原因,您不应该听从我的回答.如您所见,当我遇到错误时,我给y_calc一些值.但这在数学上是荒谬的,因为优化问题依赖于这样的事实,即解决方案充其量近似于初始问题.我99%确信y_calc = y_exp'语句将为您提供无法使用的结果.

And there's another reason you should not follow my answer. As you see, when I catch an error, I give to y_calc some value. But that's mathematically absurd because an optimization problem rely on the fact that the solution approximate at best the initial problem. I'm 99% sure that the y_calc = y_exp' statement will gives you unusable results.

这篇关于Scilab:Lotka Volterra模型Scilab上的参数估计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆