This is a handy function to compute one-tailed or two-tailed confidence intervals of any theoretical distribution fitted by MATLAB's fitdis(...) function. Simply input your data, the fitdist(...) output, and your desired confidence interval level and go to town! This functionality is really lacking in the built-in MATLAB toolbox, so feel free to use this stand-alone function. This function has been built with modularity in mind, and does not rely upon the optimization toolbox. The only specialized command used in this function is the CDF(...) command, which (I believe) is from the Statistics and Machine Learning Toolbox.
Information about the function follows:
[Confidence_Interval] = confinterval(data, Fitted_Distribution, Confidence_Interval_Level, Tolerance, Interval_Type) is a function which computes the confidence interval of a fitted distribution to a specific confidence level. This function uses an adapted bisection solution routine, and therefore should only require the Statistics and Machine Learning Toolbox.
"Data" should be a 1D vector or array of values that were used to fit a theoretical distribution to.
"Fitted_Distribution" is a distribution structure produced by MATLAB's fitdist(...) function.
"Confidence_Interval_Level" is a scale confidence level that the confidence interval will be calculated to. This value should be greater than 0 and less than 1.
"Tolerance" is the function tolerance for the confidence interval calculation. Tolerance values less than 1e-3 are recommended.
"Interval_Type" is a string input to specify the type of confidence interval. Valid inputs are: "Two Tail" for a two-tailed (centered) confidence interval, "One Tail Left" for a one-tailed confidence interval originating at the left tail of the distribution, and "One Tail Right" for a one-tailed confidence interval originating at the right tail of the distribution. If no input is selected, this option defaults to a two-tailed confidence interval.
"Confidence_Interval" is the computed confidence interval. For a two-tailed confidence interval this output takes the shape of an array of the form: [A, B]. For either one-tailed confidence intervals, this output is one number.
TJ Pilet (2021). Confidence Interval Calculator (https://www.mathworks.com/matlabcentral/fileexchange/89952-confidence-interval-calculator), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!