Reproduced
has been doing uncertainty analysis, many times will involve the concept of the confidence interval, but has not been able to have a clear understanding, today finally from the online search data, specifically verified the meaning of the confidence interval.
95% confidence interval (Confidence Interval,ci): When the 95% confidence interval for an estimate is "A-B", it can be understood that we have 95% confidence (Confidence) that the average of the sample is between a and a, and the probability of an error is 5%.
Sometimes also say 90%,99% confidence interval, the specific meaning can refer to 95% confidence interval.
The confidence interval is calculated in the following way:
(1) When the sample mean value (M) and standard deviation (ST) are known:
Lower confidence interval: a=m-n*st; Maximum confidence interval: A=m + n*st;
n=1.645 when the 90% confidence interval is obtained
n=1.96 when the 95% confidence interval is obtained
n=2.576 when the 99% confidence interval is obtained
(2) When the estimated distribution is obtained by using Monte Carlo method (Monte Carlo):
First, all the estimated samples are sorted, the confidence interval lower limit: A is the lower% percentile value after sorting; Upper limit of confidence interval: B is the upper% percentile value after sorting.
Lower=5 upper=95 When the 90% confidence interval is obtained;
lower=2.5 upper=97.5 When the 95% confidence interval is obtained
lower=0.5 upper=99.5 When the 99% confidence interval is obtained
When the sample is large enough, the results obtained from (1) and (2) are basically equal.
Reference: http://140.116.72.80/~smallko/ns2/confidence_interval.htm
With just prepare Matlab to find the confidence interval source code:
....................................................................................................................................
Definition of%%% confidence interval 90%,95%,99%
Clear
Clc
SAMPLEDATA=RANDN (10000,1);
a=0.01; %0.01 corresponds to 99% confidence interval, 0.05 corresponds to 95% confidence interval, 0.1 corresponds to 90% confidence interval
If a==0.01
n=2.576; % 2.576 corresponds to 99% confidence interval, 1.96 corresponds to 95% confidence interval, 1.645 corresponds to 90% confidence interval
ElseIf a==0.05
n=1.96;
ElseIf a==0.1
n=1.645;
End
% calculation corresponds to percentile value
Meana=mean (Sampledata);
STDA=STD (Sampledata);
Sorta=sort (Sampledata); % of data from small to large sort
Leng=size (sampledata,1);
CIa (1:2,1) =[sorta (LENG*A/2); Sorta (leng* (1-A/2))];
% use formula to calculate confidence intervals
CIf (1:2,1) =[MEANA-N*STDA;MEANA+N*STDA];
Confidence interval (Confidence Interval)