Reputation: 683
This might be a conceptual problem (if so, please tell me the forum to use, I'll ask it there), but I'm really stuck on this.
I want to plot a degree distribution in Matlab and a fit to the data. I suspect the degree distribution to agree to a power-law distribution from some xmin
(minimal value) on. So first I have my degree array:
s=[2 3 4 4 5 4 4 4 5 6 4 3 5 6 7 5 etc];
I calculate the probability distribution, where I am taking bins from 1 to 10:
ps=hist(s,1:10)
Subsequently I can plot this by using
loglog(ps)
which does indicate that the node degree follows a power-law distribution from node degree=4 onwards.
For the fit I am using plfit
(developed by the Santa Fe Institute, see here) to estimate the exponential component alpha
and minimal value for which the power-law behaviour holds xmin
. Now I the main thing is that I am having trouble plotting this fit to the data, it seems as if I am missing something. At the moment I am doing this to visualise the plot:
x=1:1:10;
pfit=x.^-alpha;
loglog(pfit)
Which results in
which is a lot more poor than expected (I would expect it to be very close to the data for x>xmin
).
I hope anyone has any experience with this and would be able to help me out, or even a pointer in the right direction would be very much appreciated!
Upvotes: 1
Views: 1921
Reputation: 9864
The ps
that you calculate is not the probability. To get the probability distribution you need to normalize it:
ps = ps/sum(ps);
You probably need to do the same for pfit
, this however might be provided by the library you are using.
Upvotes: 2