Think Complexity Version 2.6.2 Think Complexity Version 2.6.2 Allen B. Downey Green Tea Press Needham, Massachusetts Copyright © 2016 Allen B. Downey. Green Tea Press 9 Washburn Ave Needham MA 02492 Permission is granted to copy, distribute, transmit and adapt this work under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License: https://thinkcomplex.com/license. If you are interested in distributing a commercial version of this work, please contact the author. The LATEX source for this book is available from https://github.com/AllenDowney/ThinkComplexity2 iv Contents Preface xi 0.1 Who is this book for?...................... xii 0.2 Changes from the first edition................. xiii 0.3 Using the code.......................... xiii 1 Complexity Science1 1.1 The changing criteria of science................3 1.2 The axes of scientific models..................4 1.3 Different models for different purposes............6 1.4 Complexity engineering.....................7 1.5 Complexity thinking......................8 2 Graphs 11 2.1 What is a graph?........................ 11 2.2 NetworkX............................ 13 2.3 Random graphs......................... 16 2.4 Generating graphs........................ 17 2.5 Connected graphs........................ 18 2.6 Generating ER graphs..................... 20 2.7 Probability of connectivity................... 22 vi CONTENTS 2.8 Analysis of graph algorithms.................. 24 2.9 Exercises............................. 25 3 Small World Graphs 27 3.1 Stanley Milgram......................... 27 3.2 Watts and Strogatz....................... 28 3.3 Ring lattice........................... 30 3.4 WS graphs............................ 32 3.5 Clustering............................ 33 3.6 Shortest path lengths...................... 35 3.7 The WS experiment....................... 36 3.8 What kind of explanation is that?............... 38 3.9 Breadth-First Search...................... 39 3.10 Dijkstra's algorithm....................... 41 3.11 Exercises............................. 43 4 Scale-free networks 47 4.1 Social network data....................... 47 4.2 WS Model............................ 50 4.3 Degree.............................. 51 4.4 Heavy-tailed distributions................... 53 4.5 Barab´asi-Albert model..................... 55 4.6 Generating BA graphs..................... 57 4.7 Cumulative distributions.................... 59 4.8 Explanatory models....................... 62 4.9 Exercises............................. 63 CONTENTS vii 5 Cellular Automatons 67 5.1 A simple CA........................... 67 5.2 Wolfram's experiment...................... 68 5.3 Classifying CAs......................... 69 5.4 Randomness........................... 71 5.5 Determinism........................... 72 5.6 Spaceships............................ 73 5.7 Universality........................... 76 5.8 Falsifiability........................... 77 5.9 What is this a model of?.................... 78 5.10 Implementing CAs....................... 81 5.11 Cross-correlation........................ 82 5.12 CA tables............................ 85 5.13 Exercises............................. 86 6 Game of Life 89 6.1 Conway's GoL.......................... 89 6.2 Life patterns........................... 92 6.3 Conway's conjecture...................... 92 6.4 Realism............................. 94 6.5 Instrumentalism......................... 95 6.6 Implementing Life........................ 97 6.7 Exercises............................. 99 7 Physical modeling 103 7.1 Diffusion............................. 103 7.2 Reaction-diffusion........................ 105 viii CONTENTS 7.3 Percolation............................ 109 7.4 Phase change.......................... 110 7.5 Fractals............................. 113 7.6 Fractals and Percolation Models................ 115 7.7 Exercises............................. 116 8 Self-organized criticality 119 8.1 Critical Systems......................... 119 8.2 Sand Piles............................ 120 8.3 Implementing the Sand Pile.................. 121 8.4 Heavy-tailed distributions................... 125 8.5 Fractals............................. 127 8.6 Pink noise............................ 131 8.7 The sound of sand........................ 132 8.8 Reductionism and Holism................... 134 8.9 SOC, causation, and prediction................ 137 8.10 Exercises............................. 138 9 Agent-based models 141 9.1 Schelling's Model........................ 142 9.2 Implementation of Schelling's model.............. 143 9.3 Segregation........................... 145 9.4 Sugarscape............................ 147 9.5 Wealth inequality........................ 150 9.6 Implementing Sugarscape.................... 151 9.7 Migration and Wave Behavior................. 154 9.8 Emergence............................ 155 CONTENTS ix 9.9 Exercises............................. 157 10 Herds, Flocks, and Traffic Jams 159 10.1 Traffic jams........................... 159 10.2 Random perturbation...................... 163 10.3 Boids............................... 164 10.4 The Boid algorithm....................... 165 10.5 Arbitration........................... 168 10.6 Emergence and free will.................... 169 10.7 Exercises............................. 171 11 Evolution 173 11.1 Simulating evolution...................... 174 11.2 Fitness landscape........................ 175 11.3 Agents.............................. 176 11.4 Simulation............................ 177 11.5 No differentiation........................ 178 11.6 Evidence of evolution...................... 179 11.7 Differential survival....................... 182 11.8 Mutation............................. 183 11.9 Speciation............................ 186 11.10 Summary............................ 189 11.11 Exercises............................. 190 12 Evolution of cooperation 191 12.1 Prisoner's Dilemma....................... 192 12.2 The problem of nice....................... 193 x CONTENTS 12.3 Prisoner's dilemma tournaments................ 195 12.4 Simulating evolution of cooperation.............. 196 12.5 The Tournament........................ 198 12.6 The Simulation......................... 200 12.7 Results.............................. 202 12.8 Conclusions........................... 205 12.9 Exercises............................. 207 A Reading list 209 Preface Complexity science is an interdisciplinary field | at the intersection of math- ematics, computer science and natural science | that focuses on complex systems, which are systems with many interacting components. One of the core tools of complexity science is discrete models, including net- works and graphs, cellular automatons, and agent-based simulations. These tools are useful in the natural and social sciences, and sometimes in arts and humanities. For an overview of complexity science, see https://thinkcomplex.com/complex. Why should you learn about complexity science? Here are a few reasons: Complexity science is useful, especially for explaining why natural and social systems behave the way they do. Since Newton, math-based physics has focused on systems with small numbers of components and simple interactions. These models are effective for some applications, like celestial mechanics, and less useful for others, like economics. Com- plexity science provides a diverse and adaptable modeling toolkit. Many of the central results of complexity science are surprising; a recur- ring theme of this book is that simple models can produce complicated behavior, with the corollary that we can sometimes explain complicated behavior in the real world using simple models. As I explain in Chapter1, complexity science is at the center of a slow shift in the practice of science and a change in what we consider science to be. xii Chapter 0 Preface Studying complexity science provides an opportunity to learn about di- verse physical and social systems, to develop and apply programming skills, and to think about fundamental questions in the philosophy of science. By reading this book and working on the exercises you will have a chance to explore topics and ideas you might not encounter otherwise, practice program- ming in Python, and learn more about data structures and algorithms. Features of this book include: Technical details Most books about complexity science are written for a popular audience. They leave out technical details, which is frustrating for people who can handle them. This book presents the code, the math, and the explanations you need to understand how the models work. Further reading Throughout the book, I include pointers to further reading, including original papers (most of which are available electronically) and related articles from Wikipedia and other sources. Jupyter notebooks For each chapter I provide a Jupyter notebook that in- cludes the code from the chapter, additional examples, and animations that let you see the models in action. Exercises and solutions At the end of each chapter I suggest exercises you might want to work on, with solutions. For most of the links in this book I use URL redirection. This mechanism has the drawback of hiding the link destination, but it makes the URLs shorter and less obtrusive. Also, and more importantly, it allows me to update the links without updating the book. If you find a broken link, please let me know and I will change the redirection. 0.1 Who is this book for? The examples and supporting code for this book are in Python. You should know core Python and be familiar with
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages228 Page
-
File Size-