Skip to main content

Section 3.15 Models and Simulations (2026)

45 minutes
In this lesson, we will review the concept of simulations and how they are used in computer science.
A model is a simplified representation of a real-world object or system. Models can be physical, like a scale model of a building, or they can be digital, like a computer simulation of a weather system. Models are used to study and understand complex systems by focusing on the most important aspects while ignoring less relevant details.
Simulations are a way to model real-world processes or systems using computer programs. They allow us to study complex systems and predict their behavior under different conditions. They often involve randomness and can be used to test hypotheses, optimize processes, or understand the impact of different variables.
Simulations are a form of abstraction, where we focus on the most important aspects of a system while ignoring less relevant details. This allows us to create models that are easier to analyze and understand.

Subsection 3.15.1 Solar System Models

Models and simulations are most useful when real-world events are impractical for experiments (e.g., too big, too small, too fast, too slow, too expensive, or too dangerous). Watch the following videos, paying particular attention to the different ways in which the models abstract away certain details from the real world situations that are being modeled. Discuss with your classmates which features of the solar system each model chose to include and to exclude. How do those choices align with the educational goals of each model?
Bill Nye’s Model
Bill Nye illustrates the problem of trying to build a scale model of the solar system by using his bicycle to demonstrate the relative sizes and the relative distances between the planets.
7-Mile Long Scale Model
Starting with an Earth the size of a marble, these folks built a full-scale model of our solar system across 7 miles of Nevada desert.
Second Life 3D Model
This solar system model is built in Second Life, on online virtual world. Think about the differences between this model and the others.

Activity 3.15.1.

What are the main differences between the three models of the solar system described above?

Subsection 3.15.2 Simulations and Randomness

Simulations are used in many fields, including physics, biology, economics, and social sciences. They allow researchers to test hypotheses, explore scenarios, and make predictions about complex systems that would be difficult or impossible to study in the real world.
Computer simulations often use randomness to model real-world events. For example, a simulation of a coin toss might use a random number generator to determine whether the result is heads or tails. This allows the simulation to mimic the unpredictability of real-world events.
Computers cannot generate truly random numbers, but they can generate pseudorandom numbers that are close enough to random for most purposes. Pseudorandom numbers are generated using algorithms that produce sequences of numbers that appear random, but are actually determined by an initial value called a seed. By using different seeds, we can generate different sequences of pseudorandom numbers.

Activity 3.15.2.

Try this simple experiment:
  • If you flip a fair coin 20 times -- any type of coin will do -- how many heads would you expect to get?
  • Now flip the coin 20 times and count the number of heads.
Did the count match your explanation? Based on this experiment, could you conclude that your coin is fair or biased (not fair).
If you perform this experiment, heads will often come up 10 times, but not always, even though, supposedly, the probability of getting a head on a fair coin toss is 50%.
The problem with this experiment is you didn’t perform enough trials to draw any conclusion about the hypothesis that this is a fair coin. You would need to flip the coin many more times to get a better idea of whether the coin is fair or biased. This is where simulations can help.
We have already used the random module in Python to generate random numbers. The random.randint() function can be used to simulate a coin toss by generating a random integer between 0 and 1, where 0 represents heads and 1 represents tails.

Activity 3.15.3.

This short Python program simulates flipping a fair coin 20 times. It uses the random module to generate a random number between 0 and 1 for each flip, where 0 represents heads and 1 represents tails. The program counts the number of heads and tails and prints the results.
Change the code so that it completes 100 flips instead of 20. What is the percentage of heads and tails? Does it come closer to 50% than the 20 flips did?

Subsection 3.15.3 Population Growth Simulation

Simulations are often used to model population growth. In this simulation, you will explore how populations of rabbits and wolves change over time based on different initial conditions and parameters. You will be able to adjust the birth rates, death rates, and other factors to see how they affect the populations of both species.
This simulation of rabbits and wolves shows how nature attempts to stay balanced. Read the Learner’s Tab about how the simulation works and then complete the following activities. (Note that this simulator works best in the Firefox browser).

Activity 3.15.4.

On the Activity tab, click Start Simulation. You can open the population graphs at any point to see how they change over time. Record your observations about how the population of rabbits and wolves changed over time.

Activity 3.15.5.

Hypothesis: What would happen if there were lots more bunnies than there were wolves? Would the bunnies take over and live forever?
Experiment:
  • Test the hypothesis by first resetting the simulation.
  • Then click the View/Modify Parameters button followed by the View/Modify Start Parameters (Note that the View/Modify parameters button does not currently work in Chrome, but does work in Firefox).
  • Adjust the settings to increase the initial number of rabbits.
Record your observations. Did your prediction match with the results? How was it different than the first run of the simulation?

Activity 3.15.6.

Reverse the hypothesis: What would happen if there were lots more wolves than there are bunnies? Would the wolves live forever? Record your hypothesis, prediction and experiment results. (Don’t forget to reset the simulation before changing the parameters.)

Activity 3.15.7.

Explain how the rabbits and wolves live in balance in this simulation.

Activity 3.15.8.

This model chose to include certain features and exclude other features. For example, this simulation only includes rabbits, wolves, and grass but there are other predators of rabbits and other food sources for rabbits. Why do you think the creators focused on these data elements and not others? How might this introduce bias (concentration on or interest in a particular area) into the simulation?

Subsection 3.15.4 Simulations Review

Activity 3.15.9 Simulations Vocabulary.

Activity 3.15.10.

Which of the following would be examples of random events?
  • Choosing a ball from a black jar filled with red and green balls.
  • Choosing a ball from a jar is a random event.
  • Counting by 2s up to 20.
  • This doesn’t change much.
  • Dealing a hand of poker.
  • Assuming the deck is properly shuffled, dealing a poker hand is random.
  • Flipping a coin that has 3 sides.
  • It may be difficult to imagine a 3-sided coin, but really it’s just a 3-sided die.
  • Rolling a 12-sided die.
  • Rolling a single die is a random event.

Activity 3.15.11.

A list of numbers has n elements, indexed from 1 to n. The following algorithm is intended to display the number of elements in the list that have a value greater than 100. The algorithm uses the variables count and position. Steps 3 and 4 are missing.
Which of the following could be used to replace steps 3 and 4 so that the algorithm works as intended?
  • Step 3: Increase the value of position by 1.
    Step 4: Repeat steps 2 and 3 until the value of position is greater than n.
  • Step 3: Increase the value of position by 1.
    Step 4: Repeat steps 2 and 3 until the value of count is greater than 100.
  • Step 3: Repeat step 2 until the value of position is greater than n.
    Step 4: Increase the value of count by 1.
  • Step 3: Repeat step 2 until the value of count is greater than 100.
    Step 4: Increase the value of position by 1.

Activity 3.15.12.

Which of the following statements describes a limitation of using a computer simulation to model a real-world object or system?
  • Computer simulations usually make some simplifying assumptions about the real-world object or system being modeled.
  • This is correct
  • It is difficult to change input parameters or conditions when using computer simulations.
  • Computer simulations can only be built after the real-world object or system has been created.
  • Computer simulations only run on very powerful computers that are not available to the general public.

Activity 3.15.13.

A city’s fire department is using simulation software to analyze how a fire in an apartment complex might spread under a number of conditions. Consider the benefits and limitations of using a simulation instead of studying the real thing.
  • Name at least one benefit of using a simulation for this purpose.
  • Name at last one limitation of using a simulation for this purpose.

Activity 3.15.14.

Pick a model you use in your everyday life. What details does it capture and what details does it omit?
You have attempted of activities on this page.