首页 > > 详细

Writing R Homework ,Python Homework Writing,Writing R Homework ,RHomework Help,Help R Homework

A4: Question 1
In Question 1 we are modelling the female population of a species, split into n
age groups of equal duration (one year each).
In the procedure you will have the following input:
 an integer parameter k;
 a matrix M of size 3×n (for some integer n), that will be read in from an
input file chosen using the parameter k. The matrix M will have the form.
M=⎣⎡b1s1y1b2s2y2b3s3y3……… bn−1sn−1yn−1bn0yn⎦⎤,
where
 for each 1≤i≤n, bi is the birth parameter for age group i,
 for each 1≤i≤n−1, si is the survival probability for age group i,
 for each 1≤i≤n, yi is the initial population of age group i.
Your task: Form. the Leslie matrix L, and use it to calculate the population
distribution after 10 years.
For each j=0,1,2,… , let xj be the vector of populations after j years, where
the ith component of xj is the population of age group i after j years. This
means that x0=[y1,y2,…,yn].
You must write a procedure that computes the Leslie matrix L and the
population distribution column vector x10.
Running your code:
When you press "Run", you will first be prompted to enter the integer
parameter k. To test your program, you should only enter either 1, 2, or 3.
However, please note that when you click submit, your program will be tested
using other values of k, and so your code should cater for any positive integer
k. (In fact, the value of k has nothing to do with the size of the matrix M, so you
shouldn't refer to it in the code you write at all.)
After you enter k, a matrix M will be generated; in the cases k=1, k=2, and
k=3, the matrix M is uploaded from the files matrix1.in, matrix2.in, and
matrix3.in, respectively. You may run your code as many times as you like.
Expected output:
The scaffold code is set up to print the matrix L, and then print the column
vector x10 below it, with the entries of x10 rounded to the nearest integer.
Please note that you must not write code that displays any output other
than the output produced by the scaffold code. Recall that a semicolon (;)
at the end of a line suppresses any output from that line.
How your code will be marked:
When you press "Submit", your code will be tested on several test inputs,
including some hidden test inputs.
Note that if you fail one of the tests, the testing process will stop and your code
will not be tested on the remaining tests. You have completed the question
when all of the tests have passed.



 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!