Topic 3.16: Simulations

Part 1:

Learning Objective:

  • How computers can be used to represent real-world phoenomena

Essential Knowledge:

  • Simulations are abstractions for more complex objects or phoenomena for a specific purpose

  • Mimic real-world events, with simplification

  • Made to refine results/hypothesis

  • May have limitations or bias

  • When creating car-testing simulations, we assume the driver is at least 16 years old, and has their seatbelt on.

  • Examples: Radar displays, RNG simulating variability, and weather forecasting

Process_simulation

Vocab:

  • Simulation abstraction - The little errors or unusual things that come up when running a simulation

Popcorn Hack 1:

  • True or false:
  1. (T or F) A simulation will always have the same result

  2. (T or F) A simulation is used when it would be more convenient than an experiment

  3. (T or F) A simulation models very specific scenarios

  4. (T or F) A simulation cannot provide valid data to be used as fact

Answers

  1. F

  2. T

  3. T

  4. F

Part 2

  • Simulations are abstractions; mocking the real world items to get an idea of how they work on actual items

Simulations vs. Experiments:

Simulations Experiments
Simulations are where you try to mock the real-world items to get an idea of how they may perform without having to use the actual items. Experiment is dealing with an actual real-world object, using real-world equipment.
Simulations can be less expensive than experiments. Experiments can be more expensive than simulations.
Simulations provide estimated results based on models. Experiments provide actual results.
A simulation can model real-world events that are not feasible or doable for experiments. Experiments may not be possible using real-world equipment, for reasons such as the assets are not available, or they would be too dangerous.
Simulations are easier to repeat. Once set up, simulations may be faster and Experiments may take a long time to set up and conduct.
Simulations can be safer to conduct. Example: Simulation of a car crash Experiments can provide results that prove the safety of the product or event. Example: Flying an aircraft prototype.
  • Simulations are less risky and provide information on the probability of something happening
  • Experiments are riskier but more invasive, allowing for results
  • Simulations are less expensive
  • EXAMPLE: Tony Stark’s time travel SIMULATION was a test to see if his time travel theory would work
  • EXAMPLE RESULT: Tony Stark’s time travel SIMULATION worked and it provided an accurate estimate of how it would work. He then proceeded with an EXPERIMENT to see if it would actually work.

Popcorn Hack 2:

Which of the following scenarios is better to do as a simulation than a calculation?

1) Keeping score at a football game 2) Studying the spread of disease in a country 3) Determining average grade from a set of quizzes 4) Studying the impact carbon emissions on the environment

ANSWER: Scenarios 2 and 4 are better to do as a simulation because simulations provide a better, accurate estimate. Scenarios 1 and 3 are actual numbers that are straight up calculations

Popcorn Hack 3:

Which of the following statements expresses a constraint of using a computer simulation to imitate a real-world object or system?

  1. Computer simulations can only be done after the real-world object or system has been created.
  2. Computer simulations can only run-on powerful computers that are not accessible to the public.
  3. Computer simulations usually make some assumptions about the real-world object or system being modeled.
  4. Computer simulations parameters and conditions are difficult to change.

ANSWER: Scenario 3 because simulations are biased and make assumptions

  • Simulations can contain bias derived from the choices of real-world elements that were included or excluded.
  • 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).
  • Simulations facilitate the formulation and refinement of hypotheses related to the objects or phenomena under consideration.
  • Random number generators can be used to simulate the variability that exists in the real world.

Topic 3.17: Algorithmic Efficiency

Part 1

What is Algorithmic Efficiency?

  • A way to find the fastest and least resource dependent solution to a problem
  • Measures using number of computations (you can think of them as steps) in a algorithm before you can solve your problem
  • Generally speaking less computations = faster = better code but it’s heavily dependent on input size as algorithms with small input sizes may sometimes seem faster but are actually much slower at high input sizes

Basic Algorithm Example:

  • Picture a set of 4 cards numbered [4,6,7,2]. To sort these cards algorithmically, you run through them from left to right, comparing if the numbers are bigger or smaller than the card to their right.
  • If they’re already ordered correctly, you keep them as is and mark down that you made a comparison. If they’re bigger than the card on their right, you swap their positions and repeat the process for the next set of 2 cards, until you fixed them entirely. You mark down comparisons and swaps throughout the algorithm.
  • For this example, you have to make 7 comparisons and 3 swaps to make the list ordered, into [2,4,6,7], even though you’re only actually changing the position of one number.

Better Algorithm Example:

  • A different algorithm for the same problem, for example, one where you instead hold onto the smallest card instead each time you go through the set, could only use 6 comparisons and 1 swap, making it algorithmically more efficient.

Algorithm Efficiency Simply Explained:

  • On the most basic level, you can think of efficiency as a measure of the number of steps it takes you to reach your answer. If one algorithm has 7 total steps and a different one for the same problem has 20, your first algorithm is likely more efficient.
  • But, when analyzing algorithm efficiency, you can only achieve accuracy by measuring with different input sizes as well. This is due to the fact that some algorithms increase their number of steps with polynomial efficiency (linear increasing or other polynomial styles), but others increase exponentially or factorially.
  • Algorithms are only reasonable if their operate with polynomial efficiency

Popcorn Hack 4

Which algorithm in this set is unreasonable and why?

ANSWER : A as it is the only one that increases exponentially (4^x vs x^3, 7+4x, etc.)

Part 2