/
chap08.html
1128 lines (963 loc) · 52.5 KB
/
chap08.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
<title>Projecting Population Growth — Modeling and Simulation in Python</title>
<script data-cfasync="false">
document.documentElement.dataset.mode = localStorage.getItem("mode") || "";
document.documentElement.dataset.theme = localStorage.getItem("theme") || "light";
</script>
<!-- Loaded before other Sphinx assets -->
<link href="_static/styles/theme.css?digest=e353d410970836974a52" rel="stylesheet" />
<link href="_static/styles/bootstrap.css?digest=e353d410970836974a52" rel="stylesheet" />
<link href="_static/styles/pydata-sphinx-theme.css?digest=e353d410970836974a52" rel="stylesheet" />
<link href="_static/vendor/fontawesome/6.1.2/css/all.min.css?digest=e353d410970836974a52" rel="stylesheet" />
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.1.2/webfonts/fa-solid-900.woff2" />
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.1.2/webfonts/fa-brands-400.woff2" />
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.1.2/webfonts/fa-regular-400.woff2" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" href="_static/styles/sphinx-book-theme.css?digest=14f4ca6b54d191a8c7657f6c759bf11a5fb86285" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/togglebutton.css" />
<link rel="stylesheet" type="text/css" href="_static/copybutton.css" />
<link rel="stylesheet" type="text/css" href="_static/mystnb.4510f1fc1dee50b3e5859aac5469c37c29e427902b24a333a5f9fcb2f0b3ac41.css" />
<link rel="stylesheet" type="text/css" href="_static/sphinx-thebe.css" />
<link rel="stylesheet" type="text/css" href="_static/design-style.4045f2051d55cab465a707391d5b2007.min.css" />
<!-- Pre-loaded scripts that we'll load fully later -->
<link rel="preload" as="script" href="_static/scripts/bootstrap.js?digest=e353d410970836974a52" />
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=e353d410970836974a52" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/clipboard.min.js"></script>
<script src="_static/copybutton.js"></script>
<script src="_static/scripts/sphinx-book-theme.js?digest=5a5c038af52cf7bc1a1ec88eea08e6366ee68824"></script>
<script>let toggleHintShow = 'Click to show';</script>
<script>let toggleHintHide = 'Click to hide';</script>
<script>let toggleOpenOnPrint = 'true';</script>
<script src="_static/togglebutton.js"></script>
<script>var togglebuttonSelector = '.toggle, .admonition.dropdown';</script>
<script src="_static/design-tabs.js"></script>
<script>const THEBE_JS_URL = "https://unpkg.com/thebe@0.8.2/lib/index.js"
const thebe_selector = ".thebe,.cell"
const thebe_selector_input = "pre"
const thebe_selector_output = ".output, .cell_output"
</script>
<script async="async" src="_static/sphinx-thebe.js"></script>
<script>DOCUMENTATION_OPTIONS.pagename = 'chap08';</script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Analysis of Population Growth" href="chap09.html" />
<link rel="prev" title="Limits to Growth" href="chap07.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
</head>
<body data-bs-spy="scroll" data-bs-target=".bd-toc-nav" data-offset="180" data-bs-root-margin="0px 0px -60%" data-default-mode="">
<a class="skip-link" href="#main-content">Skip to main content</a>
<input type="checkbox"
class="sidebar-toggle"
name="__primary"
id="__primary"/>
<label class="overlay overlay-primary" for="__primary"></label>
<input type="checkbox"
class="sidebar-toggle"
name="__secondary"
id="__secondary"/>
<label class="overlay overlay-secondary" for="__secondary"></label>
<div class="search-button__wrapper">
<div class="search-button__overlay"></div>
<div class="search-button__search-container">
<form class="bd-search d-flex align-items-center"
action="search.html"
method="get">
<i class="fa-solid fa-magnifying-glass"></i>
<input type="search"
class="form-control"
name="q"
id="search-input"
placeholder="Search this book..."
aria-label="Search this book..."
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"/>
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd></span>
</form></div>
</div>
<nav class="bd-header navbar navbar-expand-lg bd-navbar">
</nav>
<div class="bd-container">
<div class="bd-container__inner bd-page-width">
<div class="bd-sidebar-primary bd-sidebar">
<div class="sidebar-header-items sidebar-primary__section">
</div>
<div class="sidebar-primary-items__start sidebar-primary__section">
<div class="sidebar-primary-item">
<a class="navbar-brand logo" href="index.html">
<p class="title logo__title">Modeling and Simulation in Python</p>
</a></div>
<div class="sidebar-primary-item"><nav class="bd-links" id="bd-docs-nav" aria-label="Main">
<div class="bd-toc-item navbar-nav active">
<ul class="nav bd-sidenav bd-sidenav__home-link">
<li class="toctree-l1">
<a class="reference internal" href="index.html">
Modeling and Simulation in Python
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Chapters</span></p>
<ul class="current nav bd-sidenav">
<li class="toctree-l1"><a class="reference internal" href="preface.html">Preface</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap01.html">Modeling</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap02.html">Bike Share System</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap03.html">Iteration</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap04.html">Sweeping Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap05.html">World Population</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap06.html">Proportional Growth</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap07.html">Limits to Growth</a></li>
<li class="toctree-l1 current active"><a class="current reference internal" href="#">Projecting Population Growth</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap09.html">Analysis of Population Growth</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap10.html">Case Studies Part 1</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap11.html">Epidemiology</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap12.html">Modeling Vaccination</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap13.html">Sweeping Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap14.html">Nondimensionalization</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap15.html">Cooling Coffee</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap16.html">Adding Milk</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap17.html">Pharmacokinetics</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap18.html">Glucose and Insulin</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap19.html">Case Studies Part 2</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap20.html">The Empire State Building Strikes Back</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap21.html">Drag</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap22.html">Baseball</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap23.html">Optimal Baseball</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap24.html">Rotation</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap25.html">Torque</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap26.html">Case Studies Part 3</a></li>
<li class="toctree-l1"><a class="reference internal" href="chap27.html">Under the Hood</a></li>
</ul>
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Examples</span></p>
<ul class="nav bd-sidenav">
<li class="toctree-l1"><a class="reference internal" href="queue.html">One Queue or Two</a></li>
</ul>
</div>
</nav></div>
</div>
<div class="sidebar-primary-items__end sidebar-primary__section">
</div>
<div id="rtd-footer-container"></div>
</div>
<main id="main-content" class="bd-main">
<div class="sbt-scroll-pixel-helper"></div>
<div class="bd-content">
<div class="bd-article-container">
<div class="bd-header-article">
<div class="header-article-items header-article__inner">
<div class="header-article-items__start">
<div class="header-article-item"><label class="sidebar-toggle primary-toggle btn btn-sm" for="__primary" title="Toggle primary sidebar" data-bs-placement="bottom" data-bs-toggle="tooltip">
<span class="fa-solid fa-bars"></span>
</label></div>
</div>
<div class="header-article-items__end">
<div class="header-article-item">
<div class="article-header-buttons">
<a href="https://github.com/AllenDowney/ModSimPy" target="_blank"
class="btn btn-sm btn-source-repository-button"
title="Source repository"
data-bs-placement="bottom" data-bs-toggle="tooltip"
>
<span class="btn__icon-container">
<i class="fab fa-github"></i>
</span>
</a>
<div class="dropdown dropdown-download-buttons">
<button class="btn dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false" aria-label="Download this page">
<i class="fas fa-download"></i>
</button>
<ul class="dropdown-menu">
<li><a href="_sources/chap08.ipynb" target="_blank"
class="btn btn-sm btn-download-source-button dropdown-item"
title="Download source file"
data-bs-placement="left" data-bs-toggle="tooltip"
>
<span class="btn__icon-container">
<i class="fas fa-file"></i>
</span>
<span class="btn__text-container">.ipynb</span>
</a>
</li>
<li>
<button onclick="window.print()"
class="btn btn-sm btn-download-pdf-button dropdown-item"
title="Print to PDF"
data-bs-placement="left" data-bs-toggle="tooltip"
>
<span class="btn__icon-container">
<i class="fas fa-file-pdf"></i>
</span>
<span class="btn__text-container">.pdf</span>
</button>
</li>
</ul>
</div>
<button onclick="toggleFullScreen()"
class="btn btn-sm btn-fullscreen-button"
title="Fullscreen mode"
data-bs-placement="bottom" data-bs-toggle="tooltip"
>
<span class="btn__icon-container">
<i class="fas fa-expand"></i>
</span>
</button>
<script>
document.write(`
<button class="theme-switch-button btn btn-sm btn-outline-primary navbar-btn rounded-circle" title="light/dark" aria-label="light/dark" data-bs-placement="bottom" data-bs-toggle="tooltip">
<span class="theme-switch" data-mode="light"><i class="fa-solid fa-sun"></i></span>
<span class="theme-switch" data-mode="dark"><i class="fa-solid fa-moon"></i></span>
<span class="theme-switch" data-mode="auto"><i class="fa-solid fa-circle-half-stroke"></i></span>
</button>
`);
</script>
<script>
document.write(`
<button class="btn btn-sm navbar-btn search-button search-button__button" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass"></i>
</button>
`);
</script>
<label class="sidebar-toggle secondary-toggle btn btn-sm" for="__secondary"title="Toggle secondary sidebar" data-bs-placement="bottom" data-bs-toggle="tooltip">
<span class="fa-solid fa-list"></span>
</label>
</div></div>
</div>
</div>
</div>
<div id="jb-print-docs-body" class="onlyprint">
<h1>Projecting Population Growth</h1>
<!-- Table of contents -->
<div id="print-main-content">
<div id="jb-print-toc">
<div>
<h2> Contents </h2>
</div>
<nav aria-label="Page">
<ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#generating-projections">Generating Projections</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#comparing-projections">Comparing Projections</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#summary">Summary</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#exercises">Exercises</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#exercise-1">Exercise 1</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div id="searchbox"></div>
<article class="bd-article" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="projecting-population-growth">
<h1>Projecting Population Growth<a class="headerlink" href="#projecting-population-growth" title="Permalink to this heading">#</a></h1>
<p>In the previous chapter we developed a quadratic model of world
population growth from 1950 to 2016. It is a simple model, but it fits
the data well and the mechanisms it’s based on are plausible.</p>
<p>In this chapter we’ll use the quadratic model to generate projections of future growth, and compare our results to projections from actual
demographers.</p>
<section id="generating-projections">
<h2>Generating Projections<a class="headerlink" href="#generating-projections" title="Permalink to this heading">#</a></h2>
<p>Let’s run the quadratic model, extending the results until 2100, and see how our projections compare to the professionals’.</p>
<p>Here’s the quadratic growth function again.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">growth_func_quad</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">pop</span><span class="p">,</span> <span class="n">system</span><span class="p">):</span>
<span class="k">return</span> <span class="n">system</span><span class="o">.</span><span class="n">alpha</span> <span class="o">*</span> <span class="n">pop</span> <span class="o">+</span> <span class="n">system</span><span class="o">.</span><span class="n">beta</span> <span class="o">*</span> <span class="n">pop</span><span class="o">**</span><span class="mi">2</span>
</pre></div>
</div>
</div>
</div>
<p>And here are the system parameters.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">t_0</span> <span class="o">=</span> <span class="n">census</span><span class="o">.</span><span class="n">index</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">p_0</span> <span class="o">=</span> <span class="n">census</span><span class="p">[</span><span class="n">t_0</span><span class="p">]</span>
<span class="n">system</span> <span class="o">=</span> <span class="n">System</span><span class="p">(</span><span class="n">t_0</span> <span class="o">=</span> <span class="n">t_0</span><span class="p">,</span>
<span class="n">p_0</span> <span class="o">=</span> <span class="n">p_0</span><span class="p">,</span>
<span class="n">alpha</span> <span class="o">=</span> <span class="mi">25</span> <span class="o">/</span> <span class="mi">1000</span><span class="p">,</span>
<span class="n">beta</span> <span class="o">=</span> <span class="o">-</span><span class="mf">1.8</span> <span class="o">/</span> <span class="mi">1000</span><span class="p">,</span>
<span class="n">t_end</span> <span class="o">=</span> <span class="mi">2100</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<p>With <code class="docutils literal notranslate"><span class="pre">t_end=2100</span></code>, we can generate the projection by calling <code class="docutils literal notranslate"><span class="pre">run_simulation</span></code> the usual way.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">results</span> <span class="o">=</span> <span class="n">run_simulation</span><span class="p">(</span><span class="n">system</span><span class="p">,</span> <span class="n">growth_func_quad</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<p>Here are the last few values in the results.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">show</span><span class="p">(</span><span class="n">results</span><span class="o">.</span><span class="n">tail</span><span class="p">())</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_html"><div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>Quantity</th>
</tr>
<tr>
<th>Time</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>2096</th>
<td>12.462519</td>
</tr>
<tr>
<th>2097</th>
<td>12.494516</td>
</tr>
<tr>
<th>2098</th>
<td>12.525875</td>
</tr>
<tr>
<th>2099</th>
<td>12.556607</td>
</tr>
<tr>
<th>2100</th>
<td>12.586719</td>
</tr>
</tbody>
</table>
</div></div></div>
</div>
<p>Here’s what the results look like.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">results</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">color</span><span class="o">=</span><span class="s1">'gray'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">'model'</span><span class="p">)</span>
<span class="n">decorate</span><span class="p">(</span><span class="n">xlabel</span><span class="o">=</span><span class="s1">'Year'</span><span class="p">,</span>
<span class="n">ylabel</span><span class="o">=</span><span class="s1">'World population (billions)'</span><span class="p">,</span>
<span class="n">title</span><span class="o">=</span><span class="s1">'Quadratic model projection'</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/f3934ca127f89ce76de7fea4220fb74dd3b82855b332a34edd804e9e5943523f.png" src="_images/f3934ca127f89ce76de7fea4220fb74dd3b82855b332a34edd804e9e5943523f.png" />
</div>
</div>
<p>According to the model, population growth will slow gradually after 2020, approaching 12.6 billion by 2100.</p>
<p>I am using the word <em>projection</em> deliberately, rather than
<em>prediction</em>, with the following distinction: “prediction” implies
something like “this is what we expect to happen, at
least approximately”; “projection” implies something like “if this
model is a good description of the system, and if nothing in the future causes the system parameters to change, this is what would happen.”</p>
<p>Using “projection” leaves open the possibility that there are important things in the real world that are not captured in the model. It also suggests that, even if the model is good, the parameters we estimate based on the past might be different in the future.</p>
<p>The quadratic model we’ve been working with is based on the assumption
that population growth is limited by the availability of resources; in
that scenario, as the population approaches carrying capacity, birth
rates fall and death rates rise because resources become scarce.</p>
<p>If that assumption is valid, we might be able to use actual population
growth to estimate carrying capacity, provided we observe the
transition into the population range where the growth rate starts to fall.</p>
<p>But in the case of world population growth, those conditions don’t
apply. Over the last 50 years, the net growth rate has leveled off, but not yet started to fall, so we don’t have enough data to make a credible estimate of carrying capacity. And resource limitations are probably <em>not</em> the primary reason growth has slowed. As evidence, consider:</p>
<ul class="simple">
<li><p>First, the death rate is not increasing; rather, it has declined
from 1.9% in 1950 to 0.8% now (see <a class="reference external" href="http://modsimpy.com/mortality">http://modsimpy.com/mortality</a>).
So the decrease in net growth is due entirely to declining birth
rates.</p></li>
<li><p>Second, the relationship between resources and birth rate is the
opposite of what the model assumes; as nations develop and people
become more wealthy, birth rates tend to fall.</p></li>
</ul>
<p>We should not take too seriously the idea that this model can estimate
carrying capacity. But the predictions of a model can be credible even
if the assumptions of the model are not strictly true. For example,
population growth might behave <em>as if</em> it is resource limited, even if
the actual mechanism is something else.</p>
<p>In fact, demographers who study population growth often use models
similar to ours. In the next section, we’ll compare our projections to
theirs.</p>
</section>
<section id="comparing-projections">
<h2>Comparing Projections<a class="headerlink" href="#comparing-projections" title="Permalink to this heading">#</a></h2>
<p>From the same Wikipedia page where we got the past population estimates, we’ll read <code class="docutils literal notranslate"><span class="pre">table3</span></code>, which contains projections for population growth over the next 50-100 years, generated by the U.S. Census, U.N. DESA, and the Population Reference Bureau.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">table3</span> <span class="o">=</span> <span class="n">tables</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span>
</pre></div>
</div>
</div>
</div>
<p>The column names are long strings; for convenience, I’ll replace them with abbreviations.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">table3</span><span class="o">.</span><span class="n">columns</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'census'</span><span class="p">,</span> <span class="s1">'prb'</span><span class="p">,</span> <span class="s1">'un'</span><span class="p">]</span>
</pre></div>
</div>
</div>
</div>
<p>Here are the first few rows:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">table3</span><span class="o">.</span><span class="n">head</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_html"><div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>census</th>
<th>prb</th>
<th>un</th>
</tr>
<tr>
<th>Year</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>2016</th>
<td>7.334772e+09</td>
<td>NaN</td>
<td>7.432663e+09</td>
</tr>
<tr>
<th>2017</th>
<td>7.412779e+09</td>
<td>NaN</td>
<td>NaN</td>
</tr>
<tr>
<th>2018</th>
<td>7.490428e+09</td>
<td>NaN</td>
<td>NaN</td>
</tr>
<tr>
<th>2019</th>
<td>7.567403e+09</td>
<td>NaN</td>
<td>NaN</td>
</tr>
<tr>
<th>2020</th>
<td>7.643402e+09</td>
<td>NaN</td>
<td>7.758157e+09</td>
</tr>
</tbody>
</table>
</div></div></div>
</div>
<p>Some values are <code class="docutils literal notranslate"><span class="pre">NaN</span></code>, which indicates missing data, because some organizations did not publish projections for some years.
The following function plots projections from the U.N. DESA and U.S. Census. It uses <code class="docutils literal notranslate"><span class="pre">dropna</span></code> to remove the <code class="docutils literal notranslate"><span class="pre">NaN</span></code> values from each series before plotting it.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">plot_projections</span><span class="p">(</span><span class="n">table</span><span class="p">):</span>
<span class="w"> </span><span class="sd">"""Plot world population projections.</span>
<span class="sd"> </span>
<span class="sd"> table: DataFrame with columns 'un' and 'census'</span>
<span class="sd"> """</span>
<span class="n">census_proj</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">census</span><span class="o">.</span><span class="n">dropna</span><span class="p">()</span> <span class="o">/</span> <span class="mf">1e9</span>
<span class="n">un_proj</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">un</span><span class="o">.</span><span class="n">dropna</span><span class="p">()</span> <span class="o">/</span> <span class="mf">1e9</span>
<span class="n">census_proj</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="s1">':'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">'US Census'</span><span class="p">)</span>
<span class="n">un_proj</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="s1">'--'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">'UN DESA'</span><span class="p">)</span>
<span class="n">decorate</span><span class="p">(</span><span class="n">xlabel</span><span class="o">=</span><span class="s1">'Year'</span><span class="p">,</span>
<span class="n">ylabel</span><span class="o">=</span><span class="s1">'World population (billions)'</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<p>Here are the professional projections compared to the results of the quadratic model.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">results</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">color</span><span class="o">=</span><span class="s1">'gray'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">'model'</span><span class="p">)</span>
<span class="n">plot_projections</span><span class="p">(</span><span class="n">table3</span><span class="p">)</span>
<span class="n">decorate</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s1">'Quadratic model projection, with UN and Census'</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/7bdd51ce3b8baf76e446619c945d442a07d815b85ce47af2bc8f3d484d074dd8.png" src="_images/7bdd51ce3b8baf76e446619c945d442a07d815b85ce47af2bc8f3d484d074dd8.png" />
</div>
</div>
<p>The U.N. DESA expects the world population to reach 11 billion around 2100, and then level off.
Projections by U.S. Census are a little lower, and they only go until 2050.</p>
</section>
<section id="summary">
<h2>Summary<a class="headerlink" href="#summary" title="Permalink to this heading">#</a></h2>
<p>In this chapter we use the quadratic growth model to project world population growth between now and 2100.</p>
<p>Real demographers expect world population to grow more slowly than our model, probably because their models are broken down by region and country, where conditions are different, and they take into account expected economic development.</p>
<p>Nevertheless, their projections are qualitatively similar to ours, and
theirs differ from each other almost as much as they differ from ours.
So the results from the model, simple as it is, are not entirely unreasonable.</p>
<p>If you are interested in some of the factors that go into the professional projections, you might like this video by Hans Rosling about the demographic changes we expect this century: <a class="reference external" href="https://www.youtube.com/watch?v=ezVk1ahRF78">https://www.youtube.com/watch?v=ezVk1ahRF78</a>.</p>
</section>
<section id="exercises">
<h2>Exercises<a class="headerlink" href="#exercises" title="Permalink to this heading">#</a></h2>
<p>This chapter is available as a Jupyter notebook where you can read the text, run the code, and work on the exercises.
You can access the notebooks at <a class="reference external" href="https://allendowney.github.io/ModSimPy/">https://allendowney.github.io/ModSimPy/</a>.</p>
<section id="exercise-1">
<h3>Exercise 1<a class="headerlink" href="#exercise-1" title="Permalink to this heading">#</a></h3>
<p>The net growth rate of world population has been declining for several decades. That observation suggests one more way to generate more realistic projections, by extrapolating observed changes in growth rate.</p>
<p>To compute past growth rates, we’ll use a function called <code class="docutils literal notranslate"><span class="pre">diff</span></code>, which computes the difference between successive elements in a <code class="docutils literal notranslate"><span class="pre">Series</span></code>. For example, here are the changes from one year to the next in <code class="docutils literal notranslate"><span class="pre">census</span></code>:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">diff</span> <span class="o">=</span> <span class="n">census</span><span class="o">.</span><span class="n">diff</span><span class="p">()</span>
<span class="n">show</span><span class="p">(</span><span class="n">diff</span><span class="o">.</span><span class="n">head</span><span class="p">())</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_html"><div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>census</th>
</tr>
<tr>
<th>Year</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>1950</th>
<td>NaN</td>
</tr>
<tr>
<th>1951</th>
<td>0.037311</td>
</tr>
<tr>
<th>1952</th>
<td>0.041832</td>
</tr>
<tr>
<th>1953</th>
<td>0.045281</td>
</tr>
<tr>
<th>1954</th>
<td>0.048175</td>
</tr>
</tbody>
</table>
</div></div></div>
</div>
<p>The first element is <code class="docutils literal notranslate"><span class="pre">NaN</span></code> because we don’t have the data for 1949, so we can’t compute the first difference.</p>
<p>If we divide these differences by the populations, the result is an estimate of the growth rate during each year:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">alpha</span> <span class="o">=</span> <span class="n">census</span><span class="o">.</span><span class="n">diff</span><span class="p">()</span> <span class="o">/</span> <span class="n">census</span>
<span class="n">show</span><span class="p">(</span><span class="n">alpha</span><span class="o">.</span><span class="n">head</span><span class="p">())</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_html"><div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>census</th>
</tr>
<tr>
<th>Year</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>1950</th>
<td>NaN</td>
</tr>
<tr>
<th>1951</th>
<td>0.014378</td>
</tr>
<tr>
<th>1952</th>
<td>0.015865</td>
</tr>
<tr>
<th>1953</th>
<td>0.016883</td>
</tr>
<tr>
<th>1954</th>
<td>0.017645</td>
</tr>
</tbody>
</table>
</div></div></div>
</div>
<p>The following function computes and plots the growth rates for the <code class="docutils literal notranslate"><span class="pre">census</span></code> and <code class="docutils literal notranslate"><span class="pre">un</span></code> estimates:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">plot_alpha</span><span class="p">():</span>
<span class="n">alpha_census</span> <span class="o">=</span> <span class="n">census</span><span class="o">.</span><span class="n">diff</span><span class="p">()</span> <span class="o">/</span> <span class="n">census</span>
<span class="n">alpha_census</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="s1">'.'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">'US Census'</span><span class="p">)</span>
<span class="n">alpha_un</span> <span class="o">=</span> <span class="n">un</span><span class="o">.</span><span class="n">diff</span><span class="p">()</span> <span class="o">/</span> <span class="n">un</span>
<span class="n">alpha_un</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="s1">'.'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">'UN DESA'</span><span class="p">)</span>
<span class="n">decorate</span><span class="p">(</span><span class="n">xlabel</span><span class="o">=</span><span class="s1">'Year'</span><span class="p">,</span> <span class="n">ylabel</span><span class="o">=</span><span class="s1">'Net growth rate'</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<p>It uses <code class="docutils literal notranslate"><span class="pre">style='.'</span></code> to plot each data point with a small circle.
And here’s what it looks like.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">plot_alpha</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/4eb95555309767c2c56433df88d81a18be90963b2646f7b017a1c158d5acf05f.png" src="_images/4eb95555309767c2c56433df88d81a18be90963b2646f7b017a1c158d5acf05f.png" />
</div>
</div>
<p>Other than a bump around 1990, the net growth rate has been declining roughly linearly since 1970.</p>
<p>We can model the decline by fitting a line to this data and extrapolating into the future.
Here’s a function that takes a time stamp and computes a line that roughly fits the growth rates since 1970.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">alpha_func</span><span class="p">(</span><span class="n">t</span><span class="p">):</span>
<span class="n">intercept</span> <span class="o">=</span> <span class="mf">0.02</span>
<span class="n">slope</span> <span class="o">=</span> <span class="o">-</span><span class="mf">0.00021</span>
<span class="k">return</span> <span class="n">intercept</span> <span class="o">+</span> <span class="n">slope</span> <span class="o">*</span> <span class="p">(</span><span class="n">t</span> <span class="o">-</span> <span class="mi">1970</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<p>To see what it looks like, I’ll create an array of time stamps from 1960 to 2020 and use <code class="docutils literal notranslate"><span class="pre">alpha_func</span></code> to compute the corresponding growth rates.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">t_array</span> <span class="o">=</span> <span class="n">linspace</span><span class="p">(</span><span class="mi">1960</span><span class="p">,</span> <span class="mi">2020</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="n">alpha_array</span> <span class="o">=</span> <span class="n">alpha_func</span><span class="p">(</span><span class="n">t_array</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<p>Here’s what it looks like, compared to the data.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">matplotlib.pyplot</span> <span class="kn">import</span> <span class="n">plot</span>
<span class="n">plot_alpha</span><span class="p">()</span>
<span class="n">plot</span><span class="p">(</span><span class="n">t_array</span><span class="p">,</span> <span class="n">alpha_array</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">'model'</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">'gray'</span><span class="p">)</span>
<span class="n">decorate</span><span class="p">(</span><span class="n">ylabel</span><span class="o">=</span><span class="s1">'Net growth rate'</span><span class="p">,</span>
<span class="n">title</span><span class="o">=</span><span class="s1">'Linear model of net growth rate'</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/caee466b9407e52817001dc32973643362ae65cc934162bcf155f6e55e473740.png" src="_images/caee466b9407e52817001dc32973643362ae65cc934162bcf155f6e55e473740.png" />
</div>
</div>
<p>If you don’t like the <code class="docutils literal notranslate"><span class="pre">slope</span></code> and <code class="docutils literal notranslate"><span class="pre">intercept</span></code> I chose, feel free to adjust them.</p>
<p>Now, as an exercise, you can use this function to project world population until 2100.</p>
<ol class="arabic simple">
<li><p>Create a <code class="docutils literal notranslate"><span class="pre">System</span></code> object that includes <code class="docutils literal notranslate"><span class="pre">alpha_func</span></code> as a system parameter.</p></li>
<li><p>Define a growth function that uses <code class="docutils literal notranslate"><span class="pre">alpha_func</span></code> to compute the net growth rate at the given time <code class="docutils literal notranslate"><span class="pre">t</span></code>.</p></li>
<li><p>Run a simulation from 1960 to 2100 with your growth function, and plot the results.</p></li>
<li><p>Compare your projections with those from the US Census and UN.</p></li>
</ol>
<div class="cell tag_hide-cell docutils container">
<details class="hide above-input">
<summary aria-label="Toggle hidden content">
<span class="collapsed">Show code cell content</span>
<span class="expanded">Hide code cell content</span>
</summary>
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="n">t_0</span> <span class="o">=</span> <span class="mi">1960</span>
<span class="n">t_end</span> <span class="o">=</span> <span class="mi">2100</span>
<span class="n">p_0</span> <span class="o">=</span> <span class="n">census</span><span class="p">[</span><span class="n">t_0</span><span class="p">]</span>
</pre></div>
</div>
</div>
</details>
</div>
<div class="cell tag_hide-cell docutils container">
<details class="hide above-input">
<summary aria-label="Toggle hidden content">
<span class="collapsed">Show code cell content</span>
<span class="expanded">Hide code cell content</span>
</summary>
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="n">system</span> <span class="o">=</span> <span class="n">System</span><span class="p">(</span><span class="n">t_0</span><span class="o">=</span><span class="n">t_0</span><span class="p">,</span>
<span class="n">t_end</span><span class="o">=</span><span class="n">t_end</span><span class="p">,</span>
<span class="n">p_0</span><span class="o">=</span><span class="n">p_0</span><span class="p">,</span>
<span class="n">alpha_func</span><span class="o">=</span><span class="n">alpha_func</span><span class="p">)</span>
</pre></div>
</div>
</div>
</details>
</div>
<div class="cell tag_hide-cell docutils container">
<details class="hide above-input">
<summary aria-label="Toggle hidden content">
<span class="collapsed">Show code cell content</span>
<span class="expanded">Hide code cell content</span>
</summary>
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="k">def</span> <span class="nf">growth_func_alpha</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">pop</span><span class="p">,</span> <span class="n">system</span><span class="p">):</span>
<span class="k">return</span> <span class="n">system</span><span class="o">.</span><span class="n">alpha_func</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="o">*</span> <span class="n">pop</span>
</pre></div>
</div>
</div>
</details>
</div>
<div class="cell tag_hide-cell docutils container">
<details class="hide above-input">
<summary aria-label="Toggle hidden content">
<span class="collapsed">Show code cell content</span>
<span class="expanded">Hide code cell content</span>
</summary>
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="n">growth_func_alpha</span><span class="p">(</span><span class="n">t_0</span><span class="p">,</span> <span class="n">p_0</span><span class="p">,</span> <span class="n">system</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.06725033332680001
</pre></div>
</div>
</div>
</details>
</div>
<div class="cell tag_hide-cell docutils container">
<details class="hide above-input">
<summary aria-label="Toggle hidden content">
<span class="collapsed">Show code cell content</span>
<span class="expanded">Hide code cell content</span>
</summary>
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="n">results2</span> <span class="o">=</span> <span class="n">run_simulation</span><span class="p">(</span><span class="n">system</span><span class="p">,</span> <span class="n">growth_func_alpha</span><span class="p">);</span>
</pre></div>
</div>
</div>
</details>
</div>
<div class="cell tag_hide-cell docutils container">
<details class="hide above-input">
<summary aria-label="Toggle hidden content">
<span class="collapsed">Show code cell content</span>
<span class="expanded">Hide code cell content</span>
</summary>
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="n">results2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">color</span><span class="o">=</span><span class="s1">'gray'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">'model'</span><span class="p">)</span>
<span class="n">plot_projections</span><span class="p">(</span><span class="n">table3</span><span class="p">)</span>
<span class="n">decorate</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s1">'Proportional model, linearly decreasing rate'</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/0e2a0bf7bf1c3f317307a743f398d2aa9b52777cb86db5394b5a7aec62a2c679.png" src="_images/0e2a0bf7bf1c3f317307a743f398d2aa9b52777cb86db5394b5a7aec62a2c679.png" />
</div>
</details>
</div>
<div class="cell tag_hide-cell docutils container">
<details class="hide above-input">
<summary aria-label="Toggle hidden content">
<span class="collapsed">Show code cell content</span>
<span class="expanded">Hide code cell content</span>
</summary>
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="c1"># By extrapolating the observed decline in growth rate,</span>
<span class="c1"># we generate projections that are similar to the</span>
<span class="c1"># professionals' until about 2050.</span>
<span class="c1"># After that, our model predicts that world population </span>
<span class="c1"># will peak around 2065 at about 9.8 billion, and then </span>
<span class="c1"># start to decline.</span>
</pre></div>
</div>
</div>
</details>
</div>
<div class="cell tag_hide-cell docutils container">
<details class="hide above-input">
<summary aria-label="Toggle hidden content">
<span class="collapsed">Show code cell content</span>
<span class="expanded">Hide code cell content</span>
</summary>
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Solution</span>
<span class="n">results2</span><span class="o">.</span><span class="n">idxmax</span><span class="p">(),</span> <span class="n">results2</span><span class="o">.</span><span class="n">max</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>(2066, 9.75910331482456)
</pre></div>
</div>
</div>
</details>
</div>
</section>
</section>
</section>