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: LTM.m
    path of file: ./repos/MatlabFunc/TopicModel
    
    the code of the file until where you have to start completion: function [Pz_d_final, Pw_z_final, LogL_final, nIter_final] = LTM(X, K, W, options, Pz_d, Pw_z)
% Locally-consistent Topic Modeling (LTM) using EM
%
% Notation:
% X ... (mFea x nSmp) term-document matrix (observed data)
%       X(i,j) stores number of occurrences of word i in document j
%
%       mFea  ... number of words (vocabulary size)
%       nSmp  ... number of documents
% K     ... number of topics
% W     ... weight matrix of the affinity graph 
%
% options ... Structure holding all settings
%           options.alpha:  local consistency regularization prameter (default 1000)
%                           if alpha=0, LTM boils down to the ordinary
%                           PLSA. Please see [1] for details.
%
% You only need to provide the above four inputs.
%
% Pz_d ... P(z|d)
% Pw_z ... P(w|z) corresponds to beta parameter in LDA
%
%
% References:
% [1] Deng Cai, Xuanhui Wang, Xiaofei He, "Probabilistic Dyadic Data
% Analysis with Local and Global Consistency", ICML 2009.
%
%
% This software is based on the implementation of pLSA from
%
% Peter Gehler

    
function [Pz_d_final, Pw_z_final, LogL_final, nIter_final] = LTM(X, K, W, options, Pz_d, Pw_z)
% Locally-consistent Topic Modeling (LTM) using EM
%
% Notation:
% X ... (mFea x nSmp) term-document matrix (observed data)
%       X(i,j) stores number of occurrences of word i in document j
%
%       mFea  ... number of words (vocabulary size)
%       nSmp  ... number of documents
% K     ... number of topics
% W     ... weight matrix of the affinity graph 
%
% options ... Structure holding all settings
%           options.alpha:  local consistency regularization prameter (default 1000)
%                           if alpha=0, LTM boils down to the ordinary
%                           PLSA. Please see [1] for details.
%
% You only need to provide the above four inputs.
%
% Pz_d ... P(z|d)
% Pw_z ... P(w|z) corresponds to beta parameter in LDA
%
%
% References:
% [1] Deng Cai, Xuanhui Wang, Xiaofei He, "Probabilistic Dyadic Data
% Analysis with Local and Global Consistency", ICML 2009.
%
%
% This software is based on the implementation of pLSA from
%
% Peter Gehler
% Max Planck Institute for biological Cybernetics
% pgehler@tuebingen.mpg.de
% Feb 2006
% http://www.kyb.mpg.de/bs/people/pgehler/code/index.html
%
%   
%   version 2.0 --Jan/2012 
%   version 1.0 --Nov/2008 
%   
%
%   Written by Deng Cai (dengcai AT gmail.com)
%
ZERO_OFFSET = 1e-200;

differror = 1e-7;
if isfield(options,'error')
    differror = options.error;
end