Closed maelle closed 3 months ago
I wonder if there is a rounding problem in R base? See the example below.
set.seed(2024)
n <- 8
g <- sample_forestfire(n, fw.prob = 0.37, bw.factor = 0.32 / 0.37)
dd1 <- degree_distribution(g, mode = "in")
dd2 <- degree_distribution(g, mode = "out")
# No warning.
Eps <- .Machine$longdouble.eps
base::plot(seq(along.with = dd1) - 1 + Eps, dd1 + Eps, log = "xy")
It is not a rounding error. Zero is not a valid value for a log="xy" plot. I don't understand why this has worked in the past, assuming it worked.
In R vectors are one-based. The "-1" in the plot and point statement should be omitted. To eliminate the y value warnings, replace 0 in dd1, dd2 by a value one step below the nonzero minimum of dd1, dd2.
g <- sample_forestfire(10000, fw.prob = 0.37, bw.factor = 0.32 / 0.37)
dd1 <- degree_distribution(g, mode = "in")
dd2 <- degree_distribution(g, mode = "out")
dd1[abs(dd1) < .Machine$double.eps] <- min(dd1[dd1 > 0])/ exp(1) # <---- below minimum
dd2[abs(dd2) < .Machine$double.eps] <- min(dd2[dd2 > 0])/ exp(1) # <---- below minimum
plot(seq(along.with = dd1), dd1, log = "xy")
points(seq(along.with = dd2) , dd2, col = 2, pch = 2)
thank you! this makes sense. I'll try simplifying the example.
# The forest fire model produces graphs with a heavy tail degree distribution.
# Note that some in- or out-degrees are zero which will be excluded from the logarithmic plot.
Thank you @szhorvat!
Thanks again @clpippel!
Created on 2024-03-11 with reprex v2.1.0