# Help requested - Mixture model posterior predictive plot

**URL:** <https://discourse.pymc.io/t/help-requested-mixture-model-posterior-predictive-plot/6225>\
**Category:** Questions\
**Created:** [November 6, 2020, 11:28am UTC](https://discourse.pymc.io/t/help-requested-mixture-model-posterior-predictive-plot/6225 "2020-11-06T11:28:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmp1](https://avatars.discourse-cdn.com/v4/letter/c/977dab/32.png) [@cmp1](https://discourse.pymc.io/u/cmp1)\
**Post date:** [November 6, 2020, 11:28am UTC](https://discourse.pymc.io/t/help-requested-mixture-model-posterior-predictive-plot/6225/1 "2020-11-06T11:28:26Z")

</div>

I am quite new to Pymc3 and currently trying to estimate the density of the below sales data distribution as a two-component mixture (two Mv Normals):

![download](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/2X/3/3325cd42406347317dabd88ade72013f6962b5fe.png)

Everything runs fine and the model converges well after checking BFMI/GR stats.

When I sample from the posterior distribution and attempt to plot I, however, I end up with a very strange distribution. Is this something I am doing incorrectly, or is this because I have done a poor job of specifying my priors?

Code:

```
# Model
N_SAMPLES = 2000

observed_sales = df.sales

with pm.Model() as model:
    lam1 = pm.Exponential('lam1', lam=1)
    lam2 = pm.Exponential('lam2', lam=1)
    pois1 = pm.Poisson.dist(mu=lam1)
    pois2 = pm.Poisson.dist(mu=lam2)
    w = pm.Dirichlet('w', a=np.array([1, 1]))
    like = pm.Mixture('like', w=w, comp_dists=[pois1, pois2], observed=observed_sales)

    sales_demand_trace = pm.sample(N_SAMPLES, tune=2000, random_seed=SEED, cores=1)
    prior = pm.sample_prior_predictive()
    posterior_predictive = pm.sample_posterior_predictive(sales_demand_trace)

# Draw posterior samples
y_pred = pm.sample_posterior_predictive(sales_demand_trace, 10000, model)

# Plot posterior
data_ppc = az.from_pymc3(
    trace=sales_demand_trace[1000:], 
    posterior_predictive=y_pred)

az.plot_ppc(data_ppc, num_pp_samples=100, figsize=(12,6))

```

All help very much appreciated.
