We will cover several areas within system modeling and simulation. It is meant as a short introduction to key areas within each topics like ODE, system modeling, simulation, random number generation and more.

## Ordinary Differential Equations

Numerical means there is only one answer and by integrated numerically we approximate the solution by using step size in e.g. Euler’s method that’s a first-order method. The reason for using Euler’s method is to lower the computation cost and time significantly. The step size introduce the local truncation error which is apply for each calculated step. The smaller the step size the smaller the error but we get a better result.

The stability can be described by the development of the global error. The system is stiff if the stability demands a small step size. The Initial Value Problem is the method of finding the function given a specific point. (Example: dy = 6x – 3 with y(0) = 4). A steady state is when e.g. a skydiver reaches max velocity. Chaotic behavior is characterize by being very sensitive to the initial conditions, like an asteroid flouting in space. Periodic behavior could be a sinus or cosines with their constant swings.

## Random Number Generation

Random number can be generated by rolling a die. To do that on a computer we generated it by using the LCG (Linear Congruential Generator). (x(2) = (ax(1) + b) % m.). The properties for such a generator should be independence from the rest, uniformity by having the same probability, replicability generating the same result with the same input, it should be fast, portable and have a long cycle.

A sequence of computer generated random numbers should be uniformly distributed (0..1) and independent. The properties can be tested by rejecting their null hypothesis that proposes that there is no difference between data generating. The frequency tests test for uniformity. A longer sequence can be obtained by using the combined LCG. To generate random numbers of any distribution we’ll need a RNG and a CDF that describes the desired distribution. Then we can generate the numbers and compute the derivative.

## Random Variables

RV takes take on values at random e.g. service time at a bank. Randomness can usually be described by using probability distribution. We have the main probability distribution PDF that shows the probability of each x values occurring. The cumulative CDF adds up the area beneath the PDF. The CDF is monotonic, means that it can never go down on the y axes and it will go between 0 and 1. We have several common distribution like Uniform (RNG when only min and max information is available), Exponential distribution – Independent arrivals, Normal distribution – Shooting at a target, Triangular distribution – only min, max and most common values are known, Weibull distribution – Life time of components, Lognormal distribution – Household incomes.

A normal distribution with a large variance will produce a wider graph, and a small variance will produce a high and narrow graph. The Weibull distribution will produce with a beta smaller than 1 a infant mortality similar to exponential distribution. If beta is 1 its memoryless and will be more flat than exponential distribution and beta higher than 1 will produce a normal distribution. The unique property of an exponential distribution is its memoryless, meaning the remaining life is independent from its current age.

## General simulation

The two principles of conceptual model is abstraction and idealization. Abstracting will simplify the real world which leaves out the unnecessary details like asteroids in a solar system model and idealization means replacing real things by concepts like replacing the planet with its center of gravity. The stages of a simulation project consist of the following steps. Problem formulation, set objectives, conceptual model, collect data, create simulation model, verification, experimental design, production runs and analysis and finally documentation and report.

The state of a system is a collection of variables necessary to describe a system at any time relative to the objective of the study. Description of all the entities, attributes and activities as they exist at one point in time. A state variable can be an entity, attribute and activity. A discrete-event simulation works by the state variable only changes at a discrete set of point in time, like at a bank where it’s only change when a customer arrive. A future event list controls the simulation, it contains all the future event that are scheduled and contains only primary events which are will instantaneous occur that may change the state of the system. Where a secondary event is a condition event like a customer moving from queue to service.

An attribute is a state variable and a relevant property of the entity, could be an account balance. An entity is an object of interest in the system like the customer. A System contains all the relevant event, attributes and entities. An activity is duration of a known length like serving the customer. Delay is the unknown waiting time in queue. The state is the collection of all variables necessary to describe the system at any time. The boundary is the physical and logical boundaries of the system like the solar system.

## Input Modeling

The four steps of input data is collecting data which can be a lot of work and can be error-prone, guess a distribution type of the data using histogram and QQ-plot, find the specific parameters for the distribution by using the mean and sample variance, and finally check the quality of the distribution obtained. The QQ-plot test whether the type of distribution is correct. First rank the data (1..n), then sort low to high and plot it against z-score. The QQ-plot reveals which distribution fits the data, if the graph yields a straight line that has a slope of 1 and goes through the origin.

We obtain parameters by finding the sample mean and sample variance. The chi-square test is used to compare two sets of data. The Kolmogorov-Smirnoff test compare the predicted data and the actual data by taking the distance between the two furthest positions in the sets. The distance D value can be compared to the P value to see if we can reject the null hypothesis or not.

## Output Analysis

Confidence interval measure uncertainties in a sample variable. It’s the interval which we are confident the result is in. The more test run we do the narrower the confidence interval will be. If we wish to halve the width of the interval we must run 4*n as many samples. The method of independent replications consist of running the simulation n times, use a set of independent random numbers, make observations, computer hat Thema, Sample variance and Y, finally compute a confidence interval from hat Theta to sample variance squared. The interval can be reduced by improving the accuracy.

## Stochastic Petri Nets

The SPN are a graphical modelling tool, it’s easy to understand, flexible and powerful. They are used as conceptual models in e.g. traffic and logistics. There are several components in use. The Tokens are called marking and can represent a customer. Places represent a location as a circle. Transitions are timed or immediate activities and is used to destroy and create tokens. It can fire if it is enabled.

Input arcs join places to transitions as an arrow and can determine the numbers of tokens created by firing. Output arcs join transitions to places with arrow. Inhibitor Arcs joins places to transitions drawn as line with circle at the end, it disable the transition when enough tokens are in place. The Guard function are assigned to transitions and map markings to Boolean values.

## Verification & Validation

Verification is the simulation program and validation is the model that represent real life. Verification compare the conceptual model with its implementation by building the model right. We use it between the conceptual model and the simulation program. Validation compare the real system to the conceptual model by building the right model. We use it between simulation program and the real system. The purpose of model verification is to assure that the conceptual model reflect accurately in the operation model.

The conceptual model often involves some degree of abstraction about system operations. The goals of validation can be multiple things, model depends on the goal of the project, different goals can lead to different models, a model can be valid for one goal but not for another. First thing first is to decide what the goal of the project is. There different approaches to validate a simulation mode. Two-steps validation include developer a model with high face validity and then determine the quality of the simulation output.

## Comparing Systems

The difference between a statistical and practical significance: statistical checks if our simulation experiment is good enough or are we just seeing the result of randomness. Practical approach checks the difference in performance is significant with respect to our goals. To compare two simulations models you would perform replications and then compute the averages and define a confidence interval around them. Correlated sampling is a variance reduction and it’s used to improve the confidence intervals, but it’s difficult to implement but can be very effective. The variance reduction will increase the precision of the estimates that can be obtained for a given simulation.

## General system modeling and simulation

The mean (my) is the average of a data set. The sample variance (sigma) is used to calculate how varied a sample is. The variance helps you to figure out how spread out our data set is. The null hypothesis proposes that there is no difference between certain characteristics of a data generating process. We use it to determine whether something might be wrong or not. Is the data within a statistically significant interval. If it is then the null hypothesis holds. If not, then we reject it, however that doesn’t tell us what’s going on, only that we need more testing.