lab06 (1)
pdf
keyboard_arrow_up
School
Santa Clara University *
*We aren’t endorsed by this school
Course
MISC
Subject
Statistics
Date
Apr 3, 2024
Type
Pages
8
Uploaded by CountRaccoon297
lab06
July 14, 2023
[35]:
# Initialize Otter
import
otter
grader
=
otter
.
Notebook(
"lab06.ipynb"
)
0.1
Lab 6: Examining the Therapeutic Touch
Welcome to Lab 6!
After such an extensive introduction to programming for data science, we are finally moving into
the section of the course where we can apply our new skils to answer real questions.
In this lab, we’ll use testing techniques that were introduced in lecture to test the idea of the
therapeutic touch, the idea that some practitioner can feel and massage your human energy field.
Submission
: Once you’re finished, run all cells besides the last one, select File > Save Notebook,
and then execute the final cell. Then submit the downloaded zip file, that includes your notebook,
according to your instructor’s directions.
[36]:
# Run this cell, but please don't change it.
# These lines import the Numpy and Datascience modules.
import
numpy
as
np
from
datascience
import
*
# These lines do some fancy plotting magic
import
matplotlib
%
matplotlib
inline
import
matplotlib.pyplot
as
plt
plt
.
style
.
use(
'fivethirtyeight'
)
import
warnings
warnings
.
simplefilter(
'ignore'
,
FutureWarning
)
from
matplotlib
import
patches
from
ipywidgets
import
interact, interactive, fixed
import
ipywidgets
as
widgets
import
d8error
1
0.2
1. What is the Therapeutic Touch
The Therapeutic Touch (TT) is the idea that everyone can feel the Human Energy Field (HEF)
around individuals. Those who practice TT have described different people’s HEFs as “warm as
Jell-O” and “tactile as taffy.”
TT was a popular technique used throughout the 20th century that was toted as a great way to
bring balance to a person’s health.
Certain practitioners claim they have the ability to feel the
HEF and can massage it in order to promote health and relaxation in individuals.
0.2.1
Emily Rosa
Emily Rosa
was a 4th grade student who was very familiar with the world of TT, thanks to her
parents, who were both medical practitioners and skeptics of TT.
For her 4th grade science fair project, Emily decided to test whether or not TT practitioners could
truly interact with a person’s HEF. She later went on to publish her work in TT, becoming the
youngest person to have a research paper published in a peer reviewed medical journal.
0.2.2
Emily’s Experiment
Emily’s experiment was clean, simple, and effective. Due to her parents’ occupations in the medical
field, she had wide access to people who claimed to be TT practitioners.
Emily took 21 TT practitioners and used them for her science experiment. She would take a TT
practitioner and ask them to extend their hands through a screen (which they can’t see through).
Emily would be on the other side and would flip a fair coin. Depending on how the coin landed,
she would put out either her left hand or her right hand. The TT practitioner would then have
to answer which hand Emily put out. If a pracitioner could truly interact with a person’s HEF, it
would be expected that they answered correctly.
Overall, through 210 samples, the practitioner picked the correct hand 44% of the time.
Emily’s main goal here was to test whether or not the TT practicioners’ guesses were random, like
the flip of a coin. In most medical experiments, this is the norm. We want to test whether or not
the treatment has an effect,
not
whether or not the treatment actually works.
We will now begin to formulate this experiment in terms of the terminology we learned in this
course.
Question 1.1
: Describe Emily’s model for how likely the TT practitioners are to choose the correct
hand. What alternative model is her model meant to discredit? Discuss with students around you
to come to a conclusion. Check in with a TA or AI if you are stuck.
Type your answer here, replacing this text.
Question 1.2:
Remember that the practitioner got the correct answer 44% (0.44) of the time.
According to Emily’s model, on average, what proportion of times do we expect the practitioner
to guess the correct hand? Make sure your answer is a number between 0 and 1.
[37]:
expected_proportion_correct
= 0.5
expected_proportion_correct
2
[37]:
0.5
[38]:
grader
.
check(
"q1_2"
)
[38]:
q1_2 results: All test cases passed!
The goal now is to see if our deviation from this expected proportion of correct answers is due to
something other than chance.
Question 1.3:
We usually use a statistic to help determine which model the evidence points
towards. What is a statistic that we can use to compare outcomes under Emily’s model to what
was observed? Assign
valid_stat
to an array of integer(s) representing test statistics that Emily
can use:
1. The difference between the expected percent correct and the actual percent correct
2. The absolute difference between the expected percent correct and the actual percent correct
3. The sum of the expected percent correct and the actual percent correct
NOTE:
Make sure to use
make_array
to create your array of integer(s)!
[39]:
valid_stat
=
make_array(
2
)
valid_stat
[39]:
array([2])
[40]:
grader
.
check(
"q1_3"
)
[40]:
q1_3 results: All test cases passed!
Question 1.4:
Why is the statistic from Question 1.3 the appropriate choice for comparing out-
comes in Emily’s experiment? How does it relate to the models you defined in Question 1.1?
Type your answer here, replacing this text.
Question 1.5:
Define the function
statistic
which takes in an expected proportion and an actual
proportion, and returns the value of the statistic chosen in Question 1.3. Assume that the argument
takes in proportions, but return your answer as a percentage.
Hint:
Remember we are asking for a
percentage
, not a proportion.
[41]:
def
statistic
(expected_prop, actual_prop):
return
100 *
abs
(expected_prop
-
actual_prop)
[42]:
grader
.
check(
"q1_5"
)
[42]:
q1_5 results: All test cases passed!
Question 1.6:
Use your newly defined function to calculate the observed statistic from Emily’s
experiment.
3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
[43]:
observed_statistic
=
statistic(
0.5
,
0.44
)
observed_statistic
[43]:
6.0
[44]:
grader
.
check(
"q1_6"
)
[44]:
q1_6 results: All test cases passed!
Is this observed statistic consistent with what we expect to see under Emily’s model?
In order to answer this question, we must simulate the experiment as though Emily’s model was
correct, and calculate our statistic for every simulation.
0.2.3
sample_proportions
sample_proportions
can be used to randomly sample from multiple categories when you know the
proportion of data points that are expected to fall in each category.
sample_proportions
takes
two arguments: the sample size and an array that contains the distribution of categories in the
population (should sum to 1).
Consider flipping a fair coin, where the two outcomes (coin lands heads and coin lands tails) occur
with an equal chance. We expect that half of all coin flips will land heads, and half of all coin flips
will land tails.
Run the following cell to see the simulation of 10 flips of a fair coin.
Let the first item of
coin_proportions
be the proportion of heads and the second item of
coin_proportions
be the
proportion of tails.
Observe what happens when you run this cell multiple times—the proportion of coin flips that land
heads and tails appears to change, as you are simulating flipping 10 coins each time!
[45]:
coin_proportions
=
make_array(
0.5
,
0.5
)
ten_flips
=
sample_proportions(
10
, coin_proportions)
ten_flips
[45]:
array([ 0.5,
0.5])
sample_proportions
returns an array that is the same length as the proportion array that is
passed through. It contains the proportion of each category that appears in the sample.
In our example, the first item of
ten_flips
is the simulated proportion of heads and the second
item of
ten_flips
is the simulated proportion of tails.
[46]:
simulated_proportion_heads
=
ten_flips
.
item(
0
)
simulated_proportion_tails
=
ten_flips
.
item(
1
)
print
(
"In our simulation, "
+
str
(simulated_proportion_heads)
+
" of flips were
␣
↪
heads and "
\
+
str
(simulated_proportion_tails)
+
" of flips were tails."
)
4
In our simulation, 0.5 of flips were heads and 0.5 of flips were tails.
Question 1.7:
To begin simulating, we should start by creating a representation of Emily’s model
to use for our simulation. This will be an array with two items in it. The first item should be the
proportion of times a TT practictioner picks the correct hand, assuming that Emily’s model was
correct. The second item should be the proportion of times, under the same assumption, that the
TT practitioner picks the incorrect hand. Assign
model_proportions
to this array.
After this, we can simulate 210 hand choices, as Emily evaluated in real life, and find a single statistic
to summarize this instance of the simulation. Use the
sample_proportions
function and assign
the
proportion of correct hand choices
(out of 210) to
simulation_proportion_correct
.
Lastly, use your statistic function to assign
one_statistic
to the value of the statistic for this one
simulation.
Hint:
sample_proportions
usage can be found on the
Python Reference
.
[47]:
# This saves the random state of our code so that we can
# generate the same numbers each time we run the code.
# Please do not change this line.
np
.
random
.
seed(
16
)
model_proportions
=
make_array(
0.5
,
0.5
)
simulation_proportion_correct
=
sample_proportions(
210
,model_proportions)
.
↪
item(
0
)
one_statistic
=
statistic(simulation_proportion_correct,
0.5
)
one_statistic
[47]:
0.9523809523809545
[48]:
grader
.
check(
"q1_7"
)
[48]:
q1_7 results: All test cases passed!
Question 1.8:
Let’s now see what the distribution of statistics is actually like under Emily’s
model.
Define the function
simulation_and_statistic
to take in the
model_proportions
array and the
expected proportion of times a TT practitioner would guess a hand correctly under Emily’s model.
The function should simulate Emily running through the experiment 210 times and return the
statistic of this one simulation.
Hint:
This should follow the same pattern as the code you did in the previous problem.
Type your answer here, replacing this text.
[49]:
def
simulation_and_statistic
(model_proportions, expected_proportion_correct):
'''Simulates 210 TT hand choices under Emily’s model.
Returns one statistic from the simulation.'''
return
abs
(
0.5 -
simulation_proportion_correct)
5
[50]:
num_repetitions
= 1000
simulated_statistics
=
make_array()
for
i
in
np
.
arange(num_repetitions):
simulated_statistics
=
np
.
append(simulated_statistics,
␣
↪
simulation_proportion_correct)
[51]:
grader
.
check(
"q1_8"
)
[51]:
q1_8 results: All test cases passed!
Let’s view the distribution of the simulated statistics under Emily’s model, and visually compare
where the observed statistic lies relative to the simulated statistics.
[52]:
t
=
Table()
.
with_column(
'Simulated Statistics'
, simulated_statistics)
t
.
hist()
plt
.
scatter(observed_statistic,
0
, color
=
'red'
, s
=100
, zorder
=2
);
We can make a visual argument as to whether we believe the observed statistic is consistent with
Emily’s model. Here, since larger values of the test statistic suggest the alternative model (where
the chance of guessing the correct hand is something other than 50%), we can formalize our analysis
by finding what proportion of simulated statistics were as large or larger than our observed test
statistic (the area at or to the right of the observed test statistic).
If this area is small enough,
we’ll declare that the observed data are inconsistent with our simulated model. Here is the
link
to
6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
the section in the textbook.
Question 1.9:
Calculate the proportion of simulated statistics greater than or equal to the observed
statistic.
Hint:
np.count_nonzero
usage can be found
here
.
[53]:
proportion_greater_or_equal
=
(np
.
↪
count_nonzero(simulated_statistics
>=
observed_statistic))
/
↪
len
(simulated_statistics)
proportion_greater_or_equal
[53]:
0.0
[54]:
grader
.
check(
"q1_9"
)
[54]:
q1_9 results: All test cases passed!
By convention, we often compare the proportion we just calculated to 0.05. If the proportion of
simulated statistics greater than or equal to the observed statistic is suffciently small (less than or
equal to 0.05), then this is evidence against Emily’s model. Conceptually, you may think of this
as the case where less than 5% of simulated values are as far or farther away from what we had
expected. If this is not the case, we don’t have any reason to doubt Emily’s model.
This should help you make your own conclusions about Emily Rosa’s experiment.
Therapeutic touch fell out of use after this experiment, which was eventually accepted into one of the
premier medical journals. TT practitioners hit back and accused Emily and her family of tampering
with the results, while some claimed that Emily’s bad spiritual mood towards therapeutic touch
made it diffcult to read her HEF. Whatever it may be, Emily’s experiment is a classic example
about how anyone, with the right resources, can test anything they want!
Question 1.10:
Now, take some time to think to yourself and discuss with your peers:
1. Is the data more consistent with Emily’ model (practioners were randomly guessing)?
2. What does this mean in terms of Emily’s experiment?
Do the TT practitioners’ answers
follow an even chance model or is there something else at play?
Did you talk to your peers? (T/F)
[55]:
peer_talk
=
"Yes, because Emily's experiment was clean, simple, and effective
␣
↪
which is shown as the respondent had chosen the correct hand."
peer_talk
[55]:
"Yes, because Emily's experiment was clean, simple, and effective which is shown
as the respondent had chosen the correct hand."
[56]:
peer_talk
==
True
[56]:
False
7
0.3
2. Submission
Appa and Momo want to congratulate you on completing the lab!! Now you can relax like them!
Important submission steps:
1. Run the tests and verify that they all pass. 2. Choose
Save
Notebook
from the
File
menu, then
run the final cell
. 3. Click the link to download the zip
file.
4.
Then submit the zip file to the corresponding assignment according to your instructor’s
directions.
It is your responsibility to make sure your work is saved before running the last cell.
0.4
Submission
Make sure you have run all cells in your notebook in order before running the cell below, so that
all images/graphs appear in the output. The cell below will generate a zip file for you to submit.
Please save before exporting!
[57]:
# Save your notebook first, then run this cell to export your submission.
grader
.
export(pdf
=
False
, run_tests
=
True
)
Running your submission against local test cases…
Your submission received the following results when run against available test
cases:
q1_2 results: All test cases passed!
q1_3 results: All test cases passed!
q1_5 results: All test cases passed!
q1_6 results: All test cases passed!
q1_7 results: All test cases passed!
q1_8 results: All test cases passed!
q1_9 results: All test cases passed!
<IPython.core.display.HTML object>
8
Related Documents
Related Questions
could you provide an example please?
arrow_forward
Page
of 11
ZOOM +
5. The table shows how the cost of a carne asada taco at my favorite taco
stand has increased as they have become more popular since their
opening in 2013. Use the data to answer the questions below.
Year, x
2013, 0 2014, 1
2015, 2 2016, 3 2017, 4 2018, 5 2019,6
Cost ($) 0.50
0.55
0.65
0.75
0.90
1.00
1.10
(a) What is the regression line given by your TI-84 for this data?
Round values to 3 decimal places.
(b) Using the regression equation above, predict the cost of a carne asada
taco at my favorite taco stand in 2020. Show the work.
arrow_forward
Can you give an example please?
arrow_forward
For the second part of this activity, determine which “average” would be a better representation WITHOUT being given a specific data set. This will require you to think about WHO is requesting or wants the data and then determine which “average” would better suit their needs. In real-life settings, most companies like to portray themselves in a better “light,” so you will have to think critically about how best to do that. Try to think of all the possibilities that can occur and if you need to, “create” a data set to help you determine which “average” to choose.
Scenario
Explanation
a) The average number of pieces of lost luggage per flight from an airline company’s perspective
b) The average weight of potatoes in a 10- pound bag
c) The average age at first marriage for men in America
arrow_forward
Give 2 characteristics that indicate a linear model may be appropriate to model a data set
arrow_forward
Briefly explain what is survival analysis how it works?
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you


