🖌️

# Introduction

## What is a Computer simulation?

A computer simulation is the running of a probabilistic models that performs on a computer developed to replicate the characterists of a system through a mathematical model.

The mathematical model's intents imitate the real-world processes focusing on an interesting area, one that is called a system, and the computer simulation’s goal is understanding how it behaves. When we’re getting exact information, we’re obtaining the analytical solution, such models don’t fit with computer simulation. However, when you have a complex system finding an analytical solution is hard o impossible, so you need simulations to find numerical solutions, estimate the system behavior and it shed some light on your research questions.

You ought not to simulate its behavior when you can solve it analytically, it is easier to do the experiments directly, the costs are higher than the budget, or you cannot verify the model. You ought to have a complex system.

As maybe you have noted, we have some crucial concepts, in the one hand a system where we definite it as a collection of entities altogether interact to the accomplishment of some aim where its state is the collection of variables at an instant of time that authors classifies them as discrete and continuous. In another hand, the models are mathematical models that estimate complex systems’ behavior normally queue systems, differential equations, or agents with probabilistic behavior.

## Why does Computer simulation matter to you?

Simulation allows you to find answers in your mathematical model and give you synthetic data for machine learning models.

## Ecosystem

Standards, jobs, industry, roles, …

### Software

Once upon a time when you have to develop in special languages such as Simula or GGPSS, but today you can develop in whatever programming language you like, indeed a spreadsheet is enough to show results. Of course, developers have developed some libraries or systems based on some theory and include interactive animations that you could do easily. Some of those are

• JeLSIM - Java eLearning SIMulations. Jelsim Builder,
• NetLogo and AgentSheets are programmable microworlds allowing all sorts of agent/cells simulations
• Arena
• SIMAN
• OESjs
• Some multi-purpose cognitive/classroom tools like Freestyler do have embedded simulation tools.

Check out other ones on https://en.wikipedia.org/wiki/List_of_computer_simulation_software

SIMSCRIPT

## Simulations Framework

### Components of a system

Discrete and continuous systems.

Model of a system.

Types of models; Discrete-Event System Simulation

## Story

Computer simulation have been started on August 13, 1942, when John V. Neumann and S.Ulam simulates the nuclear weapon behavior in the Manhattan project developing the Monte Carlo method. Nowadays computer simulation serves to understand business, military, and scientific systems.

# Part I. Discrete Event Simulation

“Nothing in Nature is random. A thing appears random only through the incompleteness of our knowledge.” Baruch Spinoza. Ethics.

# Elements of probability on focus simulation

A stochastic process is a collection of random variables that represent the behavior of a system over an indexed monotonic increasing variable $t$﻿. A nondeterministic process doesn’t equal a stochastic process. Stochastic process. Stochastic simulation.

## Random number generator (RNG)

A random number $x$﻿ is realization of a random variable $X$﻿ that is drawn from the distribution of that random variable as described by its probability density function $f_X$﻿. Because it is easier to transform in other distributions, the random variable is distributed according the uniform distribution, i.e. $f_X=U[0,1]$﻿.

Middle-square method

Linear congruential generator

## Generating Discrete Random Variables

Número pseudoaleatorio.

Una variable pseudoaleatoria es aquella generada por una función determinista.

Inverse transform sampling

https://programming.guide/generate-random-value-with-distribution.html

## Methods for sampling distributions

In your simulations, you may encounter situations where certain random distributions are not available in your preferred programming language, library or environment. To address this, you can use methods such as Inverse Transform Sampling and the Box-Muller Transform.

Inverse Transform Sampling is a method for generating random numbers from any probabilistic distribution. given its cumulative distribution function (CDF). For any real random variable $X$﻿ distributed according to a cumulative distribution function $F_X(x)$﻿, the random variable $F_X^{-1}(U)$﻿ has the distribution $F_X(x)$﻿ where $U$﻿ is a uniform random variable on $[0,1]$﻿. Formally, $X\sim F(x) \implies F^{-1}(U)\sim F(x)$﻿ and $U\sim Unif[0,1]$﻿.

• Proof.

Example.

Now, we want to create our random number generator that follows the exponential distribution which is $f(x)=\lambda e^{-\lambda x}.$﻿ Its CDF is $F(x)=1-e^{\lambda x}$﻿, therefore $F^{-1}(x)=-\dfrac{ln(1-x)}{\lambda}$﻿. Now if you introduce a random number that follows a uniform distribution on $[0,1]$﻿, you get a random number generator that follows the exponential distribution.

from random import random

def exponential_random(lamb=2):
u=random()
return -ln(1-u)/lamb

## Monte Carlo methods

Monter Carlo methods is an heuristic algorithm that follows

1. Generate N random inputs.
1. Perform the simulation for each input.y
1. Aggregate the output of the simulation.
for i in random_inputs():
x=agg(simulate(i))
if reaches_the_condition(x):
return (i,x)

Finding $\pi$﻿

n=1000
f=len([_ for _ in range(n) if euclidean([random(),random()]) <= 1])
4*f/l

https://geometrycollective.github.io/monte-carlo/

# The discrete event simulation approach

Introduction

Discrete-Event Simulation

Waiting for lines concepts

Probability distributions

Paradigms are Event worldview, Processing Network Worldview, and Object worldview.

• Queue Network —waiting lines. GPSS and SIMAN/AREA
• Event-Based Simulation paradigm with SIMSCRIPT
• Object-Orientation and the (co-routine-based) Process Interaction paradigm with Simula

JSIM graph

# Part II. Continuous and nonlinear Event Simulation

