Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. # Distribution
  2. Fx <- function(x) pnorm(x)
  3. fx <- function(x) dnorm(x)
  4.  
  5.  
  6. n <- 10
  7. # ATTENTION: 6M simulation may take some time
  8. z <- replicate(1e6, min(rnorm(n)))
  9.  
  10. # Probabiltiy z > y
  11.  
  12. prob <- function(x) {
  13. sapply(x, function(u) mean(z>u))
  14. }
  15.  
  16.  
  17. # Density
  18. fos_k <- function(x, n, k) {
  19. fact <- factorial(n) / (factorial(k-1) * factorial(n-k))
  20. fact * fx(x) * Fx(x)^(k-1) *(1-Fx(x))^(n-k)
  21. }
  22.  
  23. curve(fos_k(x, n=n, k=1), from=-1, to=1)
  24. curve(prob, add=T, col=2, from=-1, to=1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement