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: rvmBinEm.m
    path of file: ./repos/PRMLT/chapter09
    
    the code of the file until where you have to start completion: function [model, llh] = rvmBinEm(X, t, alpha)
% Relevance Vector Machine (ARD sparse prior) for binary classification.
% trained by empirical bayesian (type II ML) using EM.
% Input:
%   X: d x n 
    
function [w, llh, U] = logitBin(X, t, lambda, w)
% Logistic regression
[d,n] = size(X);
tol = 1e-4;
maxiter = 100;
llh = -inf(1,maxiter);
idx = (1:d)';
dg = sub2ind([d,d],idx,idx);
h = ones(1,n);
h(t==0) = -1;
a = w'*X;
for iter = 2:maxiter
    y = sigmoid(a);                     % 4.87
    r = y.*(1-y);                       % 4.98
    Xw = bsxfun(@times, X, sqrt(r));
    H = Xw*Xw';                         % 4.97
    H(dg) = H(dg)+lambda;
    U = chol(H);
    g = X*(y-t)'+lambda.*w;             % 4.96
    p = -U\(U'\g);
    wo = w;                             % 4.92
    w = wo+p;   
    a = w'*X;   
    llh(iter) = -sum(log1pexp(-h.*a))-0.5*sum(lambda.*w.^2);  % 4.89
    incr = llh(iter)-llh(iter-1);
    while incr < 0      % line search
        p = p/2;
        w = wo+p;
        a = w'*X;   
        llh(iter) = -sum(log1pexp(-h.*a))-0.5*sum(lambda.*w.^2);
        incr = llh(iter)-llh(iter-1);
    end