// ----------------------------------------------------------------------------------- // /* ROOT macro for fitting the World Population and predicting its future. Author: Troels C. Petersen (NBI) Email: petersen@nbi.dk Date: 4th of October 2012 */ // ----------------------------------------------------------------------------------- // // ----------------------------------------------------------------------------------- // double func_pol1(double *x, double *par) { // ----------------------------------------------------------------------------------- // return par[0] + par[1]*x[0]; } // ----------------------------------------------------------------------------------- // void WorldPopulation() { // ----------------------------------------------------------------------------------- // gROOT->Reset(); // Setting of general plotting style: gStyle->SetCanvasColor(0); gStyle->SetFillColor(0); // Setting what to be shown in statistics box: gStyle->SetOptStat(0); gStyle->SetOptFit(1111); // ------------------------------------------------------------------ // // Define the data: // ------------------------------------------------------------------ // const int Npoints = 17; double x[Npoints] = { 1750, 1800, 1850, 1900, 1950, 1955, 1960, 1965, 1970, 1975, 1980, 1985, 1990, 1995, 2000, 2005, 2010}; double ex[Npoints] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; double y[Npoints] = { 791, 978, 1262, 1650, 2519, 2756, 2982, 3335, 3692, 4068, 4435, 4831, 5263, 5674, 6070, 6454, 6972}; double ey[Npoints]; // Well, this is up to you // ------------------------------------------------------------------ // // Fit the data and plot the result: // ------------------------------------------------------------------ // // Make a white canvas: c1 = new TCanvas("c1","",650,20,600,450); c1->SetFillColor(0); // Define a histogram (range, axis titles, etc.), where the graph is to be plottet: TH1F *h1 = c1->DrawFrame(0.0,0.0,10.0,10.0); h1->SetXTitle("Year"); h1->SetTitleOffset(1.0,"y"); h1->SetYTitle("World Population (in millions)"); // Make graphs (using a known number of points in four arrays): TGraphErrors* graph = new TGraphErrors(Npoints, x, y, ex, ey); graph->SetMarkerColor(1); graph->SetMarkerStyle(20); graph->SetMarkerSize(1.0); graph->Draw("P same"); c1->Update(); // c1->SaveAs("WorldPopulation.png"); } //---------------------------------------------------------------------------------- /* Questions: ---------- 1) Try to fit the World Population data. How well do you think the World Population was known at different times? Does your initial guess agree with the Chi2 of your fit to data? Also, try to fit only up to a certain year, say 1970, and see how well your model predicts the (known) future. 2) What is your estimate for the World Population by the year 2050? And by 2100? And does it reach a maximum? Remember to include an uncertainty on your estimate! Compare your results with your fellow students. Given the same data, did you agree on the future projections? 3) Now read the associated data for the period 1950-2011. Try to fit it with the same model - does it fit well? How about the errors? Possibly try another model. Do you find a maximum population (and if so, when?). 4) Consider instead the yearly growth, and try to fit this. Do you now have an idea of a maximum World Population? And can you estimate (with errors of course) when that happens? Advanced questions: ------------------- 1) Find other sources of this data, possibly more complete, and repeat the exercise. */ //----------------------------------------------------------------------------------