<jupyter_start><jupyter_text>Bob's Pizza Probability  The use of total expectation law in a discrete case*Every day Bob goes to the pizza shop, orders a slice of pizza, andpicks a topping—pepper, pepperoni, pineapple, prawns, or prosciutto—uniformly at random. On the day that Bob first picks pineapple, find the expected number of prior days in which he picked pepperoni.***The analytic solution is provided in the notes**<jupyter_code>import numpy as np

topping = ["pepper", "pepperoni", "pineapple", "prawns", "prosciutto"]

def pineapple_pizza():
    global topping
    pepperoni_days=0 #num of prior days Bob ordered pepperoni
    current = np.random.choice(topping)
    while (current!="pineapple"):
        if current=="pepperoni":
            pepperoni_days+=1
        current = np.random.choice(topping)
    return pepperoni_days
# Run it 1000 times and calculate the mean of pepperoni_days
dayslst = [pineapple_pizza() for i in range(10000)]
print("Estimated expectation is: {}".format(np.mean(dayslst)))<jupyter_output>Estimated expectation is: 0.992
{'fraction_non_alphanumeric': 0.08945386064030132, 'fraction_numerical': 0.014124293785310734, 'mean_word_length': 4.84065934065934, 'pattern_counts': {'":': 1, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '455678', 'license': 'MIT', 'n_tokens_mistral': 339, 'n_tokens_neox': 317, 'n_words': 117, 'path': 'Pizza_for_Bob.ipynb', 'repo_name': 'Lonitch/stochastic-process', 'size': '1062'}