问题
From this source, I am trying to reproduce the following plot:
Earlier, I posted a question regarding the log10-log10 plot of the lognormal distribution, and got an answer here:
# lognormal base log10 pdf, w is in log10
lognorm_base10 <- function(w, mu, sigma) {
log10(exp(1)) / (sqrt(2*pi*sigma^2) * 10^w) * exp(- (w - mu)^2 / (2 * sigma^2))
}
# Generate data for mu = 0, sigma = 10
x = seq(0, 10, length.out = 101)
y = lognorm_base10(x[2:101], 0, 10)
I thought overlapping the power law was going to be easy with p(x) = c * x^-gamma
, where c = 0.03
and gamma = 1
.
However, this is not the case, getting something as disparate as
# Generating the power law density curve:
alpha <- -1
C <- 0.03
z <- log10(C) + alpha * log10(x[2:101])
plot(x[2:101], log10(y), type = "l")
lines(x[2:101], z, type= 'l', col=2)
I can get a line as log(p(x)) = log C -alpha * log(x):
but not if I intend to keep the same x axis, ranging from 0 to 10 to plot both densities in one single plot.
Multiple logarithmic combinations haven't solved the issue. What am I missing?
来源:https://stackoverflow.com/questions/47048035/plotting-area-of-overlap-lognormal-and-power-law-distributions