Confidence intervals in Contour Plots

4 次查看(过去 30 天)
I am trying to generate a contour plot that gives me the 95% and 68% interval probability. What I should obtain is the following:
where the inner circle is the 68% and the outer 95%. I am trying to do the following with the input CODAchain1.txt: the x values are from row 0-1000, and y from row 1001-2000.
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. The code I would use is the following:
ic_table_file1 = 'CODAchain1.txt';
%%Read tables
codachain = load(ic_table_file1);
%%Length params
snum=1000;
long_vec=length(codachain);
%%Computations mean
media=mean(codachain(1:snum,2));
mean2=mean(codachain(snum+1:long_vec,2));
%Standard deviation
sdev=std(codachain(1:snum,2));
sdev2=std(codachain(snum+1:long_vec,2));
%Percentage 68
percentage=0.68;
frac=int64(percentage*snum);
vector1=codachain(1:snum,2);
vector1=sort(vector1);
i_fin=snum-frac+1;
for i=1:1:i_fin
vector_res(i,1)=vector1(frac+i-1)-vector1(i);
end
minres=min(vector_res);
for i=1:1:i_fin
if (vector_res(i,1)==minres)
k_res=i;
end
end
int_min68=vector1(k_res,1);
int_max68=vector1(frac+k_res-1,1);
%Percentage 95
percentage=0.9;
frac95=percentage*snum;
i_fin95=snum-frac95+1;
for i=1:1:i_fin95
vector_res95(i,1)=vector1(frac95+i-1)-vector1(i);
end
minres95=min(vector_res95);
for i=1:1:i_fin95
if (vector_res95(i,1)==minres95)
k_res95=i;
end
end
int_min95=vector1(k_res95,1);
int_max95=vector1(frac95+k_res95-1,1);
%Contour plots
figure(3);
hold on;
k68=0;
for i=1:1:snum
if(codachain(i,2)>int_min68&&codachain(i,2)<int_max68)
k68=k68+1;
codachain68x(k68,:)=codachain(i,:);
codachain68y(k68,:)=codachain(i+snum,:);
end
end
k95=0;
for i=1:1:snum
if(codachain(i,2)>int_min95&&codachain(i,2)<int_max95)
k95=k95+1;
codachain95x(k95,:)=codachain(i,:);
codachain95y(k95,:)=codachain(i+snum,:);
end
end
x95=codachain95x(1:k95,2);
y95=codachain95y(1:k95,2);
x68=codachain68x(1:k68,2);
y68=codachain68y(1:k68,2);
xout=codachain(1:snum,2);
yout=codachain(snum+1:long_vec,2);
plot(xout,yout,'.r');
So here I obtain the distribution of the data.
Now what I would need to do is to obtain the 68% and 95% interval so that I obtain the same plot as shown in the beginning.
Thank you very much.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by