how can I change the code to have only unique CDF and PDF plot?not for all samples
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
sogol bandekian
el 16 de Mayo de 2022
Respondida: Star Strider
el 16 de Mayo de 2022
mu = 1;
sigma = 5; % make the distribution as wide as we want.
N = 100;
randgeneration = randn(N,1)*sigma + mu;
pdfNormal = normpdf(randgeneration, mu, sigma);
figure;
subplot(2,2,1)
plot(randgeneration, pdfNormal);
xlabel('randomgeneration');
ylabel('pdfNormal');
subplot(2,2,2)
histogram(randgeneration);
subplot(2,2,3)
histfit(randgeneration);
subplot(2,2,4);
pd=makedist('Normal'); %create probability distribution object
cumulativedis=cdf(pd,randgeneration);
plot(randgeneration,cumulativedis,'r-.');
xlabel('randgeneration');
ylabel('CDF');
disp(mean(randgeneration));
disp(std(randgeneration))
0 comentarios
Respuesta aceptada
Star Strider
el 16 de Mayo de 2022
I am not absolutely certain what you want.
If you want one plot for the first and last subplots, rather than multiple lines in each one, sort them by first sorting ‘randgeneration’ and using that index for it and the others (the second and third subplots are histograms, so the order is irrelevant for them) —
mu = 1;
sigma = 5; % make the distribution as wide as we want.
N = 100;
randgeneration = randn(N,1)*sigma + mu;
[~,ix] = sort(randgeneration); % Create Sorting Index
pdfNormal = normpdf(randgeneration, mu, sigma);
figure;
subplot(2,2,1)
plot(randgeneration(ix), pdfNormal(ix));
xlabel('randomgeneration');
ylabel('pdfNormal');
subplot(2,2,2)
histogram(randgeneration);
subplot(2,2,3)
histfit(randgeneration);
subplot(2,2,4);
pd=makedist('Normal'); %create probability distribution object
cumulativedis=cdf(pd,randgeneration);
plot(randgeneration(ix),cumulativedis(ix),'r-.');
xlabel('randgeneration');
ylabel('CDF');
disp(mean(randgeneration));
disp(std(randgeneration))
.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Subplots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!