0% found this document useful (0 votes)
9 views5 pages

Sample Space Simulation in Vensim

The document explains the concept of sample space in probability, providing examples of outcomes for tossing a coin and throwing a die. It details a step-by-step guide for simulating these random experiments using Vensim, including defining variables, creating constants, and graphing outputs. Additionally, it covers setting up a Linear Congruential Generator (LCG) simulation, outlining the necessary constants and equations for generating pseudo-random numbers.

Uploaded by

wolakon9
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

Sample Space Simulation in Vensim

The document explains the concept of sample space in probability, providing examples of outcomes for tossing a coin and throwing a die. It details a step-by-step guide for simulating these random experiments using Vensim, including defining variables, creating constants, and graphing outputs. Additionally, it covers setting up a Linear Congruential Generator (LCG) simulation, outlining the necessary constants and equations for generating pseudo-random numbers.

Uploaded by

wolakon9
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Label 1: Sample Space-can be defined as the set of all possible outcomes that result from

conducting a random experiment and is denoted by S.

Example: A.) If a die is thrown, sample space is S = {1, 2, 3, 4, 5, 6) . This consists of six
outcomes 1, 2, 3, 4, 5, 6.

B.) The sample space for tossing a fair coin is {heads, tails.

A simulation of the sample spaces for:

• Tossing a fair coin (Heads or Tails)

• Throwing a die (1 through 6)

Each experiment was run 1,000 times, and the frequencies of each outcome were
recorded and visualized:

This graph shows how often each outcome occurred, helping you understand the
distribution of results in random experiments.

To set up a sample space simulation in Vensim, you can follow these steps. Vensim is
typically used for system dynamics modeling, so we’ll simulate the logic of random
experiments (like tossing a coin or rolling a die) using discrete event modeling concepts.

Step-by-Step Setup in Vensim of Lab 1

1. Define Variables
• Coin Toss Outcome: A variable that randomly switches between "Heads" and
"Tails".

• Die Roll Outcome: A variable that randomly switches between 1 to 6.

2. Create Constants

• CoinSampleSpace = {"Heads", "Tails"}

• DieSampleSpace = {1, 2, 3, 4, 5, 6}

• Trials = 1000 (number of simulations)

3. Use Random Functions

Vensim doesn’t directly support string outputs, so you simulate outcomes numerically:

• Coin Toss:

• CoinOutcome = IF THEN ELSE(RANDOM UNIFORM(0,1) < 0.5, 1, 2)

o Map 1 → Heads, 2 → Tails

• Die Roll:

• DieOutcome = RANDOM INTEGER(1, 6)

4. Create Accumulators

Use level variables to count outcomes:

• HeadsCount, TailsCount

• Die1Count, Die2Count, …, Die6Count

Each update based on the outcome per time step.

5. Set Time Parameters

• INITIAL TIME = 0

• FINAL TIME = Trials

• TIME STEP = 1

6. Graph Outputs

Use Vensim’s graph tool to visualize:

• Frequency of Heads vs Tails


• Frequency of each die face (1–6)

Lab 2: LCG

Note: In Vensim PLE, you might need to simulate using subscripts or lookup tables to
represent categories like "Heads" and "Tails".

Here's the simulation of a Linear Congruential Generator (LCG) using the parameters:

• Multiplier (a) = 1664525

• Increment (c) = 1013904223

• Modulus (m) = (2^{32})

• Seed (X₀) = 42

• Iterations = 1000

The output values were normalized to the range [0, 1] for visualization. This is the plot
showing the pseudo-random sequence:
This plot helps illustrate the behavior of the LCG. While the values appear random, LCGs
can exhibit periodicity and correlation over longer sequences, especially in higher
dimensions.

To set up a Linear Congruential Generator (LCG) simulation in Vensim, you can follow
these steps to model the iterative formula:

Step-by-Step Setup in Vensim

1. Define Constants

Create constants for the LCG parameters:

• a = 1664525

• c = 1013904223

• m = 4294967296 (which is (2^{32}))

• X0 = 42 (initial seed)

You can define these as constants in Vensim using the equation editor.

2. Create a Stock Variable

Create a stock variable called X to represent the current pseudo-random number.

• Initial value: X0
• Equation:

X = MODULO(a * X(-1) + c, m)

This uses the previous value of X to compute the next one.

Note: Vensim uses MODULO(x, y) for modulus operation.

3. Create an Auxiliary Variable for Normalization

To visualize the output in the range [0, 1], create an auxiliary variable:

Normalized X = X / m

4. Set Simulation Time

• Initial Time: 0

• Final Time: 1000 (or however many iterations you want)

• Time Step: 1

5. Graph the Output

Use the Graph Tool to plot Normalized X over time to observe the pseudo-random
behavior.

You might also like