Borrar filtros
Borrar filtros

plot pdf along with data

1 visualización (últimos 30 días)
Rini
Rini el 28 de Sept. de 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);

Respuestas (0)

Categorías

Más información sobre MATLAB Report Generator en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by