Assignment 1.2.1: Writing Sample Spaces

Last updated: March 3rd, 20202020-03-03Project preview
In [2]:
import pandas as pd
import numpy as np

Writing Sample Spaces

In [3]:
toy_dataset = pd.read_csv('toy_dataset.csv')
Number City Gender Age Income Illness
0 1 Dallas Male 41 40367.0 No
1 2 Dallas Male 54 45084.0 No
2 3 Dallas Male 42 52483.0 No
3 4 Dallas Male 40 40941.0 No
4 5 Dallas Male 46 50289.0 No

Write the sample space of the following experiments. The first one is done as an example.

Experiment 1: You make a list of three of the cities to visit.

In [11]:
In [35]:
def experiment_1(): 
    cities = np.random.choice(toy_dataset['City'].unique(),3,replace=False).tolist()
    return cities
In [57]:
['San Diego', 'Mountain View', 'Boston']
In [72]:
all_cities = toy_dataset['City'].unique().tolist()
indexes = range(len(all_cities))
sample_space = {(all_cities[i],all_cities[j],all_cities[k]) 
                for i in indexes 
                for j in indexes[i+1:]
                for k in indexes[j+1:]}
In [77]:
{('Boston', 'San Diego', 'Austin'),
 ('Boston', 'Washington D.C.', 'Austin'),
 ('Boston', 'Washington D.C.', 'San Diego'),
 ('Dallas', 'Boston', 'Austin'),
 ('Dallas', 'Boston', 'San Diego'),
 ('Dallas', 'Boston', 'Washington D.C.'),
 ('Dallas', 'Los Angeles', 'Austin'),
 ('Dallas', 'Los Angeles', 'Boston'),
 ('Dallas', 'Los Angeles', 'Mountain View'),
 ('Dallas', 'Los Angeles', 'San Diego'),
 ('Dallas', 'Los Angeles', 'Washington D.C.'),
 ('Dallas', 'Mountain View', 'Austin'),
 ('Dallas', 'Mountain View', 'Boston'),
 ('Dallas', 'Mountain View', 'San Diego'),
 ('Dallas', 'Mountain View', 'Washington D.C.'),
 ('Dallas', 'New York City', 'Austin'),
 ('Dallas', 'New York City', 'Boston'),
 ('Dallas', 'New York City', 'Los Angeles'),
 ('Dallas', 'New York City', 'Mountain View'),
 ('Dallas', 'New York City', 'San Diego'),
 ('Dallas', 'New York City', 'Washington D.C.'),
 ('Dallas', 'San Diego', 'Austin'),
 ('Dallas', 'Washington D.C.', 'Austin'),
 ('Dallas', 'Washington D.C.', 'San Diego'),
 ('Los Angeles', 'Boston', 'Austin'),
 ('Los Angeles', 'Boston', 'San Diego'),
 ('Los Angeles', 'Boston', 'Washington D.C.'),
 ('Los Angeles', 'Mountain View', 'Austin'),
 ('Los Angeles', 'Mountain View', 'Boston'),
 ('Los Angeles', 'Mountain View', 'San Diego'),
 ('Los Angeles', 'Mountain View', 'Washington D.C.'),
 ('Los Angeles', 'San Diego', 'Austin'),
 ('Los Angeles', 'Washington D.C.', 'Austin'),
 ('Los Angeles', 'Washington D.C.', 'San Diego'),
 ('Mountain View', 'Boston', 'Austin'),
 ('Mountain View', 'Boston', 'San Diego'),
 ('Mountain View', 'Boston', 'Washington D.C.'),
 ('Mountain View', 'San Diego', 'Austin'),
 ('Mountain View', 'Washington D.C.', 'Austin'),
 ('Mountain View', 'Washington D.C.', 'San Diego'),
 ('New York City', 'Boston', 'Austin'),
 ('New York City', 'Boston', 'San Diego'),
 ('New York City', 'Boston', 'Washington D.C.'),
 ('New York City', 'Los Angeles', 'Austin'),
 ('New York City', 'Los Angeles', 'Boston'),
 ('New York City', 'Los Angeles', 'Mountain View'),
 ('New York City', 'Los Angeles', 'San Diego'),
 ('New York City', 'Los Angeles', 'Washington D.C.'),
 ('New York City', 'Mountain View', 'Austin'),
 ('New York City', 'Mountain View', 'Boston'),
 ('New York City', 'Mountain View', 'San Diego'),
 ('New York City', 'Mountain View', 'Washington D.C.'),
 ('New York City', 'San Diego', 'Austin'),
 ('New York City', 'Washington D.C.', 'Austin'),
 ('New York City', 'Washington D.C.', 'San Diego'),
 ('Washington D.C.', 'San Diego', 'Austin')}
In [ ]:
Notebooks AI
Notebooks AI Profile20060