Plot the expression (determined in modelling the growth of the US population) P(
ID: 3866588 • Letter: P
Question
Plot the expression (determined in modelling the growth of the US population) P(t) = where t is the date, in years AD, using t = 1790 to 2000. What population is predicted in the year 2020? 5. Create an M-by-N array of random numbers (use rand). Move through the array, element by element, and set any value that is less than 0.2 to 0 and any value that is greater than (or equal to) 0.2 to 1. 6. Write a code that will use the random-number generator rand to determine the following: I. The number of random numbers it takes to add up to 20. II The number of random numbers it takes before a number between 0.8 and 0.85 occurs. III. The number of random numbers it takes before the mean of those numbers is within 0.01 of 0.5 (the mean of this random-number generator). 7. Compute the cumulative product of the elements in a vector. The cumulative product of the j^th element of the vector x, x_ is defined by: P_i = x_1 x_2 x_3 .. x_j for j = 1: length of the vector x. Create 2 different versions of this function: I. One that uses two for-loops to explicitly carry out the calculations, element by element. An "inner" loop should accumulate the product and an "outer" loop should move through the elements of the vector p. II. One that uses the built-in function prod to replace the inner loop. In each case, you can check your results with the built-in function, cumprod.Explanation / Answer
Please post 1 question at a time buddy. We are allowed to answer only 1 at a time. This is answer to question 4
p = @(t) 197273000/(1 + exp(-0.313*(t - 1913.25)));
year = [];
population = [];
for i = 1790:2000
year = [year i];
population = [population p(i)];
end
plot(year, population)
predict = p(2020)
fprintf("Predicted population in 2020 is: %d ", predict);