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: bayes_get_probabilities_2010.m
    path of file: ./repos/CanlabCore/CanlabCore/Statistics_tools
    
    the code of the file until where you have to start completion: function [priors_Pt, pa1_given_t, pa0_given_t, varargout] = bayes_get_probabilities_2010(Y, Xi, k)
% :Usage:
% ::
%
%     [priors_Pt, pa1_given_t, pa0_given_t, pt_given_act1, pt_given_act0, pa1_given_not_t] = bayes_get_probabilities_2010(Y, Xi, k)
%
% :Inputs:
%
%   **k:**
%        is regularization param, biases P(activity | task class) towards 0.5
%
%   **kY:**
%        is data matrix, obs x features, 1/0 (active/not)
%
%   **kXi:**
%        is task indicator matrix
%
% This is a sub-function of classify_naive_bayes.m
% For complete help, see classify_naive_bayes.m
%
% ..
%    tor wager, oct 07
% ..

[nobs, nfeatures] = size(Y);
nclasses = size(Xi, 2);

% priors_Pt and evidence: Marginal probability estimates
% -----------------------------------------------------
sumx = sum(Xi);          % number of obs in each class
N = sum(sumx);          % total obs
repsum = sumx(ones(nfeatures, 1), :);

% priors_Pt, p(t) for each of t tasks
% assume Xi are task indicators, must be zero or one
priors_Pt = sumx ./ N;


%priors_Pt = sum(Xi) ./ sum(Xi(:));


% evidence, p(a) for each activation state S = {0, 1}

% Note: Only return this in 'full' output mode, because classification can be
% (is) made on the likelihood * p(t), which is proportional to p(t | a)
% also, this way, we can accumulate likelihood based on the dist. of all
% the data, and apply the priors_Pt only once.

% % % no need to save?

    
function [priors_Pt, pa1_given_t, pa0_given_t, varargout] = bayes_get_probabilities_2010(Y, Xi, k)
% :Usage:
% ::
%
%     [priors_Pt, pa1_given_t, pa0_given_t, pt_given_act1, pt_given_act0, pa1_given_not_t] = bayes_get_probabilities_2010(Y, Xi, k)
%
% :Inputs:
%
%   **k:**
%        is regularization param, biases P(activity | task class) towards 0.5
%
%   **kY:**
%        is data matrix, obs x features, 1/0 (active/not)
%
%   **kXi:**
%        is task indicator matrix
%
% This is a sub-function of classify_naive_bayes.m
% For complete help, see classify_naive_bayes.m
%
% ..
%    tor wager, oct 07
% ..

[nobs, nfeatures] = size(Y);
nclasses = size(Xi, 2);

% priors_Pt and evidence: Marginal probability estimates
% -----------------------------------------------------
sumx = sum(Xi);          % number of obs in each class
N = sum(sumx);          % total obs
repsum = sumx(ones(nfeatures, 1), :);

% priors_Pt, p(t) for each of t tasks
% assume Xi are task indicators, must be zero or one
priors_Pt = sumx ./ N;


%priors_Pt = sum(Xi) ./ sum(Xi(:));


% evidence, p(a) for each activation state S = {0, 1}

% Note: Only return this in 'full' output mode, because classification can be
% (is) made on the likelihood * p(t), which is proportional to p(t | a)
% also, this way, we can accumulate likelihood based on the dist. of all
% the data, and apply the priors_Pt only once.

% % % no need to save?
% % evidence_yes = sum(Y) ./ N;
% % evidence_no = 1 - evidence_yes;

% Likelihoods and posteriors: conditional probabilities
% -----------------------------------------------------

% likelihoods: p(activity | task)
xcount = Y' * Xi;       % activation count for each task
xnotcount = repsum - xcount;

% k is regularization param, biases towards 0.5 (2 classes) or 1/# classes
pa1_given_t = (xcount + k) ./ (nclasses*k + repsum); %(repmat(sumx, nfeatures, 1));

pa0_given_t = (xnotcount + k) ./ (nclasses*k + repsum); %(repmat(sumx, nfeatures, 1));


% % % Likelihood ratio
% % evidence_yes = (sum(Y) ./ nobs)';
% % evidence_yes = evidence_yes(:, ones(1, nclasses));
% % % add .1 to regularize...
% % lr = ( (pa1_given_t + .1) ./ (evidence_yes + .1) ) - 1;

%%% need to apply priors_Pt only once!! Not to each voxel. Don't need to
%%% return full posterior for each voxel.
% posteriors: p(task | activity)
if nargout > 3

    notY = ~Y;
    sumv = sum(Y);
    sumnotv = sum(notY);

    pt_given_act1 = xcount ./ (sumv(ones(2, 1), :)');
    pt_given_act0 = (notY' * Xi) ./ (sumnotv(ones(2, 1), :)');

    pt_given_act1(pt_given_act1 == 0) = .001;
    pt_given_act1(pt_given_act1 == 1) = .999;

    pt_given_act0(pt_given_act0 == 0) = .001;
    pt_given_act0(pt_given_act0 == 1) = .999;
    
    varargout{1} = pt_given_act1;
    varargout{2} = pt_given_act0;
end