An introduction to computer simulation. M.M. Woolfson and G.J. Pert

Computer Aided Simulations

# Differential equations

Example

Mechanics

## Types

The Monte Carlo method

Particle methods

Continuum physics — the finite-difference method

Continuum physics

Complex models

Validation and testing

# Cross-Entropy Method

https://web.mit.edu/6.454/www/www_fall_2003/gew/CEtutorial.pdf

# References

[1] Daniel P. Maki Maynard Thompson, Mathematical Modeling and Computer Simulation

[2] W. David Kelton, Randall P. Sadowski, Nancy B. Zupick, Simulation with Arena, 6th edition. (McGraw-Hill Professional, 2014). ISBN 978-0-07-337628-8

[3] Altiok, Tayfur and Benjamin Melamed.Simulation Modeling and Analysis with ARENA. Elsevier, Inc., 2007. ISBN 978-0-12-370523-5

[4] Rossetti, Manuel D. Simulation Modeling with Arena. John Wiley & Sons, Inc., 2010. ISBN 978-0-470-09726-7

[5] Sturrock, D.T., Pegden, C.D., Introduction to SIMAN, Simulation Conference, 1990. Proceedings.,

[6] Winter C. Dennis Pegden, Robert E. Shannon, Randall P. Sadowski, Introduction to Simulation Using Siman, McGraw-Hill 1995

[7] Fishman, G. (2013). Discrete-event simulation: modeling, programming, and analysis. Springer Science & Business Media.

[8] Gordon, G. (1969). System simulation. Ed. PrenticeHall.

[9] Kelton, W. D., & Law, A. M. (2000). Simulation modeling and analysis. Boston: McGraw Hill.

[10] Michael Pidd. Computer Simulation in Management Science

[11] Young, Joseph and Findley, Michael. 2014. "Computational Modeling to Study Conflicts and Terrorism." Routledge Handbook of Research Methods in Military Studies edited by Soeters, Joseph; Shields, Patricia and Rietjens, Sebastiaan. pp. 249–260. New York: Routledge,

[12] R. Frigg and S. Hartmann, Models in Science. Entry in the Stanford Encyclopedia of Philosophy.

[13] E. Winsberg Simulation in Science. Entry in the Stanford Encyclopedia of Philosophy.

[14] S. Hartmann, The World as a Process: Simulations in the Natural and Social Sciences, in: R. Hegselmann et al. (eds.), Modelling and Simulation in the Social Sciences from the Philosophy of Science Point of View, Theory and Decision Library. Dordrecht: Kluwer 1996, 77–100.

[15] E. Winsberg, Science in the Age of Computer Simulation. Chicago: University of Chicago Press, 2010.

[16] P. Humphreys, Extending Ourselves: Computational Science, Empiricism, and Scientific Method. Oxford: Oxford University Press, 2004.

[17] James J. Nutaro (2011). Building Software for Simulation: Theory and Algorithms, with Applications in C++. John Wiley & Sons. ISBN 978-1-118-09945-2.

[18] Desa, W. L. H. M., Kamaruddin, S., & Nawawi, M. K. M. (2012).

[20] Nature in Code Biology in Javascript - Learning programming while discovering the rules that govern life by Marcel Salathe

Modeling of Aircraft Composite Parts Using Simulation. Advanced Material Research, 591–593, 557–560.

"Simulation Modeling and Analysis" by Law. Other fine choices include "Discrete-Event System Simulation" by Banks, Carson, & Nelson, "Principles of Discrete-Event Simulation" by Fishman, "Discrete-Event Simulation: A First Course" by Leemis & Park, or "Graphical Simulation Modeling and Analysis Using SIGMA for Windows" by Schruben

Winter Simulation Conference Archive
,
pick any year, and check out the articles in either the introductory or
advanced tutorials. I'd particularly recommend Schriber's
Inside Discrete-Event Simulation Software: How It Works and Why It Matters
series, and
Fundamentals of Simulation Modeling
by Sanchez.

"Discrete-Event System Simulation" by Banks, Carson, Nelson & Nicol
and "Simulation Modeling and Analysis" by Law & Kelton to be most
'Simulation' by Ross
is another very useful resource.

Simulation modeling and analysis by Averill M. Law

https://hrms.secab.org/resource/450_15CS834_SMS_SIETNotes_NEW.pdf

BANKS J., J. S. Carson and B. L. Nelson 1996. Discrete-Event System Simulation,

second edition. Prentice-Hall, Englewood Cliffs, NJ.

GORDON G. 1996. System Simulation, second edition. Prentice-Hall, Englewood Cliffs,

NJ.

LAW A. and W. D. Kelton 1991. Simulation Modeling and Analysis, second edition.

McGraw-Hill, New York, NY.

SCHRUBEN L. W. 1983. Simulation modeling with event graphs. Communications of

the ACM, 26:957-963

https://pascua.iit.comillas.edu/aramos/simio/transpa/s_Simulation_reduced_final.pdf

"* Simulations | AP CSP | Khan Academy." 2 Mar. 2023, www.khanacademy.org/computing/ap-computer-science-principles/x2d2f703b37b450a3:simulations.

Collaboration., Dylan Nelson for the Tng. "IllustrisTNG - Main." 2 Mar. 2023, www.tng-project.org.

https://github.com/USC-Marshall-DSO/tutorials/blob/main/Monte Carlo Simulations/Slides/Simulation Studies.pdf

Hands-On Simulation Modeling with Python - Second Edition by Giuseppe Ciaburro

Modeling and Simulation in Python by Allen B. Downey

Introduction to Modeling and Simulation by Mark W. Spong