Unit 3 Sections 16 Hacks
Home | API | Notes |
Notes
An experiment is a structured procedure that is undertaken to make a discovery, test a hypothesis, or demonstrate a known fact. Simulations, on the other hand, are used to attempt to replicate real-world events or situations in order to test or predict outcomes.
The advantages of using simulations include that they can be safer, more cost-effective, more efficient, and they can provide more data in less time than experiments. However, the downside of using simulations is that they are not as accurate as experiments and outside factors such as gravity and air resistance may not be included in the simulation.
Simulations should not be used when a situation already has set results or data that won't change, such as a score in a game, the most purchased food item, or the average yearly wage. In these cases, an experiment would not be necessary since the data is already known.
Simulations are a form of computer modeling that enables the analysis of a system by using mathematical models and algorithms to simulate the behavior of the system’s components. Simulations are used to study a system’s performance, its interactions with other systems, and its dynamic behavior over time. Simulations can be applied to any type of system, from simple mechanical systems to large, complex systems.
Simulations typically involve a combination of software and hardware components. The software component is responsible for creating a mathematical model of the system, which may include equations that describe the behavior of the system’s components and their interactions with each other. The hardware component is responsible for running the simulation, by executing the mathematical model and generating the results of the simulation.
Simulations can be used to study a variety of things, such as the performance of a system, the effects of changes to the system, or the behavior of a system over time. By running multiple simulations with different input values, researchers can gain insight into how a system will behave under different conditions. Simulations can also be used to test the accuracy of mathematical models, or to compare different models of the same system.
Simulations are a powerful tool for studying complex systems, as they provide a way to analyze the behavior of the system without actually having to build or test the system. They can also provide insight into the behavior of a system under a variety of conditions, allowing researchers to identify areas of improvement or potential problems. Simulations can be used to test new designs or to gain a better understanding of how a system works before building it.
Hack #1
- Create an idea for a simulation and describe it (you don’t actually have to code it just think about/answer the guiding questions).
To test the safety of a car, a simulation can be ran to test out different outcomes depending on the force of the crash. A simulation of this would help to reduce the costs and effects of physically performing crash tests for a car.
Hack #2
questions_number = 6
answers_correct = 0
questions = [
"True or False: Simulations will always have the same result. \n A: True, \n B: False",
"True or False: A simulation has results that are more accurate than an experiment \n A: True, \n B: False",
"True or False: A simulation can model real world events that are not practical for experiments \n A: True, \n B: False",
"Which one of these is FALSE regarding simulations \n A: Reduces Costs, \n B: Is safer than real life experiments, \n C: More Efficient, \n D: More accurate than real life experiments",
"Which of the following scenarios would be the LEAST beneficial to have as a simulation \n A: A retail company wants to identify the item which sold the most on their website, \n B: A restaurant wants to determine if the use of robots will increase efficiency, \n C: An insurance company wants to study the impact of rain on car accidents, \n D: A sports car company wants to study design changes to their new bike design ",
"Which of the following is better to do as a simulation than as a calculation \n A: Keeping score at a basketball game, \n B: Keeping track of how many games a person has won, \n C: Determining the average grade for a group of tests, \n D: Studying the impact of carbon emissions on the environment"
]
question_answers = [
"B",
"B",
"A",
"D",
"A",
"D"
]
print("Welcome to the Simulations Quiz!")
def ask_question (question, answer):
print("\n", question)
user_answer = input(question)
print("You said: ", user_answer)
if user_answer == answer:
print("Correct!")
global answers_correct
answers_correct = answers_correct + 1
else:
print("You are incorrect")
for num in range(questions_number):
ask_question(questions[num], question_answers[num])
print("You scored: ", answers_correct, "/6")
Hack #3
- Describe the rolling dice simulation (answer guiding questions)
1) What makes it a simulation? The dice simulation is a proper simulation because it imitates the process of rolling a dice in a randomized manner from the numbers 1 through 6.
2) What are it’s advantages and disadvantages? The simulation allows the dice roll to be quickly and easily carried out. The disadvantage of the simulation is that it is purely mathematical, it does not account for any sorts of physical forces (ie. dents, cracks, etc.) that may affect the dice roll in a real-life scenario.
3) In your opinion, would an experiment be better in this situation? In my opinion, I believe that a simulation would work better than an experiment - as it disregards human errors such as various forms of rolling, or physical alterations to the dice.
Hack #4
- Add a feature onto the rolling dice simulation
- ex: a 14-sided dice or expand the purpose of the simulation (hint: use conditionals to make dice part of a game/real life situation)
import random
def roll_dice(num_dice):
roll_results = []
for _ in range(num_dice):
roll = random.randint(1, 14)
roll_results.append(roll)
return roll_results
num_dice_input = input("How many dice do you want to roll? [1-14] ")
num_dice = parse_input(num_dice_input)
roll_results = roll_dice(num_dice)
print("You rolled:", roll_results)
Extra Work
Going over John Conway's Game of Life
John Conway's Game of Life is a cellular automaton game, meaning it consists of a grid of cells that change state based on a set of rules and the states of their neighbors. The game was developed by John Conway in 1970 and has since become a popular subject in mathematics and computer science.
The game consists of a 2-dimensional grid of cells, each of which can have one of two states: "alive" or "dead". A cell is considered alive if it has two or three neighbors that are alive, and is considered dead if it has fewer than two neighbors or more than three neighbors. The cells then evolve over time based on these rules.
At each step of the game, any live cell with fewer than two or more than three live neighbors dies, as if by underpopulation or overpopulation. Any deceased cell that has three living neighbors shall turn into a live cell - simulating reproduction. All other cells remain unchanged.
The game can be implemented in many ways, but is often seen as a "zero-player" game, meaning that once the initial setup is complete, the game proceeds by itself. As a result, it has been used to study the behavior of complex systems and to explore emergent behavior.
import random
def gamble(your_spin):
result = []
for _ in range (your_spin):
spin = random.randint(1, 7)
your_spin.append(spin)
print(result)
return result
spin_num = 3
result = gamble(spin_num)
print("Your roll: ", result)
#Not finished