Effacer les filtres
Effacer les filtres

plot pdf along with data

1 vue (au cours des 30 derniers jours)
Rini
Rini le 28 Sep 2016
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);

Réponses (0)

Catégories

En savoir plus sur MATLAB Report Generator dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by