<jupyter_start><jupyter_text>MITx 18.6501x - Fundamentals of Statistics  Unit 1 Introduction to statistics  Probability review: dice rolling game    Alice and Bob play a game where two fair six-sided dice are rolled.    Alice gets $1 if the sum of the numbers of the two dice is a prime number. (The number  is not prime.)Bob gets $3 if the numbers on the two dice are the same (e.g. 1-1, 2-2, …).    Who makes more money on average (i.e. in expectation)?<jupyter_code>def permutations(list_1, list_2):
    
    n_permuts = [(i,j) for i in list_1 for j in list_2]
    
    return n_permuts
dice_1 = [1, 2, 3, 4, 5, 6]
dice_2 = [1, 2, 3, 4, 5, 6]

sample_space = permutations(dice_1, dice_2)
n_sample_space = len(sample_space)

print(f"Total of possibilities are: {n_sample_space}")
import math

def check_prime(x):
    sta = 1
    for i in range(2,int(math.sqrt(x))+1): # range[2,sqrt(num)]
        if x%i == 0:
            sta = 0
            # print("Not Prime")
            return False
    # if sta == 1:
        # print("Prime")

    return True

# num = int(input("Enter the number: "))
# ret = check_prime(num)
# ret
alice_possibilities = [(i,j) for i in dice_1 for j in dice_2 if check_prime(i+j)]
print(f"Alice has {len(alice_possibilities)} possible results")
bob_possibilities = [(i,j) for i in dice_1 for j in dice_2 if i==j]
print(f"Bob has {len(bob_possibilities)} possible results")
def expectation(p, x):
    
    expect_value = p*x
    
    return expect_value
p_bob = len(bob_possibilities)/n_sample_space
p_alice = len(alice_possibilities)/n_sample_space

x_bob = 3
x_alice = 1
p_bob, p_alice, x_bob, x_alice
bob_expectation = expectation(p_bob, x_bob)
alice_expectation = expectation(p_alice, x_alice)

print(f"Bob makes on average $ {bob_expectation} and Alice makes $ {alice_expectation}")<jupyter_output>Bob makes on average $ 0.5 and Alice makes $ 0.4166666666666667<jupyter_text>Review: probability questionAssume that we observe three draws,  from a Bernoulli distribution with parameter . For example, imagine that in the model for the preferred head direction for kissing, either direction were actually equally likely and we observed three kissing couples.What is the probability of observing at least two ones, i.e., what is ?<jupyter_code># Bernouli probability mass function

def pmf(n,p):
    f = p**n*(1-p)**(1-n)
    
    return f
n = 3
p = 1/2

pmf(n, p)<jupyter_output><empty_output><jupyter_text>With the setup as in the problem above, we say a group of four people is “interesting", if there are at most five pairs who are friends. Assume that each pair of people are friends, independent of every other pair, with probability . Let  be the number of pairs that are friends in this group.What is the probability that a randomly chosen group of four people is “interesting"? (Enter your answer as a fraction (recommended) or enter as a decimal accurate to nearest .)<jupyter_code>from scipy.stats import binom
#calculate binomial probability

result = binom.pmf(k=4, n=5, p=0.5)
#Print the result
print("Binomial Probability: ",result)<jupyter_output>Binomial Probability:  0.15625<jupyter_text>P(N <= 5) = 1 - P(N=6) = 1 - (1/2)**6 = 63/64<jupyter_code>1 - binom.pmf(k=6, n=6, p=0.5)<jupyter_output><empty_output><jupyter_text>Following the model above, if 128 different people each observe one randomly chosen groups of four people, how many times on average do these observations lead to the conclusion that the person's chosen group is interesting?<jupyter_code>(1 - binom.pmf(k=6, n=6, p=0.5)) * 128<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09742441209406495, 'fraction_numerical': 0.029955207166853303, 'mean_word_length': 4.3248882265275705, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '483780', 'license': 'MIT', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1188, 'n_words': 438, 'path': 'Lecture 1 - What is statistics.ipynb', 'repo_name': 'CarolGonz/fundamentals_of_statistics_mitx', 'size': '3572'}