TensorFlow Probability distributions
Every distribution in TFP has a shape, batch, and event size associated with it. The shape is the sample size; it represents independent and identically distributed draws or observations. Consider the normal distribution that we defined in the previous section:
normal = tfd.Normal(loc=0., scale=1.)
This defines a single normal distribution, with mean zero and standard deviation one. When we use the sample
function, we do a random draw from this distribution.
Notice the details regarding batch_shape
and event_shape
if you print the object normal
:
print(normal)
>>> tfp.distributions.Normal("Normal", batch_shape=[], event_shape=[], dtype=float32)
Let us try and define a second normal
object, but this time, loc
and scale
are lists:
normal_2 = tfd.Normal(loc=[0., 0.], scale=[1., 3.])
print(normal_2)
>>> tfp.distributions.Normal("Normal", batch_shape=[2], event_shape=[], dtype...