tests/test_binning.R

library("mcPAFit")
alpha <- 0.8
net <- simple_net(time_step = 10000, p_const = 0.2, alpha = alpha)
stats <- get_my_statistics(net)

alpha_timeline <- estimate_alpha(net)
alpha_timeline

deg_vec <- table(stats$final_deg)
degree <- as.integer(names(deg_vec))

bin_vec <- binning(stats$final_deg)
result_bin <- rep(0,length(bin_vec$bin_hist) - 1)
for (i in 1:length(result_bin))
    result_bin[i] <- sum(bin_vec$bin_hist[(i+1):
                         length(bin_vec$bin_hist)]) / bin_vec$bin_hist[i]  
plot(bin_vec$center_bin[-length(bin_vec$center_bin)],result_bin, log = "xy")

result <- empirical_estimate(stats$final_deg)
result_perfect <- empirical_estimate_perfect(net)

y_min <- min(result$A,result_perfect$A)
y_max <- max(result$A,result_perfect$A)

plot(result$k, result$A, log = "xy", pch = 20,
     ylim = c(y_min,y_max),
     xlab = "Degree", ylab = "Attachment rate")
lines(result$k,result$k^alpha)
points(result_perfect$k, result_perfect$A, pch = 20,col = "blue")
thongphamthe/mcPAFit documentation built on May 20, 2019, 10:23 p.m.