You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: effect_size_CI.m
    path of file: ./repos/CanlabCore/CanlabCore/Statistics_tools
    
    the code of the file until where you have to start completion: function [d_CI, P, P_CI] = effect_size_CI(d, n, varargin)
% Confidence interval for effect size (Cohen's d or Hedges' g) using noncentral t distribution
%
% d_CI = effect_size_CI(d, n, [dfe])
%
% - This function assumes dfe is n-1 unless specified otherwise
% - Assumes normally distributed data
%
% Outputs:
% d_CI = 95% confidence interval for d, 2-tailed
% P = P-value for the input d
% P_CI = 95% confidence interval for P, 2-tailed
%
% :Inputs:
%
%   **d:**
%        Effect size estimate
%
%   **n:**
%        Sample size
%
% :Optional Inputs:
%   **'method', 'noncentralt':**
%        Use noncentral t method instead of Hedges and Olkin
%
%   **'n2', [integer]:**
%        Sample size for 2nd group
%        In this case, effect_size_CI returns the CI for the two-sample
%        effect size.  n is the first group's sample size.
%
%   **'alphaval', [numeric value]:**
%        Alpha value, acceptable false positive rate
%
%   **'tails', [1 or 2]:**
%        1 for one-tailed, 2 for two-tailed tests/CIs. Default = 2
%
%   **'dfe', [value]:**
%        Manually entered error degrees of freedom
%
% :Outputs:
%
%   **d_CI:**
%        95% confidence interval for d, 2-tailed by default
%
%   **P:**
%        P-value for the input d
%
%   **P_CI:**
%        P-values for lower and upper 95% confidence interval bounds on d, 2-tailed by default
%
%
% :Notes:
% ::
% --------------------------------------------------
%
% There are multiple methods for this and formulas are suggested by
% Hedges (1981), Theory for Glass's Estimator of Effect Size and Related Estimators
%
% This function implements two methods:
% 1.Hedges-Olkin, a parametric calculation that is quick to implement
% - the default
%

    
function [d_CI, P, P_CI] = effect_size_CI(d, n, varargin)
% Confidence interval for effect size (Cohen's d or Hedges' g) using noncentral t distribution
%
% d_CI = effect_size_CI(d, n, [dfe])
%
% - This function assumes dfe is n-1 unless specified otherwise
% - Assumes normally distributed data
%
% Outputs:
% d_CI = 95% confidence interval for d, 2-tailed
% P = P-value for the input d
% P_CI = 95% confidence interval for P, 2-tailed
%
% :Inputs:
%
%   **d:**
%        Effect size estimate
%
%   **n:**
%        Sample size
%
% :Optional Inputs:
%   **'method', 'noncentralt':**
%        Use noncentral t method instead of Hedges and Olkin
%
%   **'n2', [integer]:**
%        Sample size for 2nd group
%        In this case, effect_size_CI returns the CI for the two-sample
%        effect size.  n is the first group's sample size.
%
%   **'alphaval', [numeric value]:**
%        Alpha value, acceptable false positive rate
%
%   **'tails', [1 or 2]:**
%        1 for one-tailed, 2 for two-tailed tests/CIs. Default = 2
%
%   **'dfe', [value]:**
%        Manually entered error degrees of freedom
%
% :Outputs:
%
%   **d_CI:**
%        95% confidence interval for d, 2-tailed by default
%
%   **P:**
%        P-value for the input d
%
%   **P_CI:**
%        P-values for lower and upper 95% confidence interval bounds on d, 2-tailed by default
%
%
% :Notes:
% ::
% --------------------------------------------------
%
% There are multiple methods for this and formulas are suggested by
% Hedges (1981), Theory for Glass's Estimator of Effect Size and Related Estimators
%
% This function implements two methods:
% 1.Hedges-Olkin, a parametric calculation that is quick to implement
% - the default
%
% Hedges LV, Olkin I. Statistical methods for meta-analysis. Orlando: Academic Press Inc; 2014. p. 86.
% https://www.statisticshowto.datasciencecentral.com/hedges-g/
% https://books.google.com/books?id=5obZnfK5pbsC&pg=PA10&dq=hedges+g&hl=en&sa=X&ved=0ahUKEwjLl6eL4NPRAhVowYMKHQzGDpsQ6AEIGjAA#v=onepage&q=hedges%20g&f=false
%
% 2. A version based on the non-central t-distribution
% - this is an "alpha version" and may not be correct
% the method suggested by David C. Howell, University of Vermont
% Using the CDF of the non-central t distribution for the observed t score
% https://www.uvm.edu/~statdhtx/methods8/Supplements/MISC/Confidence%20Intervals%20on%20Effects/Effect%20Sizes%20Confidence%20Intervals.html
%
% NOTE: Confidence intervals are not symmetric.
%
% Effect size toolbox:
% https://www.mathworks.com/matlabcentral/fileexchange/32398-hhentschke-measures-of-effect-size-toolbox
%
% :See also:
% ::
% --------------------------------------------------
% power_calc.m
%
% Formulas
% p2t = @(p, dfe, tails) abs(tinv(p ./ tails, dfe));
% p2d = @(p, dfmodel, dfe, tails) abs(tinv(p ./ tails, dfe)) ./ sqrt(dfmodel + dfe);  % dfmodel + dfe = N observations
% d2t = @(d, dfmodel, dfe) d .* sqrt(dfmodel+dfe);
% d2p = @(d, dfmodel, dfe, tails) tails .* (1 - tcdf(d .* sqrt(dfmodel+dfe), dfe));
% d2p = @(d, n, dfe, tails) tails .* (1 - tcdf(d .* sqrt(n), dfe));
%
%
% :Examples:
% ::
% ---------------------------------------
% e.g.,
% n = 100; d = 0.65;
% d_CI = effect_size_CI(d, n);
%
% [d_CI, P, P_CI] = effect_size_CI(0.5, 30)
%
% A two-sample version of the above (wider confidence interval):
% [d_CI, P, P_CI] = effect_size_CI(0.5, 30, 'n2', 30)
%
% % Generate 1 and 2-sample values for a range of effect sizes and plot
% % ---------------------------------------
% dvals = [0.01:0.05:2]';
% n = 20;
% [d_CI1, d_CI2] = deal(zeros(length(dvals), 2));
% P = [];
% P2 = []; % 2-group case
% 
% for i = 1:length(dvals)
% 
%     [d_CI1(i, :), P(i, 1)] = effect_size_CI(dvals(i), n);
%  
%     [d_CI2(i, :), P2(i, 1)] = effect_size_CI(dvals(i), n, 'n2', n);
% 
% end