Skip to content

Commit

Permalink
Add example to tf.contrib.distributions.Mixture.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 158573758
  • Loading branch information
jvdillon authored and tensorflower-gardener committed Jun 9, 2017
1 parent 7f7826b commit 0a2c50a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tensorflow/contrib/distributions/python/ops/mixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@ class Mixture(distribution.Distribution):
Methods supported include `log_prob`, `prob`, `mean`, `sample`, and
`entropy_lower_bound`.
#### Examples
```python
# Create a mixture of two Gaussians:
ds = tf.contrib.distributions
mix = 0.3
bimix_gauss = ds.Mixture(
cat=ds.Categorical(probs=[mix, 1.-mix]),
components=[
ds.Normal(loc=-1., scale=0.1),
ds.Normal(loc=+1., scale=0.5),
])
# Plot the PDF.
import matplotlib.pyplot as plt
x = tf.linspace(-2., 3., int(1e4)).eval()
plt.plot(x, bimix_gauss.prob(x).eval());
```
"""

def __init__(self,
Expand Down

0 comments on commit 0a2c50a

Please sign in to comment.