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: ft_statfun_cohensd.m
    path of file: ./repos/fieldtrip/statfun
    
    the code of the file until where you have to start completion: function stat = ft_statfun_cohensd(cfg, dat, design)

% FT_STATFUN_COHENSD computes the effect size according to Cohen's d. This function
% supports both unpaired and paired designs.
%
% The table below contains descriptors for magnitudes of Cohen's d.
%   Very small  0.01
%   Small       0.20
%   Medium      0.50
%   Large       0.80
%   Very large  1.20
%   Huge        2.00
%
% Use this function by calling one of the high-level statistics functions as
%   [stat] = ft_timelockstatistics(cfg, timelock1, timelock2, ...)
%   [stat] = ft_freqstatistics(cfg, freq1, freq2, ...)
%   [stat] = ft_sourcestatistics(cfg, source1, source2, ...)

    
function stat = ft_statfun_cohensd(cfg, dat, design)

% FT_STATFUN_COHENSD computes the effect size according to Cohen's d. This function
% supports both unpaired and paired designs.
%
% The table below contains descriptors for magnitudes of Cohen's d.
%   Very small  0.01
%   Small       0.20
%   Medium      0.50
%   Large       0.80
%   Very large  1.20
%   Huge        2.00
%
% Use this function by calling one of the high-level statistics functions as
%   [stat] = ft_timelockstatistics(cfg, timelock1, timelock2, ...)
%   [stat] = ft_freqstatistics(cfg, freq1, freq2, ...)
%   [stat] = ft_sourcestatistics(cfg, source1, source2, ...)
% with the following configuration option:
%   cfg.statistic = 'ft_statfun_cohensd'
%
% The experimental design is specified as:
%   cfg.ivar  = independ