Algebra for College Students
Algebra
ISBN:9781285195780
Author:Jerome E. Kaufmann, Karen L. Schwitters
Publisher:Cengage Learning

Glencoe Algebra 1, Student Edition, 9780079039897...
Algebra
ISBN:9780079039897
Author:Carter
Publisher:McGraw Hill

Holt Mcdougal Larson Pre-algebra: Student Edition...
Algebra
ISBN:9780547587776
Author:HOLT MCDOUGAL
Publisher:HOLT MCDOUGAL

College Algebra (MindTap Course List)
Algebra
ISBN:9781305652231
Author:R. David Gustafson, Jeff Hughes
Publisher:Cengage Learning

Elementary Geometry for College Students
Geometry
ISBN:9781285195698
Author:Daniel C. Alexander, Geralyn M. Koeberlein
Publisher:Cengage Learning
Related Questions
- could you provide an example please?arrow_forwardPage of 11 ZOOM + 5. The table shows how the cost of a carne asada taco at my favorite taco stand has increased as they have become more popular since their opening in 2013. Use the data to answer the questions below. Year, x 2013, 0 2014, 1 2015, 2 2016, 3 2017, 4 2018, 5 2019,6 Cost ($) 0.50 0.55 0.65 0.75 0.90 1.00 1.10 (a) What is the regression line given by your TI-84 for this data? Round values to 3 decimal places. (b) Using the regression equation above, predict the cost of a carne asada taco at my favorite taco stand in 2020. Show the work.arrow_forwardCan you give an example please?arrow_forward
- For the second part of this activity, determine which “average” would be a better representation WITHOUT being given a specific data set. This will require you to think about WHO is requesting or wants the data and then determine which “average” would better suit their needs. In real-life settings, most companies like to portray themselves in a better “light,” so you will have to think critically about how best to do that. Try to think of all the possibilities that can occur and if you need to, “create” a data set to help you determine which “average” to choose. Scenario Explanation a) The average number of pieces of lost luggage per flight from an airline company’s perspective b) The average weight of potatoes in a 10- pound bag c) The average age at first marriage for men in Americaarrow_forwardGive 2 characteristics that indicate a linear model may be appropriate to model a data setarrow_forwardBriefly explain what is survival analysis how it works?arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Algebra for College StudentsAlgebraISBN:9781285195780Author:Jerome E. Kaufmann, Karen L. SchwittersPublisher:Cengage LearningGlencoe Algebra 1, Student Edition, 9780079039897...AlgebraISBN:9780079039897Author:CarterPublisher:McGraw Hill
- Holt Mcdougal Larson Pre-algebra: Student Edition...AlgebraISBN:9780547587776Author:HOLT MCDOUGALPublisher:HOLT MCDOUGALCollege Algebra (MindTap Course List)AlgebraISBN:9781305652231Author:R. David Gustafson, Jeff HughesPublisher:Cengage LearningElementary Geometry for College StudentsGeometryISBN:9781285195698Author:Daniel C. Alexander, Geralyn M. KoeberleinPublisher:Cengage Learning


Algebra for College Students
Algebra
ISBN:9781285195780
Author:Jerome E. Kaufmann, Karen L. Schwitters
Publisher:Cengage Learning

Glencoe Algebra 1, Student Edition, 9780079039897...
Algebra
ISBN:9780079039897
Author:Carter
Publisher:McGraw Hill

Holt Mcdougal Larson Pre-algebra: Student Edition...
Algebra
ISBN:9780547587776
Author:HOLT MCDOUGAL
Publisher:HOLT MCDOUGAL

College Algebra (MindTap Course List)
Algebra
ISBN:9781305652231
Author:R. David Gustafson, Jeff Hughes
Publisher:Cengage Learning

Elementary Geometry for College Students
Geometry
ISBN:9781285195698
Author:Daniel C. Alexander, Geralyn M. Koeberlein
Publisher:Cengage Learning