<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 That was exciting
Step1:  Now, we're going to simulate picking numbers out of a hat, doing it 'runs' times. The bucket_size is the number of nubmer in the hat.
Step2:  Now, we'll pick a hundred times for all hat sizes from 1 to 9999
Step3:  Now, we'll import the plotting stuff - I don't know why this warning appears for me.
Step4:  Now, we'll grab and plot tuples of (number of items in hats, chance of pulling a number starting with 1) for all hat sizes
Step5:  And we'll do the same for numbers starting with 2
Step6:  And we'll plot them on top of each other. You'll see the stochastic approach shows expected results according to
<ASSISTANT_TASK:>
Python Code:
first_digit(100)
first_digit(399)
Explanation: That was exciting
End of explanation
import random
def do_drawing(bucket_size, runs):
    digits = [first_digit(random.randint(1,bucket_size)) for x in range(runs)]
    return digits
Explanation: Now, we're going to simulate picking numbers out of a hat, doing it 'runs' times. The bucket_size is the number of nubmer in the hat.
End of explanation
import collections
counters=[(top_end, collections.Counter(do_drawing(top_end, 100))) for top_end in range(1,10000)]
Explanation: Now, we'll pick a hundred times for all hat sizes from 1 to 9999
End of explanation
import matplotlib.pyplot as plt
%matplotlib inline
Explanation: Now, we'll import the plotting stuff - I don't know why this warning appears for me.
End of explanation
one_odds = [counter[1][1] for counter in counters]
plt.semilogx(range(len(counters)), one_odds)
Explanation: Now, we'll grab and plot tuples of (number of items in hats, chance of pulling a number starting with 1) for all hat sizes
End of explanation
two_odds = [counter[1][2] for counter in counters]
plt.semilogx(range(len(counters)), two_odds)
Explanation: And we'll do the same for numbers starting with 2
End of explanation
plt.semilogx(range(len(counters)), one_odds, 'b', range(len(counters)), two_odds, 'r')
Explanation: And we'll plot them on top of each other. You'll see the stochastic approach shows expected results according to
End of explanation
<END_TASK>