1/2/2024 0 Comments Coderunner column 80You'll have in the Assignmento directory, the file 'pop.txt' and the plot (graph) should appear when we run your code. Calculate the total error described above and assign that value to the variable error. ![]() Complete the functions get_data(), pop() and error() that models the population growth. Remember your lab for file 10 to read the file correctly. You should save this file under the As- signment folder and then read it in the get_data() function. Create a text file called pop.txt that has the same data and format as Table 1 (you can use tab for seperating the columns).Manually check your functions before attempting to create the plot. You only need to ensure that the error() function return the correct output. For plotting, we are using the python library "Matplotlib' - it's already imported in the starter code and the code is already setup. The variable total_error is used for plotting afterwards. After completing all the functions, uncomment line 112-123 and notice that we are storing the output from the functions error (line 112) in a variable called total_error. Note: In the starter we have already provided the code for creaitng this plot (line 112-123). +|P110 - pop(110) where p is the population (from the data) at year 1900 + i. The closer the answer is to zero, the better the model! So we can sum all the error. Let's find the absolute value of the difference of the data poo and our model pop(60) |3040 – pop(60)] = [3040 – 3298.428492408121| = 258.4284924081212 (17) I'm using the value of the function I've written in Python-and kept the decimal places so you can replicate it-but it doesn't contribute significantly to the overall answer. For example, po = 1650, Pio = 1750, P20 = 1860 (you can cross check these values from the table above). We will write p to indicate population for that year. Similarly, we can subtract 1900 from the year (1960-1900), so the input to the function is 60. The first thing we can do to simplify this even more is to discard x 106 and treat the population just as 3040. For example, in 1960, the data says the population was 3040 x 106. If the difference is not high then it means that the model is doing good otherwise if the difference is large then the model's predictions may not be that good as they tend to be far away from the actual population (as given in Table-1). This simply tells us how far away are the predictions of the model from the true population in that particular year. A proposed model of these data is: pop(year) = 1436.53(1.01395) pear (16) Can we judge how good this model is? There are many ways, but the simplest is to check the difference between the value of the data and the value from the model for a particular year. ![]() Table 1 has approximate values for a little over a century beginning with the earth's population of people in 1900s. To get a better understanding of these kinds of functions, we'll look at the population growth of people. Exponential functions grow very fast-we can see it in real-life with the spread of COVID 19 infections. Here is the general form: f(1) = a(b) (15) where a, b are constants. Exponential functions are a class of functions that find use in virtually every field. Problem 2: Modeling Data and Judging Goodness of a Model Years + 1900 Population x 106 110 Table 1: Human Population from 1900-2010 in millions.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |