plot pdf along with data
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have a 1D array generated from Gaussian mixtures and the estimated mean and variance and mixing weight for each component. How can I plot the data along with the pdf curves for each component. I tried the following code but it produces only the curves which do not fit within the range.
X is the 1D array.
lineStyles={'--b','--g','--r','--c','--m','--y'};
minVal = min(X);
maxVal = max(X);
plotRange = minVal:(maxVal-minVal)/100:maxVal;
hist(X,plotRange);
hold on;
totalProb = zeros(1,length(plotRange));
for i=1:length(model.m) % no. of components. m is estimated mean and W is the inverse covariance matrix
probs = normpdf(plotRange, model.m(i),1./exp(model.logW(i)));
probs = probs./sum(probs);
finalProbs = model.alpha(i)*length(X)*probs; % alpha is the mixing weight for each component
plot(plotRange,finalProbs,lineStyles{mod(i,6)+1},'LineWidth',2);
totalProb = totalProb + finalProbs;
end
plot(plotRange, totalProb, '-k','LineWidth',3);
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur MATLAB Report Generator dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!