function [corr_ci_lower, corr_ci_upper, rmse_lower, rmse_upper, ... 
or_lower, or_upper] = get_confidence(corrs, num_clips, rmses, outratios) 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% compute the MM test plan / MM final report's confidence interval on 
% statistics correlation, rmse & outlier ratio; on a per-clip basis. 
% ‘corrs’ is an array holding each model’s correlation 
% ‘num_clips’ is the number of clips used in the calculation 
% ‘rmses’ is an array holding each model’s RMSE 
% ‘outratios’ is an array holding each model’s outlier ratio 
% 
% The lower and upper confidence bounds are returned. 
 
temp = 0.5 * log( (1 + corrs) ./ (1 - corrs) ); 
corr_ci_lower = temp - 1.96 * sqrt(1 / (num_clips - 3)); 
corr_ci_upper = temp + 1.96 * sqrt(1 / (num_clips - 3)); 
corr_ci_lower = ((exp(2.0 * corr_ci_lower) - 1.0) ./ (exp(2 * corr_ci_lower) + 1.0)); 
corr_ci_upper = ((exp(2.0 * corr_ci_upper) - 1.0) ./ (exp(2 * corr_ci_upper) + 1.0)); 
 
rmse_lower = rmses * sqrt(num_clips-4) / sqrt( chi2inv(0.025, num_clips-4)); 
rmse_upper = rmses * sqrt(num_clips-4) / sqrt( chi2inv(0.975, num_clips-4)); 
 
or_lower = outratios + 1.96 * sqrt( outratios .* (1.0 - outratios) ./ num_clips ); 
or_upper = outratios - 1.96 * sqrt( outratios .* (1.0 - outratios) ./ num_clips ); 
