Unit 3 Section 16 Blog
Unit 3 Section 16
Notes
- Can use a psuedo-random number generator to represent things like roling a dice
- Experiments are usually much harder to do than simulations, but involve all real world variables
- Important to use flowcharts to plan out simulations
- Simulation: simpler abstraction of an very complicated natural phenomena
- Simulations remove details that are unnecessary or are too difficult to simulate
- Simulations are cheaper to do, safer, repeatable, and can be used to make predictions
- Simulations can be used for complex scenarioes
- Things like rolling a dice have many things affecting it
- Will take a lot of conditionals, iteration
Explanations for Answers
3) Using a pseudo-random number generator in a simulation can make it less accurate, so it is better to avoid using one.
4) In a flight simulation, the least likely factor to be removed for the sake of functionality is imperfections on aircraft.
5) The main difference between an experiment and a simulation is the situation being considered.
6) A car company can use simulation to determine the safety of their new car in the event of a crash, as it would be too dangerous to conduct such an experiment on real vehicles.
7) An environmental group may use simulation to accurately predict the impact of the greenhouse effect on the environment, as it would be harmful to conduct an experiment on the actual environment.
9) A teacher can use an experiment to find the average score on a final exam, as this will simply involve calculating the average and does not require simulation.
import random
tracker = {1:0, 2:0, 3:0, 4:0, 5:0, 6:0}
i = 0
def diceGame():
dice_roll = random.randint(1, 6)
return dice_roll
while i < 1000:
score = diceGame()
tracker[score] += 1
i += 1
print("Here are the results of the dice rolling simulation.")
for j in range(1, 7):
tracker[j] = ((tracker[j])/1000)*100
print("Frequency of " + str(j) + ": " + str(tracker[j]) + "%")