Help to model fitting a distribution of weights in weighted graphs : power or exponential law?

useful, but not sufficient for me to understand which law may best describe my model.

I have a weighted network, where weights are cosine similarity between nodes. The similarity is computed in function of the degree of the two nodes and the intersection of common neighbours.

I want now to describe the distribution of weights of a node's neighbours. If you can point to resources for a theoretical description of what I may expect, super thank you!!

I am learning about fitting, logPlots and square error standard deviation: how to make best use of Mathematica tools in this exercise to analytically find out best fitting model ?

Please bear with me and let me tell you how I am reasoning about by showing an example.

# sorted distribution of weights of a node's neighbours, from more similar to less similar
data = {1000, 435, 427, 401, 383, 372, 372, 370, 369, 364, 359, 336,
335, 334, 330, 314, 314, 311, 305, 305, 300, 295, 294, 289, 285,
283, 273, 273, 272, 272, 270, 269, 261, 252, 241, 234, 219, 216,
216, 211, 208, 206, 206, 202, 199, 192, 185, 181, 180, 176, 163,
162, 155, 155, 150, 146, 145, 144, 143, 138, 136, 129, 122, 119,
117, 105, 98, 95, 86, 83, 77, 77, 70, 44, 42, 32, 26};

# normalise the weights [0,1]
dataModel = Table[{i, data[[i]]/1000}, {i, Length[data]}];

# plot my distribution
ListLinePlot[data]

# let's try fitting!
# Exponential or Power law ? Or would you suggest another one?


Attempt 1 : I try to plot an Exp and Power model, and plot the residuals. Here it seems to me more of a Power law

model = a Exp[-k x] + c;
model = a Power[-k x] + c;

fit = FindFit[dataModel, model, {a, k, c}, x]

modelf = Function[{x}, Evaluate[model /. fit]]

Plot[modelf[x], {x, 0, Length[dataModel]},
Epilog -> Map[Point, dataModel]]

{xl, yl} = Transpose[dataModel];
residuals = yl - Map[modelf, xl];
ListPlot[residuals, Filling -> Axis, DataRange -> {Min[xl], Max[xl]},
PlotRange -> {{0, Length[data]}, All}]


Attempt 2: here it seems more an Exp distribution

model = x^k + c;
model = a/x - k^x + c;

fit = FindFit[dataModel, model, {a, k, c}, x]
modelf = Function[{x}, Evaluate[model /. fit]];
Plot[modelf[x], {x, 0, Length[dataModel]},
Epilog -> Map[Point, dataModel]]


Attempt 3 - I try to use Log Log analysis for a mix of Power and Exp types of function: a/x - x^n + c, and a/x - n^x + c

dataNormalise = Table[data[[i]]/1000, {i, Length[data]}];

fitFkt = NonlinearModelFit[dataNormalise, a/x - x^n + c, {a, n, c},
x]

fitFkt = NonlinearModelFit[dataNormalise, a/x - n^x + c, {a, n, c}, x]

Show[ListPlot[dataNormalise], Plot[fitFkt[x], {x, 0, Length[data]}]]
Show[ListPlot[Log@dataNormalise, PlotStyle -> Red],
Plot[Log@fitFkt[Power@x], {x, 0, Length[dataNormalise]}],
Frame -> True, FrameLabel -> {"log(score)", "log(Var)"},
BaseStyle -> {14, FontFamily -> "Helvetica"}]


What kind of function are a/x - n^x + c? I thought it is a kind of Exponential, since Order of n^x > ax could "approximate" to n^x.

It turns out that a/x - n^x + c seems to better fit a Log distribution of a Power law (Log@fitFkt[Power@x]) than the function a/x - x^n + c.

I am confused.

Could you help me to:

• what kind of function is a/x - n^x + c ?
• decide which model fit best my curve and best way to analytically support the choice (I tried to learn from tutorial examples)
• help me understand how do you "guess" a curve : here a/x - x^n +c seems to me a best choice but, apart that it would be a lucky guess, I would like to better understand how to compose functions, and what kind of function are and what kind of Log Log tests look at.

EDITED: comments prompt me to check if model maybe linear or not: here I include more data-points to play with it!

https://jsfiddle.net/gg4u/m3r9c7dt/1/

It includes examples from two different knowledge networks, computed with same rationale.

• To show my ignorance about how the data is generated: Are the observations from a single node? Or are nodes also also counted as neighbors? I'm trying to understand if the observations are not independent of each other or not. – JimB Oct 30 '17 at 23:54
• Is it possible you're over thinking this? Your dataModel points look very linear to me, apart from the first point being an outlier. Fitting to all but the first point: fit = LinearModelFit[Rest@dataModel, {1, x}, x]; Show[ListPlot[Rest@dataModel], Plot[fit["Function"][x], {x, 1, 76}]]. – aardvark2012 Oct 31 '17 at 0:14
• Thank you for asking @JimB The model is like this : each node is associated to a set of nodes. The similarity between nodes is computed like: en.wikipedia.org/wiki/Cosine_similarity#Ochiai_coefficient The distribution in data shows the weights of node-neighbours associated to a node. So, here weight_AB for node_B as neighbour of node_A is equivalent to node_A as neighbour of node_B. So to answer your questions, observations of neighbours' weights distribution of a node depend from each other node. – user305883 Oct 31 '17 at 8:58
• @aardvark2012 Among the functions I tried above, it seems to me that modelFit = NonlinearModelFit[dataNormalise, a/x - n^x + c, {a, n, c},  and Show[ListPlot[Log@dataNormalise, PlotStyle -> Red], Plot[Log@modelFit[Power@x], {x, 0, Length[dataNormalise]}], Frame -> True, FrameLabel -> {"log(score)", "log(Var)"}, BaseStyle -> {14, FontFamily -> "Helvetica"}] better describe data than linear model. First point is the similarity between parent node and itself. But is it correct? why Log a/x - n^x + c should fit with Log Power distribution? what kind of f(x) is a/x - n^x + c? – user305883 Oct 31 '17 at 9:10
• I'm not convinced about that n^x. a/x + b x + c gives just as good a fit (if not a little better). Unless you have a good theoretical reason for using n^x, Occam's razor suggests it's probably not the way to go. That leaves you with a / x to take care of the first node, and b x + c to take care of the rest. The fact that the first point is "the similarity between parent node and itself" suggests to me that there's no reason for it to follow the same distribution as the other points. Your nodes are just very similar to their parents, and similarity to non-parents seems linear to me. – aardvark2012 Oct 31 '17 at 10:07