Unit 3 Lesson 16, Student Copy
Notes
- The main difference between simulations and experiments is that simulations replicate real world scenarios digitally while experiments are held in the real world
- Simulations usually are less expensive than running an experiment because the expenses needed for acquiring equipment are not present when running a simulation
- Since experiments and done in the real world, they provide actual results while simulations use models based on collected data to provide estimations of what is expected to happen
- Simulations can provide estimations for events that can't be recreated in the real world because simulations don't run the risk of safety issues and they can be done without equipment that would be needed for experimentation
- Once created, simulations are easier to repeat to obtain more estimations when compared to experiments because experiments often take a long time to set up and execute
- Simulation are a way to simulate real-world environments to test safety or logistics. It's important to use random numbers, consider biases, and consider if a simulation is the best solution.
- When making a simulation you should consider removing details, which could be done using pseudo-random number generators, and using other ideas from previous college board lessons; like procedure, flowcharts and conditionals
import random
otherclothes = ["white hat", "blue shirt", "purple socks"]
myclothes = ["red shoes", "green pants", "tie", "belt"]
def mycloset():
my = myclothes[(random.randint(0,(len(myclothes) - 1)))]
other = otherclothes[random.randint(0,(len(otherclothes) - 1))]
i = input("do you want to trash or add clothes")
print("closet before trashing/adding: " + str(myclothes))
if i == "trash":
myclothes.remove(my)
print("closet after removing an item: " + str(myclothes))
elif i == "add":
myclothes.append(other)
print("closet after adding an item: " + str(myclothes))
else:
print("not a valid input")
mycloset()
import random
def coinflip(): #def function
randomflip = random.randint(0,3) #picks either 0 or 1 randomly (50/50 chance of either)
if randomflip == 0 or 1: #assigning 0 to be heads--> if 0 is chosen then it will print, "Heads"
print("Heads")
else:
if randomflip == 2: #assigning 1 to be tails--> if 1 is chosen then it will print, "Tails"
print("Tails")
#Tossing the coin 5 times:
t1 = coinflip()
t2 = coinflip()
t3 = coinflip()
t4 = coinflip()
t5 = coinflip()
import random
dec = 0
def randomnum(): # function for generating random int
ran = random.randint(1,255)
return(ran)
def converttobin(n): # function for converting decimal to binary
bin = ""
i = 7
while i >= 0:
if n % (2**i) == n:
bin = bin + "0"
i -= 1
else:
bin = bin + "1"
n -= 2**i
i -= 1
return(bin)
survivorstatus = ["hykeem", "kendrick", "don", "travis" , "ye", "jeffrey", "quavo", "offset"]
def survivors(binary): # function to assign position
i = 0
print("inital survivors: " + str(survivorstatus))
while i < len(survivorstatus):
if binary[i] == "0":
rem = survivorstatus[i]
survivorstatus.remove(rem)
i += 1
else:
i += 1
print("final survivors: " + str(survivorstatus))
ran1 = randomnum()
bin1 = converttobin(ran1)
survivors(bin1)
import random
def roll():
x = random.randint(1,6)
return(str(x))
a = roll()
b = roll()
c = roll()
d = roll()
print(a)
print(b)
print(c)
print(d)
- A researcher gathers data about the effect of Advanced Placement®︎ classes on students' success in college and career, and develops a simulation to show how a sequence of AP classes affect a hypothetical student's pathway.Several school administrators are concerned that the simulation contains bias favoring high-income students, however.
- answer options:
- The simulation is an abstraction and therefore cannot contain any bias
- The simulation may accidentally contain bias due to the exclusion of details.
- If the simulation is found to contain bias, then it is not possible to remove the bias from the simulation.
- The only way for the simulation to be biased is if the researcher intentionally used data that favored their desired output.
- answer options:
- Jack is trying to plan his financial future using an online tool. The tool starts off by asking him to input details about his current finances and career. It then lets him choose different future scenarios, such as having children. For each scenario chosen, the tool does some calculations and outputs his projected savings at the ages of 35, 45, and 55.Would that be considered a simulation and why?
- answer options
- No, it's not a simulation because it does not include a visualization of the results.
- No, it's not a simulation because it does not include all the details of his life history and the future financial environment.
- Yes, it's a simulation because it runs on a computer and includes both user input and computed output.
- Yes, it's a simulation because it is an abstraction of a real world scenario that enables the drawing of inferences.
- answer options
- Sylvia is an industrial engineer working for a sporting goods company. She is developing a baseball bat that can hit balls with higher accuracy and asks their software engineering team to develop a simulation to verify the design.Which of the following details is most important to include in this simulation?
- answer options
- Realistic sound effects based on the material of the baseball bat and the velocity of the hit
- A depiction of an audience in the stands with lifelike behavior in response to hit accuracy
- Accurate accounting for the effects of wind conditions on the movement of the ball
- A baseball field that is textured to differentiate between the grass and the dirt
- answer options
- Ashlynn is an industrial engineer who is trying to design a safer parachute. She creates a computer simulation of the parachute opening at different heights and in different environmental conditions.What are advantages of running the simulation versus an actual experiment?
- answer options
- The simulation will not contain any bias that favors one body type over another, while an experiment will be biased.
- The simulation can be run more safely than an actual experiment
- The simulation will accurately predict the parachute's safety level, while an experiment may be inaccurate due to faulty experimental design.
- The simulation can test the parachute design in a wide range of environmental conditions that may be difficult to reliably reproduce in an experiment.
- this question has 2 correct answers
- answer options
- YOUR OWN QUESTION; can be situational, pseudo code based, or vocab/concept based
- YOUR OWN QUESTION; can be situational, pseudo code based, or vocab/concept based
questions = [
((3,0), "A researcher gathers data about the effect of Advanced Placement classes on students' success in college and career, and develops a simulation to show how a sequence of AP classes affect a hypothetical student's pathway.Several school administrators are concerned that the simulation contains bias favoring high-income students, however.",
"The simulation is an abstraction and therefore cannot contain any bias",
"The simulation may accidentally contain bias due to the exclusion of details.",
"If the simulation is found to contain bias, then it is not possible to remove the bias from the simulation.",
"The only way for the simulation to be biased is if the researcher intentionally used data that favored their desired output."),
((4,0), "Jack is trying to plan his financial future using an online tool. The tool starts off by asking him to input details about his current finances and career. It then lets him choose different future scenarios, such as having children. For each scenario chosen, the tool does some calculations and outputs his projected savings at the ages of 35, 45, and 55.Would that be considered a simulation and why?",
"No, it's not a simulation because it does not include a visualization of the results.",
"No, it's not a simulation because it does not include all the details of his life history and the future financial environment.",
"Yes, it's a simulation because it runs on a computer and includes both user input and computed output.",
"Yes, it's a simulation because it is an abstraction of a real world scenario that enables the drawing of inferences."),
((1,0), "Sylvia is an industrial engineer working for a sporting goods company. She is developing a baseball bat that can hit balls with higher accuracy and asks their software engineering team to develop a simulation to verify the design.Which of the following details is most important to include in this simulation?",
"Realistic sound effects based on the material of the baseball bat and the velocity of the hit",
"A depiction of an audience in the stands with lifelike behavior in response to hit accuracy",
"Accurate accounting for the effects of wind conditions on the movement of the ball",
"A baseball field that is textured to differentiate between the grass and the dirt"),
((2,4), "Ashlynn is an industrial engineer who is trying to design a safer parachute. She creates a computer simulation of the parachute opening at different heights and in different environmental conditions.What are advantages of running the simulation versus an actual experiment?",
"The simulation will not contain any bias that favors one body type over another, while an experiment will be biased.",
"The simulation can be run more safely than an actual experiment",
"The simulation will accurately predict the parachute's safety level, while an experiment may be inaccurate due to faulty experimental design.",
"The simulation can test the parachute design in a wide range of environmental conditions that may be difficult to reliably reproduce in an experiment."),
((1,0), "what function is used to add?",
"+",
"-",
"*",
"%"),
((1,0), "what function is used to subtract?",
"-",
"+",
"*",
"/")
]
def questionloop(qlist):
score = 0
for sub in qlist:
print("question: " + sub[1])
print("answer 1: " + sub[2])
print("answer 2: " + sub[3])
print("answer 3: " + sub[4])
print("answer 4: " + sub[5])
res = input("Choose an answer number: ")
if int(res) == sub[0][0]:
score += 1
continue
elif int(res) == sub[0][1]:
score += 1
else:
continue
percent = score * 100 / 6
passfail = ""
if percent < 70:
passfail = "failed"
else:
passfail = "passed"
print("You " + str(passfail) + " the test with " + str(percent) + "%.")
questionloop(questions)
Create your own simulation based on your experiences/knowledge! Be creative! Think about instances in your own life, science, puzzles that can be made into simulations
Some ideas to get your brain running: A simulation that breeds two plants and tells you phenotypes of offspring, an adventure simulation...
import random
genotypes = ["RR", "Rr", "rr"]
def breed(parent1, parent2):
genotype1 = random.choice(parent1)
genotype2 = random.choice(parent2)
offspring_genotype = genotype1 + genotype2
return offspring_genotype
def determine_phenotype(genotype):
if genotype == "RR" or genotype == "Rr":
return "red"
elif genotype == "rr":
return "white"
parent1 = ["RR", "Rr"]
parent2 = ["RR", "rr"]
offspring_genotype = breed(parent1, parent2)
offspring_phenotype = determine_phenotype(offspring_genotype)
print(f"The offspring has a {offspring_phenotype} phenotype.")