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: icatb_optimal5fun.m
    path of file: ./repos/bspm/thirdparty/MIALAB/GroupICATv4.0a/icatb/icatb_analysis_functions/icatb_algorithms
    
    the code of the file until where you have to start completion: function [name,a,b] = icatb_optimal5fun(data)
% [name,a,b] = icatb_optimal5fun(data)
% Created By: Baoming Hong, IOL, CT, USA
% Data: 1-08-04
%**************************************************************************
%*** the parameters: data denotes the estimated 1-D signal. f denotes the
%    estimated denisity function value, x is the corresponding axis values
%*** parameter b: distribution sacle factor parameter; a: mean/translation
%    factor, here not considering mean factor for Laplace, Logistic
%    Gaussian distribution, except for Logweilbull distribution...
%***                  Hong, Baoming, July 9, 2003
%*************************************************************************
% calcualte mean, variance, skewness & kurtosis

    
function [name,a,b] = icatb_optimal5fun(data)
% [name,a,b] = icatb_optimal5fun(data)
% Created By: Baoming Hong, IOL, CT, USA
% Data: 1-08-04
%**************************************************************************
%*** the parameters: data denotes the estimated 1-D signal. f denotes the
%    estimated denisity function value, x is the corresponding axis values
%*** parameter b: distribution sacle factor parameter; a: mean/translation
%    factor, here not considering mean factor for Laplace, Logistic
%    Gaussian distribution, except for Logweilbull distribution...
%***                  Hong, Baoming, July 9, 2003
%*************************************************************************
% calcualte mean, variance, skewness & kurtosis
        PI = 3.1415926;
        meanS1 = mean(data');
        varS1 = var(data');
        skewS1 = skewness(data,0);
        kurS1 = kurtosis(data,0);
        b1 = sqrt(6*varS1)/3.1415926;
        a1 = meanS1 - b1*0.577215;
        
        meanS2 = mean(-data'); % for the signed data
        varS2 = var(-data');
        skewS2 = skewness(-data,0);
        kurS2 = kurtosis(-data,0);
        b2 = sqrt(6*varS2)/PI;
        a2 = meanS2 - b2*0.577215;
% now we want to estimate their distribution using kernel density estimation
       [f1, x1] = ksdensity(data);
       [f2, x2] = ksdensity(-data);   % note: the data: U=WX, probably be "signed"...
% initialization
        delt1 = zeros(4,1);
        delt2 = zeros(4,1);
        
% decide which distribution is optimal  
    for i=1:length(x1)  
         y1 = icatb_logistic_pdf(x1(i),0,1);  %%% here mean=0; var=1;
         y2 = icatb_lap_pdf(x1(i),meanS1,sqrt(varS1/2));
         y3 = normpdf(x1(i),meanS1,sqrt(varS1));
         y4 = icatb_logweibull_pdf(x1(i),a1,b1);
         delt1(1)=(y1-f1(i))^2 + delt1(1);
         delt1(2)=(y2-f1(i))^2 + delt1(2);
         delt1(3)=(y3-f1(i))^2 + delt1(3);
         delt1(4)=(y4-f1(i))^2 + delt1(4);
     end