<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Probability is 
How likely something is to happen.
Let's start with obligatory example of coin-toss<br>
Here is our virtual coin so that everyone can see it
Step1:  Seems like it will take endless time click everyone and record it to prove as we increase n then probability of Heads is going to be
Step2:  Still taking lot of time to get 0.5 probability. Lets try it with Python
Simulating coin-toss experiment with Python
Step3:  For n=100000
Step4:  Exercise 1
<ASSISTANT_TASK:>
Python Code:
from IPython.display import HTML
HTML('<iframe src="https://nipunsadvilkar.github.io/coin-flip/" width="100%" height="700px" scrolling="no" style="margin-top: -70px;" frameborder="0"></iframe>')
Explanation: Probability is 
How likely something is to happen.
Let's start with obligatory example of coin-toss<br>
Here is our virtual coin so that everyone can see it:<br>
https://nipunsadvilkar.github.io/coin-flip/
End of explanation
from IPython.display import HTML
HTML('<iframe src="http://localhost/Seeing-Theory/basic-probability/index.html#first" width="100%" height="700px" scrolling="no" style="margin-top: -70px;" frameborder="0"></iframe>')
Explanation: Seems like it will take endless time click everyone and record it to prove as we increase n then probability of Heads is going to be: $$\frac{1}{2}$$ 
<br>and same for Tails.<br> Lets try with a different way - another virtual coin flipping and comparing it with theoretical probability of Heads and Tails $$\frac{1}{2}$$
End of explanation
%matplotlib inline
from utils import comp_prob_inference
import matplotlib.pyplot as plt
comp_prob_inference.flip_fair_coin()
flips = comp_prob_inference.flip_fair_coins(100)
comp_prob_inference.plot_discrete_histogram(flips)
comp_prob_inference.plot_discrete_histogram(flips, frequency=True)
Explanation: Still taking lot of time to get 0.5 probability. Lets try it with Python
Simulating coin-toss experiment with Python
End of explanation
# TODO: make this plot more beautiful(with grids and color) and should be able to show value on hover
flips = comp_prob_inference.flip_fair_coins(100000)
comp_prob_inference.plot_discrete_histogram(flips, frequency=True)
n = 100000
heads_so_far = 0
fraction_of_heads = []
for i in range(n):
    if comp_prob_inference.flip_fair_coin() == 'heads':
        heads_so_far += 1
    fraction_of_heads.append(heads_so_far / (i+1))
plt.figure(figsize=(8, 4))
plt.plot(range(1, n+1), fraction_of_heads)
plt.xlabel('Number of flips')
plt.ylabel('Fraction of heads')
Explanation: For n=100000
End of explanation
from IPython.core.pylabtools import figsize
import numpy as np
from matplotlib import pyplot as plt
figsize(11, 9)
import scipy.stats as stats
dist = stats.beta
n_trials = [0, 1, 2, 3, 4, 5, 8, 15, 50, 500]
data = stats.bernoulli.rvs(0.5, size=n_trials[-1])
x = np.linspace(0, 1, 100)
# For the already prepared, I'm using Binomial's conj. prior.
for k, N in enumerate(n_trials):
    sx = plt.subplot(len(n_trials)/2, 2, k+1)
    plt.xlabel("$p$, probability of heads") \
        if k in [0, len(n_trials)-1] else None
    plt.setp(sx.get_yticklabels(), visible=False)
    heads = data[:N].sum()
    y = dist.pdf(x, 1 + heads, 1 + N - heads)
    plt.plot(x, y, label="observe %d tosses,\n %d heads" % (N, heads))
    plt.fill_between(x, 0, y, color="#348ABD", alpha=0.4)
    plt.vlines(0.5, 0, 4, color="k", linestyles="--", lw=1)
    leg = plt.legend()
    leg.get_frame().set_alpha(0.4)
    plt.autoscale(tight=True)
plt.suptitle("Bayesian updating of posterior probabilities",
             y=1.02,
             fontsize=14)
plt.tight_layout()
Explanation: Exercise 1:
Do the same simulation for die experiment. You should get stable line at 1/6 when number of throws is higher(~n=10K).
End of explanation
<END_TASK>