N <- 10; s <- 0.5; y <- 1:N
proby <- dzipf(y, N = N, s = s)
plot(proby ~ y, type = "h", col = "blue", ylab = "Probability",
ylim = c(0, 0.2), main = paste("Zipf(N = ",N,", s = ",s,")", sep = ""),
lwd = 2, las = 1)
sum(proby) # Should be 1
max(abs(cumsum(proby) - pzipf(y, N = N, s = s))) # Should be 0
Run the code above in your browser using DataLab