Confidence intervals in Plots (Normal distribution)
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I would like to know how to plot the 68% confidence interval of a Gaussian in such a way the resulting image looks similar to this one:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/164961/image.png)
I am trying to do that with R, but I want to resort to Matlab again for my research and I want to see its abilities for statistics. I would compute the histogram as follows. The input comes from the CODAchain1.txt attached.
ic_table_file1 = 'CODAchain1.txt';
%%Read tables
codachain = load(ic_table_file1);
%%Length params
snum=1000;
media=mean(codachain(1:snum,2));
sdev=std(codachain(1:snum,2));
vector1=codachain(1:snum,2);
vector1=sort(vector1);
%Histogram
figure(2);
hold on;
min_bin=min(vector1);
max_bin=max(vector1);
inc_bin=(max_bin-min_bin)/40;
binranges = min_bin:inc_bin:max_bin;
[bincounts,ind] = histc(vector1(:),binranges);
sumatot=sum(bincounts(:));
bar(binranges,bincounts/sumatot,'m');
mu=media;
sigma=sdev;
analytic = min_bin:inc_bin:max_bin;
Y = normpdf(analytic,mu,sigma);
sumatotY=sum(Y(:));
plot(analytic,Y/sumatotY);
xlim([min_bin max_bin])
I don't know how would I be able to make the confidence interval that appears in the first image.
Thank you very much.
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Histograms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!