celestialgod

Weibull distribution

Aug 2nd, 2015
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.59 KB | None | 0 0
  1. x = seq(3, 3.5, by = 0.1)
  2. matplot(x, cbind(((x-1)/x)^(1/x), factorial(1/x), (log(2))^(1/x)), type = "l", ylab = "")
  3. legend("topleft",, c("Mode", "Mean", "Median"), col=1:3, lty=1:3)
  4. f = function(k) ((k-1)/k)^(1/k) - factorial(1/k)
  5. g = function(k) (log(2))^(1/k) - factorial(1/k)
  6. h = function(k) ((k-1)/k)^(1/k) - (log(2))^(1/k)
  7. ps = c(uniroot(f, c(3, 3.5))$root, uniroot(g, c(3, 3.5))$root,
  8.   uniroot(h, c(3, 3.5))$root)
  9. abline(v = ps, lwd = 2, lty = 2, col = "grey")
  10. s = function(k) factorial(3/k)-3*factorial(1/k)*(factorial(2/k)-(factorial(1/k))^2) - (factorial(1/k))^3
  11. uniroot(s, c(2, 50))
Advertisement
Add Comment
Please, Sign In to add comment