Path damping coefficients

One way of interpreting our Random alpha PageRank model is in terms of path damping coefficients. In this experiment, we plot the path damping coefficients for a series of distributions and show how these coefficients influence actual paths in the graph.

Recall that the weight of a path of length $k$ was

To implement this routine in the code we compute the moments for a distribution, and then difference them.

Contents

Setup the experiment

This experiment should be run from the rapr/experiments/damping directory

cwd = pwd;
dirtail = 'experiments/damping';
if strcmp(cwd(end-length(dirtail)+1:end),dirtail) == 0
    warning('rapr:dir','%s should be executed from rapr/%s\n',mfilename,dirtail);
end
addpath('../../matlab'); % ensure we have the RAPr codes available

All of our models for this case will be defined in terms of their beta parameters. (These are the same parameters as in ../density/driver_beta_density.m)

params = [
      0,   0, 0.6, 0.9   % uniform [0,6,0.9]
      2,  16,   0,   1   % skewed right
      1,   1, 0.1, 0.9   % equicentric
   -0.5,-0.5, 0.2, 0.7   % bi-modal
];

Plot the density functions

For reference, we repeat the code to plot the density functions from the ../density/driver_beta_density.m function.

s={'-.','-','--',':'}; c={[1 0.5 0.5],[0.5 0.5 1],[0 0.75 0.5],[1 0 0.25]};
figure(1); clf; hold on; lgn={}; hs=[];to={'FontSize',14};set(gcf,'Color',[1 1 1]);
for i=1:size(params,1)
  a=params(i,1);b=params(i,2); l=params(i,3); r=params(i,4);
  f = @(x) (1./(r-l))*betapdf((x-l)/(r-l),b+1,a+1);
  ls={'LineStyle',s{i},'Color',c{i}};[x,y]=fplot(f,[l,r]);h=plot(x,y,ls{:});
  line([l l],[0,f(l)],ls{:}); line([r r],[0,f(r)],ls{:});
  lgn{end+1}=sprintf('Beta(%g,%g,%g,%g)',a,b,l,r); hs(end+1)=h;
end
xlim([0 1]); ylim([0,7]);axis off; pbaspect([2,1,1]); line([0 1],[0 0],'Color',[0 0 0]);
legend(hs,lgn,'Location','NorthWest'); text(0,-0.3,'0',to{:});text(1,-0.3,'1',to{:});

Generate the moments and path damping coefficients

All our code uses the "alphadist" function to abstract the actual distribution out of many functions. We can use the alphadist function in this case to get the moments of each distribution and then difference the moments to get the path damping coefficients.

First, we'll show the behavior of the head of the path damping coefficients (the behavior up to about 1e-6)

% Set the number of coefficients to compute
N=1e3;

% Display the plot, the colors and styles should be matched to the previous
% plot to ensure consistency for all the experiments.
s={'-.','-','--',':'}; c={[1 0.5 0.5],[0.5 0.5 1],[0 0.75 0.5],[1 0 0.25]};
figure(2); clf; cla;  lgn={}; lss={'LineWidth',1};
for i=1:size(params,1)
    a=params(i,1);b=params(i,2); l=params(i,3); r=params(i,4);
    d=alphadist('beta',a,b,l,r); uk=d.mf(N); pd=-diff(uk);
    lgn{end+1}=sprintf('Beta(%g,%g,%g,%g)',a,b,l,r);
    loglog(1:N,pd,'LineStyle',s{i},'Color',c{i},lss{:}); hold on;
end
legend(lgn,'Location','NorthEast'); ylim([1e-6,1e-0]); box off;
pbaspect([2.5,1,1]); print(gcf,sprintf('beta-damping.eps'),'-depsc2');

Now, we'll show the tail behavior. Computing the moments this far can take a while in the case when the distribution is not centered at 0. So for this case, we precompute, then display

N=1e5; pds=zeros(size(params,1),N);
for i=1:size(params,1),
    a=params(i,1);b=params(i,2); l=params(i,3); r=params(i,4);
    d=alphadist('beta',a,b,l,r); uk=d.mf(N); pds(i,:)=-diff(uk);
end

save 'damping-moments.mat' pds params

Draw the plot

% Display the plot, the colors and styles should be matched to the previous
% plot to ensure consistency for all the experiments.
s={'-.','-','--',':'}; c={[1 0.5 0.5],[0.5 0.5 1],[0 0.75 0.5],[1 0 0.25]};
figure(3); clf; cla;  lgn={}; lss={'LineWidth',1};
for i=1:size(params,1)
    a=params(i,1);b=params(i,2); l=params(i,3); r=params(i,4);
    lgn{end+1}=sprintf('Beta(%g,%g,%g,%g)',a,b,l,r);
    loglog(1:N,pds(i,:),'LineStyle',s{i},'Color',c{i},lss{:}); hold on;
end
legend(lgn,'Location','NorthEast'); ylim([1e-16,1e-0]); box off;
pbaspect([3,1,1]); print(gcf,sprintf('beta-damping-tail.eps'),'-depsc2');

Plot the coefficients along with the powers of the matrix

While the path damping coefficients give the influence of the random parameter A on the model, another way to look at the data is the actual terms in the summation for the expectation. Recall that

So the next set of plots shows the terms

for each power $j$.

For this experiment, we need to load a matrix

% First, we compute the Markov chain weight of all paths up to length Nt
load('../../data/example-small.mat');
n = size(P,1); v = ones(n,1)./n; Ptiv=v; Nt=2e2; PW=zeros(n,Nt);
for i=1:Nt, PW(:,i)=Ptiv; y = P'*Ptiv; Ptiv=y+(1-sum(y)).*v; end

Plot the raw powers of the matrix P.

figure(4); loglog(PW','k'); ylim([1e-6,1]); pbaspect([2 1 1]); xlim([1 Nt]); box off;

Now, we plot all the elements of

on the same scale.

lss={'LineWidth',1}; set(0,'DefaultAxesLineStyleOrder',{'-','-.','--',':'});
for i=1:size(params,1)
    ns=PW*diag(sparse(pds(i,1:Nt))); figure(i+4); clf; cla;
    h=loglog(ns','k',lss{:}); ylim([1e-6,1]); pbaspect([2 1 1]); xlim([1 Nt]);
    box off; print(gcf,sprintf('damping-all-pages-%i.eps',i),'-depsc2');
end

This plot shows that there are two natural groups of pages from each distribution.

Plot the same information, but individually per page. These plots are less informative because they don't show the nice overlap between the different pages.

xlims=[1 Nt]; ylims=[1e-6,1];
for i=1:size(params,1)
    ns=PW*diag(sparse(pds(i,1:Nt))); figure(i+4); clf; cla
    for p=1:size(ns,1)
        subplot(6,1,p);
        semilogy(ns(p,:),'k-','LineWidth',1);
        xlim(xlims); ylim(ylims);
         pbaspect([8,1,1]);
        box off;
        ylabel(sprintf('x_%d',p));
        if (p<6) set(gca,'XTickLabel',{}); set(gca,'YTickLabel',{}); end
        %if (p==6) box off; else axis off; end
        line(xlims, [1e-6 1e-6],'Color',[0 0 0]);
        line([1 1],ylims,'Color',[0 0 0]);
    end
    print(gcf,sprintf('damping-by-page-%i.eps',i),'-depsc2');
end