私の仕事は、式 を使用して人口増加をモデル化するプログラムを作成することですx_new = r * x_previous * (1-x_previous)
。ここr
で、 は繁殖力パラメーターで、x
は人口です。私は実用的なプログラムと方法を持っています。しかし、私の数学はチェックアウトしていません。.01
の初期母集団、繁殖力パラメータ1.1
、1000
時間ステップをテストして、約 の答えを得ることができるはずです.09
)。
これが私のプログラムです:
import java.util.Scanner;
public class Lab6Question3 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("The population, p: ");
double p = input.nextDouble();
System.out.println("The fecundity rate, r: ");
double r = input.nextDouble();
System.out.println("Number of Time Steps, n: ");
int n = input.nextInt();
int i; //iterations
System.out.println("-------------------------------------");
System.out.println("Simulation with starting population " + p);
System.out.println("Running " + n + " steps");
System.out.println("Varying fecundicity 1, 1.1, ..., 4.9, 5");
for (i = 0; i < n; i++) {
System.out.println("r = " + r + " final population = " + p);
r = r + 0.1;
p = populationGrowth(p, r);
}
}
public static double populationGrowth(double population, double fecundicity)
{
double p;
return (fecundicity * population * (1 - population));
}
}
私の出力は反復で正しくフォーマットされていますが、母集団の結果は間違っています:
Simulation with starting population 0.01
Running 10000 steps
Varying fecundicity 1, 1.1, ..., 4.9, 5
r = 1.0 final population = 0.01
r = 1.1 final population = 0.01089
r = 1.2000000000000002 final population = 0.012925689480000004
r = 1.3000000000000003 final population = 0.01658620084090661
.
.
.
痛みの原因は何ですか?前もって感謝します!