function [f, df]= Associate_Overall_lognormal_musigma(VV)   
%% This script seems to work in the current setting. 
globalvars_edgefile;

mupara=VV(1);
logsigmasquare=VV(2);
sigmasquare=exp(logsigmasquare);
    
%% Update the Transfer Relationship Closeness:
[sender1,receiver1]=find(EdgeConn);
senderknow1=Expvectors(sender1,:);
receiverknow1=Expvectors(receiver1,:);

variablelog1=sqrt(sum((senderknow1-receiverknow1).^2,2))./sqrt(sum(senderknow1.^2,2));
normvar1=log(variablelog1);


valfij=1./variablelog1 .*exp(-(normvar1-mupara).^2./(2*sigmasquare));

sparseTRC=sparse(sender1, receiver1, valfij, size(EdgeConn,1), size(EdgeConn,2));
TRC_ij=full(sparseTRC);
delta0=sparse(sender1, receiver1,normvar1,size(EdgeConn,1), size(EdgeConn,2));
delta=full(delta0);

posi=find(sum(EdgeConn,2));
TRCtran=EdgeConn;
TRCtran(posi,:)=TRC_ij(posi,:)./(sum(TRC_ij(posi,:),2)*ones(1,NumExperts));
%% End updating TRC_ij and TRCtran
  
[betaparanew1]=UpdateBetaPara_speedbeta_lognormal(betaparanew, uint32(ExpTransTktFile), betaindxflag, TRC_ij);
betaparanew=betaparanew1;  %% must update the beta first  

 
  
   
   %[d_edgeknowledge, f]=TermsWrtWandExpvec_speedbeta_edgefile_maxopt_exporder(EdgeKnowledge,intEdgeKnowIndx,intExpTransTktFile, betaparanew, phi ,Tktvectors, betaindxflag,uint32(NumExperts),diffmatrix);
[d_para, f]=TermsWrtMuandSigmaSquare_speedbeta(uint32(ExpTransTktFile), betaparanew, phi, betaindxflag,uint32(NumExperts),TRCtran,delta,sigmasquare,mupara,TRC_ij);

    
    
df=d_para(:);
 
  
  %% It is different from the original caculation A.1, figure out why 

  
  


  
  

