Section 1.1 — Introduction to data¶
This notebook contains all the code from Section 1.1 Introduction to data of the No Bullshit Guide to Statistics.
Definitions¶
Study design and randomization¶
Random selection¶
In [5]:
Copied!
import random
population = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
sample = random.sample(population, 3)
sample
import random
population = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
sample = random.sample(population, 3)
sample
Out[5]:
[6, 8, 2]
Random assignment¶
In [11]:
Copied!
def flip_coin():
r = random.random()
if r < 0.5:
print("intervention")
else:
print("control")
flip_coin()
def flip_coin():
r = random.random()
if r < 0.5:
print("intervention")
else:
print("control")
flip_coin()
control
Discussion¶
In [ ]:
Copied!