How to plot a mixed density function?

1 vue (au cours des 30 derniers jours)
Lukas Winek
Lukas Winek le 5 Avr 2020
Commenté : Lukas Winek le 7 Avr 2020
Hi
So, lets say I get 10000 random numbers:
-5000 from normal distribution with mean = 1 and sigma = 1
-5000 from normal distribution with mean = 4 and sigma = 1
Now I have to plot density function.
I know how to plot single density function, not a mix.
Can you help me?
Thanks,
Lukas
  1 commentaire
Torsten
Torsten le 5 Avr 2020
h = histogram(data,'Normalization','probability')

Connectez-vous pour commenter.

Réponse acceptée

Jeff Miller
Jeff Miller le 6 Avr 2020
x=-6:.01:10;
pdf1 = normpdf(x,1,1);
pdf2 = normpdf(x,4,1);
mixpdf = 0.5*pdf1 + 0.5*pdf2;
figure;
plot(x,mixpdf);

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by