Modelling the combination of three distributions (not linear combination)

Lets say I want to model a distribution which empirically I can see is a combination of three PDFs in one. For example in the data below you can see a Gamma distribution to the left, a Uniform in the middle, then another (different) gamma to the far right:

image

Note that this is not simply the addition of three RVs - in some % of the time the RV belongs to Gamma, sometimes Uniform, and sometimes the other Gamma, but not a linear combination of the three. How would be the best way to go about modelling this in pymc3?

Check out pymc.Mixture — PyMC 0+untagged.345.g2bd0611.dirty documentation

I’m not sure if this addresses what I’m trying to do. For example if I had three normal distributions, if I used a mixture the result would be one normal distribution. What I would really want is a distribution with three “peaks” (three superimposed distributions), rather that one distribution which is the result of summing three distributions. Am I misunderstanding the functionality of the link you sent?

Mixture does what you want. It interpolates between the components.

import matplotlib.pyplot as plt
import pymc as pm

x = pm.Mixture.dist(
  w=[1/3]*3, 
  comp_dists=[
    pm.Normal.dist(-10), 
    pm.Normal.dist(0), 
    pm.Normal.dist(10),
  ],
)
plt.hist(pm.draw(x, 10_000), bins=100)

Edit: I get an error uploading the picture, but you should be able to reproduce on your end