I have grafo
and I calculated the distribution of grades and grade as follows:
dd <- degree_distribution(graph)
d <- degree(graph)
From this, I estimated the Power Law
, to see if my distribution follows the "Power law":
degree = 1:max(d)
probability = dd[-1]
# Exclui zeros, pois log de 0 é infinito!
nonzero.position = which(probability != 0)
probability = probability[nonzero.position]
degree = degree[nonzero.position]
reg = lm(log(probability) ~ log(degree))
cozf = coef(reg)
#Estima a power law com base nos valores
power.law.fit = function(x) exp(cozf[[1]] + cozf[[2]] * log(x))
From this, I plotted the points and power law
using ggplot2
. Home
Resulting in the following image:
df <- data.frame(x = degree, y = probability)
print(
ggplot(df, aes(x,y,colour="Distribuição"))+
geom_point(shape = 4) +
stat_function(fun = power.law.fit, geom = "line", aes(colour="Power Law"))+
labs(title = "Grafo", subtitle = "Distribuição dos Graus",
x="K", y="P(k)", colour="Legenda")+
scale_color_brewer(palette="Dark2")
)
As you can see, my distribution does not follow Power Law
! I would like to estimate the distribution of Poisson
and plot in the same graph.
While not sure that my distribution does not follow (or follow) Poisson
, I would like to plot along with Power Law
. I have no idea how to estimate this distribution ( Poisson
) from the data, and calculate the average degree.
Can anyone help me? Thankful.
- The graph used to calculate the distribution and the degree is very large (700 thousand vertices), so I did not put the graph data. The explanation of the answer can be based on any graph.