如果题目的意思是:
方法头必须是double[] preyPredLV(double[] preyPred, double[] a, double[] b, int n};
然后,题目的要求如下,谁能给出一段代码,符合题目的要求?
The dynamics between predators and preys in a given ecosystem attracts a lot of attention from researchers. Different scientists have developed Predator-Prey models to try to understand the interactions and foresee the evolution of the populations.
在给定的生态系统里,食肉动物和猎物之间的动态吸引了许多来自调研人员的注意力。不同的科学家开发了食肉动物-猎物模型,试图理解和预测人口进化的交互。
One of the first analyzed Predator-Prey ecosystems was the “Lynx-Snowshoe hare” and one of the first Predator-Prey models defined was the one developed by Lotka and Volterra.
其中,第一个分析食肉动物-猎物生态系统的是”Lynx-Snow雪地靴野兔”,以及第一个定义的食肉动物-猎物模型是由Lotka和Volterrra开发的。
This Predator-Prey model defines:
这个食肉动物-猎物模型定义了:
H[n] as the snowshoe hare population (being n a specific moment of time)
是雪地靴野兔的人口(n是一个特定时刻 )
L[n] as the lynx population
是猞猁的人口
It assumes that the primary growth of the hare population in the absence of lynx is a1*H[n] and that the lynx population in the absence of hares declines –b1*L[n]
假设,当猞猁缺乏的时候,野兔人口的主要增长是a1*H[n],并且,野兔缺乏的时候,猞猁的人口下降是-b1*L[n].
It also assumes that the primary loss of snowshoe hares is due to predating a2*H[n]*L[n] and the growth of the lynx population is from the energy derived from eating snowshoe hares b2*H[n]*L[n]
它还假设雪地靴野兔的主要减少是因为捕食a2*H[n]*L[n],且猞猁的人口增长是因为来源于吃雪地靴野兔得到的能量b2*H[n]*L[n]
The Lotka-Volterra model is defined by the following formula:
H[n+1] = H[n] + a1 * H[n] - a2*H[n]*L[n] = H[n] * (1 + a1 - a2*L[n])
L[n+1] = L[n] - b1 * L[n] + b2*H[n]*L[n] = L[n] * (1 - b1 +b2*H[n])
For instance, let’s assume that the initial population of snowshoe hares is 300 and the initial population of lynxes is 20, and the values of the constants that regulate the model are a1=0.1, a2=0.01, b1=0.01 and b2=0.00002. The previous formula can be used to calculate the population of both lynxes and snowshoe hares after 2 periods:
举个例子,让我们假设,雪地靴野兔的初始人口是300个,猞猁的初始人口是20个,约束这个模型的常量的值是a1=0.1, a2=0.01, b1=0.01 and b2=0.00002。前一个公式能被用来计算猞猁和雪地靴野兔的人口,在期间2以后。
After 1 period the population of snowshoe hares will be:
在期间1以后,雪地靴野兔的人口将会是:
H[1] = H[0] + a1 * H[0] - a2*H[0]*L[0] = H[0] * (1 + a1 - a2*L[0]) = 300 *(1 + 0.1 - 0.01*20) = 270
In turn, the population of lynxes will be:
相应地,猞猁的人口将会是:
L[1] = L[0] - b1 * L[0] + b2*H[0]*L[0] = L[0] * (1 - b1 +b2*H[0]) = 20 * (1 - 0.01 + 0.00002*300) = 19.92
Notice that we keep the decimals for the following loop in the formula.
注意,我们保持小数点给公式里的下面的循环
After 2 periods, the population of snowshoe hares will be:
H[2] = H[1] * (1 + a1 - a2*L[1]) = 270 * (1 + 0.1 - 0.01*19.92) = 243.216
经过2个期间,雪地靴野兔的人口将会是如上面的公式
And the population of lynxes will be:
L[2] = L[1] * (1 - b1 +b2*H[1]) = 19.92 * (1 - 0.01 + 0.00002*270) = 19.828368
且猞猁的人口将会是以上的只数
If we continue, we can guess the population after 20 periods:
H[20]=47.15 snowshoe hares
L[20]=17.28 lynxes
如果我们继续,我们能够猜测20个期间以后的人口数:
Or after 100 periods:
H[100]=8.44 snowshoe hares
L[100]=7.89 lynxes
经过100期间:
Or even after 200 periods:
H[200]=903.17 snowshoe hares
L[200]=3.91 lynxes
或者甚至经过200个期间以后: