How to set confidence intervals in MATLAB?

I want to build confidence interval charts in MATLAB, but I don’t know how to do it at all. I have data in a .xls file.

Can someone give me a hint or does anyone know the commands for building CI?

+3
source share
3 answers

I'm not sure what you mean by confidence interval graphs, but this is an example of how to build a two-way 95% CI normal distribution:

alpha = 0.05;          % significance level
mu = 10;               % mean
sigma = 2;             % std
cutoff1 = norminv(alpha, mu, sigma);
cutoff2 = norminv(1-alpha, mu, sigma);
x = [linspace(mu-4*sigma,cutoff1), ...
    linspace(cutoff1,cutoff2), ...
    linspace(cutoff2,mu+4*sigma)];
y = normpdf(x, mu, sigma);
plot(x,y)

xlo = [x(x<=cutoff1) cutoff1];
ylo = [y(x<=cutoff1) 0];
patch(xlo, ylo, 'b')

xhi = [cutoff2 x(x>=cutoff2)];
yhi = [0 y(x>=cutoff2)];
patch(xhi, yhi, 'b')

plot

+5
source

See these m files on the Matlab file server:

+3
source

, .

enter image description here

% Get some random data
x       = linspace(0.3, pi-0.3, 10);
Data    = sin(x) + randn(1, 10)/10;
Data_sd = 0.1+randn(1,10)/30;

% prepare it for the fill function
x_ax    = 1:10;
X_plot  = [x_ax, fliplr(x_ax)];
Y_plot  = [Data-1.96.*Data_sd, fliplr(Data+1.96.*Data_sd)];

% plot a line + confidence bands
hold on 
plot(x_ax, Data, 'blue', 'LineWidth', 1.2)
fill(X_plot, Y_plot , 1,....
        'facecolor','blue', ...
        'edgecolor','none', ...
        'facealpha', 0.3);
hold off 

:

+1

Source: https://habr.com/ru/post/1720670/


All Articles