Slide 1 of 2
UNFORMATTED ATTACHMENT PREVIEW
Assignment (Total of 20 points) • Single spaced, 12-point or larger font size; 1-inch margins • Use headers and/or bullets to organize and convey key elements, and page numbers • Only Latin alphabet characters are allowed (i.e., do not include any words or phrases that contain non-English characters) • Comment all the codes provided and answer the questions in the document as needed • All the codes provided part should be in one .py file • There is no minimum and maximum number of words for each question, but your answers need to be comprehensive and address the question. 1 2 – 3 4 Hands-On Simulation Modeling with Python Develop simulation models to get accurate results and enhance decision-making processes Giuseppe Ciaburro BIRMINGHAM—MUMBAI Hands-On Simulation Modeling with Python Copyright © 2020 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Commissioning Editor: Sunith Shetty Acquisition Editor: Devika Battike Senior Editor: David Sugarman Content Development Editor: Joseph Sunil Technical Editor: Sonam Pandey Copy Editor: Safis Editing Project Coordinator: Aishwarya Mohan Proofreader: Safis Editing Indexer: Manju Arasan Production Designer: Joshua Misquitta First published: July 2020 Production reference: 1160720 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-83898-509-7 www.packt.com Packt.com Subscribe to our online digital library for full access to over 7,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website. Why subscribe? • Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals • Improve your learning with Skill Plans built especially for you • Get a free eBook or video every month • Fully searchable for easy access to vital information • Copy and paste, print, and bookmark content Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at firstname.lastname@example.org for more details. At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. Contributors About the author Giuseppe Ciaburro holds a PhD in environmental technical physics, along with two master’s degrees. His research was focused on machine learning applications in the study of urban sound environments. He works at the Built Environment Control Laboratory at the Università degli Studi della Campania Luigi Vanvitelli, Italy. He has over 18 years’ professional experience in programming (Python, R, and MATLAB), first in the field of combustion, and then in acoustics and noise control. He has several publications to his credit. About the reviewers Greg Walters has been involved with computers and computer programming since 1972. He is well versed in Visual Basic, Visual Basic.NET, Python, and SQL, and is an accomplished user of MySQL, SQLite, Microsoft SQL Server, Oracle, C++, Delphi, Modula-2, Pascal, C, 80×86 Assembler, COBOL, and Fortran. He is a programming trainer and has trained numerous individuals in many pieces of computer software, including MySQL, Open Database Connectivity, Quattro Pro, Corel Draw!, Paradox, Microsoft Word, Excel, DOS, Windows 3.11, Windows for Workgroups, Windows 95, Windows NT, Windows 2000, Windows XP, and Linux. He is currently retired and, in his spare time, is a musician and loves to cook. He is also open to working as a freelancer on various projects. Yoon Hyup Hwang is a seasoned data scientist in the marketing and finance industries and is the author of two applied machine learning books. He has almost a decade of experience building numerous machine learning models and data science products. He holds an M.S.E. in Computer and Information Technology from the University of Pennsylvania and a B.A. in Economics from the University of Chicago. He enjoys training various martial arts, snowboarding, and roasting coffee. He currently lives in the Greater New York Area with his artist wife, Sunyoung, and a playful dog, Dali (named after Salvador Dali). Packt is searching for authors like you If you’re interested in becoming an author for Packt, please visit authors. packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Table of Contents Preface Section 1: Getting Started with Numerical Simulation 1 Introducing Simulation Models Introducing simulation models 4 Decision-making workflow Comparing modeling and simulation Pros and cons of simulation modeling Simulation modeling terminology 5 6 6 7 Classifying simulation models 9 Comparing static and dynamic models 9 Comparing deterministic and stochastic models 9 Comparing continuous and discrete models10 Approaching a simulationbased problem 10 Problem analysis Data collection Setting up the simulation model Simulation software selection Verification of the software solution Validation of the simulation model Simulation and analysis of results 11 11 11 13 14 15 16 Dynamical systems modeling 16 Managing workshop machinery Simple harmonic oscillator Predator-prey model 17 18 20 Summary22 2 Understanding Randomness and Random Numbers Technical requirements Stochastic processes 24 24 Types of stochastic process 25 Examples of stochastic processes The Bernoulli process Random walk 26 26 27 The Poisson process 29 Random number simulation 30 Probability distribution Properties of random numbers 31 32 The pseudorandom number generator33 The pros and cons of a random number generator 33 Random number generation algorithms 34 Linear congruential generator 34 Random numbers with uniform distribution37 Lagged Fibonacci generator 39 Testing uniform distribution 42 The chi-squared test Uniformity test 42 45 Exploring generic methods for random distributions 51 The inverse transform sampling method 51 The acceptance-rejection method 52 Random number generation using Python 53 Introducing the random module The random.random() function The random.seed() function The random.uniform() function The random.randint() function The random.choice() function The random.sample() function Generating real-valued distributions 54 54 55 56 56 57 58 58 Summary 59 3 Probability and Data Generation Processes Technical requirements 62 Explaining probability concepts 62 Exploring probability distributions69 Understanding Bayes’ theorem 66 Probability density function Mean and variance Uniform distribution Binomial distribution Normal distribution Compound probability Bayes’ theorem Summary83 Types of events Calculating probability Probability definition with an example 62 63 63 66 68 Section 2: Simulation Modeling Algorithms and Techniques 70 71 72 76 79 4 Exploring Monte Carlo Simulations Technical requirements 88 Introducing Monte Carlo simulation88 Monte Carlo components First Monte Carlo application Monte Carlo applications Applying the Monte Carlo method for Pi estimation 89 89 90 91 Understanding the central limit theorem96 Law of large numbers Central limit theorem 96 97 simulation101 Generating probability distributions Numerical optimization Project management Performing numerical integration using Monte Carlo Defining the problem Numerical solution Min-max detection Monte Carlo method Visual representation 101 102 103 104 104 106 108 109 111 Summary113 Applying Monte Carlo 5 Simulation-Based Markov Decision Processes Technical requirements 116 Overview of Markov processes 116 The Bellman equation explained138 The agent-environment interface Exploring MDPs Understanding the discounted cumulative reward Comparing exploration and exploitation concepts 117 119 Multi-agent simulation 140 Summary142 Introducing Markov chains 124 Transition matrix Transition diagram Markov chain applications 122 123 125 126 127 Introducing random walks 127 Simulating a one-dimensional random walk129 Simulating a weather forecast 132 Dynamic programming concepts Principle of optimality The Bellman equation 139 139 140 6 Resampling Methods Technical requirements Introducing resampling methods Sampling concepts overview Reasoning about sampling Pros and cons of sampling Probability sampling How sampling works 144 144 145 146 146 147 147 Exploring the Jackknife technique148 Defining the Jackknife method 148 Estimating the coefficient of variation 150 Applying Jackknife resampling using Python 151 Demystifying bootstrapping 156 Introducing bootstrapping Bootstrap definition problem Bootstrap resampling using Python Comparing Jackknife and bootstrap 156 157 158 161 Explaining permutation tests 162 Approaching cross-validation techniques163 The validation set approach Leave-one-out cross validation K-fold cross validation Cross-validation using Python 163 164 165 165 Summary168 7 Using Simulation to Improve and Optimize Systems Technical requirements Introducing numerical optimization techniques 170 170 Defining an optimization problem 171 Explaining local optimality 173 Defining the descent methods 174 Approaching the gradient descent algorithm174 Understanding the learning rate 177 Explaining the trial and error method 178 Implementing gradient descent in Python178 Facing the Newton-Raphson method183 Using the Newton-Raphson algorithm for root-finding 183 Approaching Newton-Raphson for numerical optimization Applying the Newton-Raphson technique 184 185 Deepening our knowledge of stochastic gradient descent 189 Discovering the multivariate optimization methods in Python191 The Nelder–Mead method 191 Powell’s conjugate direction algorithm 195 Summarizing other optimization methodologies197 Summary198 Section 3: Real-World Applications 8 Using Simulation Models for Financial Engineering Technical requirements Understanding the geometric Brownian motion model 202 202 Defining a standard Brownian motion 203 Addressing the Wiener process as random walk 204 Implementing a standard Brownian motion 205 Handling the stock price trend as time series213 Introducing the Black-Scholes model 215 Applying Monte Carlo simulation 216 Studying risk models for portfolio management 220 Using Monte Carlo methods for stock price prediction 207 Using variance as a risk measure 221 Introducing the value-at-risk metric 221 Estimating the VaR for some NASDAQ assets223 Exploring the Amazon stock price trend 208 Summary232 9 Simulating Physical Phenomena Using Neural Networks Technical requirements 234 Introducing the basics of neural networks 234 Understanding biological neural networks Exploring ANNs Splitting the data 256 Explaining multiple linear regression 258 Understanding a multilayer perceptron regressor model 260 235 236 Exploring deep neural networks264 Understanding feedforward neural networks 242 Exploring neural network training 243 264 265 266 Getting familiar with convolutional neural networks Examining recurrent neural networks Analyzing LSTM networks Summary267 Simulating airfoil self-noise using ANNs 244 Importing data using pandas Scaling the data using sklearn Viewing the data using matplotlib 246 249 252 10 Modeling and Simulation for Project Management Technical requirements 270 Introducing project management270 Addressing management problems using MDPtoolbox Changing the probability of fire 278 282 Understanding what-if analysis Scheduling project time using Monte Carlo simulation 284 271 Managing a tiny forest problem272 Summarizing the Markov decision process272 Exploring the optimization process 273 Introducing MDPtoolbox 275 Defining the tiny forest management example 275 Defining the scheduling grid 285 Estimating the task’s time 286 Developing an algorithm for project scheduling287 Exploring triangular distribution 288 Summary294 11 What’s Next? Summarizing simulation modeling concepts 295 Generating random numbers 296 Applying Monte Carlo methods 298 Addressing the Markov decision process299 Analyzing resampling methods 300 Exploring numerical optimization techniques302 Using artificial neural networks for simulation303 Applying simulation model to real life 304 Other Books You May Enjoy Leave a review – let other readers know what you think 317 Modeling in healthcare Modeling in financial applications Modeling physical phenomenon Modeling public transportation Modeling human behavior 304 305 306 307 308 Next steps for simulation modeling309 Increasing the computational power 309 Machine learning-based models 311 Automated generation of simulation models312 Summary313 Preface Simulation modeling helps you to create digital prototypes of physical models to analyze how they work and predict their performance in the real world. With this comprehensive guide, you’ll learn about various computational statistical simulations using Python. Starting with the fundamentals of simulation modeling, you’ll learn about concepts such as randomness and explore data generating processes, resampling methods, and bootstrapping techniques. You’ll then cover key algorithms such as Monte Carlo simulations and the Markov Decision Process, which are used to develop numerical simulation models, and discover how they can be used to solve real-world problems. As you make progress, you’ll develop simulation models to help you get accurate results and enhance decision-making processes. Using optimization techniques, you’ll learn to modify the performance of a model to improve results and make optimal use of resources. The book will guide you through creating a digital prototype using practical use cases for financial engineering, prototyping project management to improve planning, and simulating physical phenomena using neural networks. By the end of this book, you’ll be able to construct and deploy simulation models of your own to solve real-world challenges. Who this book is for Hands-On Simulation Modeling with Python is for simulation developers and engineers, model designers, and anyone already familiar with the basic computational methods that are used to study the behavior of systems. This book will help you explore advanced simulation techniques such as Monte Carlo methods, statistical simulations, and much more using Python. Working knowledge of the Python programming language is required. What this book covers Chapter 1, Introduction, analyzes the basics of numerical simulation and highlights the difference between modeling and simulation and the strengths of simulation models such as defects. The different types of models are analyzed, and we study practical modeling cases to understand how to elaborate a model starting from the initial considerations. viii Preface Chapter 2, Understanding Randomness and Random Numbers, defines stochastic processes and explains the importance of using them to address numerous real-world problems. The main methods for generating random numbers with practical examples in Python code, and the generation of uniform and generic distributions, are both explored. It also explains how to perform a uniformity test using the chi-square method. Chapter 3, Probability and the Data Generating Process, shows how to distinguish between the different definitions of probabilities and how they can be integrated to obtain useful information in the simulation of real phenomena. Chapter 4, Monte Carlo Simulations, explores techniques based on Monte Carlo methods for process simulation. We will first learn the basic concepts, and then we will see how to apply them to practical cases. Chapter 5, Simulation-Based Markov Decision Process, shows how to deal with decisionmaking processes with Markov chains. We will analyze the concepts underlying Markovian processes and then analyze some practical applications to learn how to choose the right actions for the transition between different states of the system. Chapter 6, Resampling Methods, shows how to apply resampling methods to approximate some characteristics of the distribution of a sample in order to validate a statistical model. We will analyze the basics of the most common resampling methods and learn how to use them by solving some practical problems. Chapter 7, Use of Simulation to Improve and Optimize Systems, shows how to use the main optimization techniques to improve the performance of our simulation models. We will see how to use the gradient descent technique, the Newton-Raphson method, and stochastic gradient descent. We will also see how to apply these techniques with practical examples. Chapter 8, Simulation Models for Financial Engineering, shows practical cases of using simulation methods in a financial context. We will learn how to use Monte Carlo methods to predict stock prices and how to assess the risk associated with a portfolio of shares. Chapter 9, Simulating Physical Phenomena with Neural Networks, shows how to develop models based on artificial neural networks to simulate physical phenomena. We will start by exploring the basic concepts of neural networks, and we will examine their architecture and its main elements. We will see how to train a network to update its weights. Preface ix Chapter 10, Modeling and Simulation for Project Management, deals with practical cases of project management using the tools we learned how to use in the previous chapters. We will see how to evaluate in advance the results of the actions undertaken in the management of a forest using Markov processes, and then move on to evaluating the time required for the execution of a project using the Monte Carlo simulation. Chapter 11, What’s Next?, provides a better understanding of the problems associated with building and deploying simulation models and additional resources and technologies to learn how to hone your machine learning skills. To get the most out of this book Working knowledge of Python programming language is required. If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code. Download the example code files You can download the example code files for this book from your account at www. packt…
Do you similar assignment and would want someone to complete it for you? Click on the ORDER NOW option to get instant services at essayloop.com
Do you have a similar assignment and would want someone to complete it for you? Click on the ORDER NOW option to get instant services at essayloop.com. We assure you of a well written and plagiarism free papers delivered within your specified deadline.