In [1]:
import tensorflow_probability as tfp
import tensorflow as tf
import collections
In [4]:
tfd = tfp.distributions
try:
tf.compat.v1.enable_eager_execution()
except ValueError:
pass
import matplotlib.pyplot as plt
In [8]:
normal_dist = tfd.Normal(loc=0,scale=1)
In [13]:
normal_dist.sample(10)
Out[13]:
In [19]:
normal_dist.log_prob(0.)
Out[19]:
In [24]:
data_normal = normal_dist.sample(100)
plt.scatter(range(len(data_normal)),data_normal,color="blue",alpha=0.4)
plt.title("Normal Distribution")
plt.show()
In [25]:
gamma_dist = tfd.Gamma(concentration=3.0,rate=2.0)
data_gamma = gamma_dist.sample(100)
In [26]:
plt.scatter(range(len(data_gamma)),data_gamma,color="blue")
plt.title("Gamma Distribution")
plt.show()
In [49]:
#normal_dist.cdf(100.0),gamma_dist.cdf(value=100.0)
import numpy as np
np.std(data_gamma)
np.std(data_normal)
Out[49]:
Here is an example typesetting mathematics in \LaTeX
\begin{equation*}
X(m,n) = \left\{\begin{array}{lr}
x(n), & \text{for } 0\leq n\leq 1\\
\frac{x(n-1)}{2}, & \text{for } 0\leq n\leq 1\\
\log_2 \left\lceil n \right\rceil \qquad & \text{for } 0\leq n\leq 1
\end{array}\right\} = xy
\end{equation*}