MATLAB: Plotting the true pdf of a finite mixture

mixture plot

Hey all,
I would like to know how to plot the true ( Theoretical and not a kernel estiamtion) pdf for a mixture of two distributions ( Gamma and Singh-Maddala). Any suggestions?
If it helps; the code in R is:
u=seq(0,1,by=.0001)
plot(u,0.95*dgamma(u,0.5,1)+0.05*dsinmad(u,1.97,2.8,1.7), type="l")
Thank you in advance.

Best Answer

This is pretty straightforward if you have the Statistics and Machine Learning Toolbox:
pd_gamma = makedist('gamma','a',0.5,'b',1);
pd_burr = makedist('burr','alpha',1.97,'c',2.8,'k',1.7);
x = 0:0.0001:1;
y_gamma = pdf(pd_gamma,x);
y_burr = pdf(pd_burr,x);
y = 0.95*y_gamma + 0.05*y_burr;
figure
plot(x,y)
I'm not certain that the parameterization is the same as it is in R, so you should check that.
If you do not have that toolbox, you do have some other options. You would need to define the pdf functions yourself, and then plot them.
Here is an example of plotting a function like that:
x = 0:0.01:1;
f = @(x) exp(-x.^2);
figure
plot(x,f(x))