daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Mar 19th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library(tidyverse)
  2.  
  3. rmixexp <- function(n, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, m1, m2,
  4. m3, m4, m5, m6, m7, m8, m9, m10, m11) {
  5.   w1 * rexp(n, 1 / m1) +
  6.     w2 * rexp(n, 1 / m2) +
  7.     w3 * rexp(n, 1 / m2) +
  8.     w4 * rexp(n, 1 / m5) +
  9.     w5 * rexp(n, 1 / m5) +
  10.     w6 * rexp(n, 1 / m6) +
  11.     w7 * rexp(n, 1 / m7) +
  12.     w8 * rexp(n, 1 / m8) +
  13.     w9 * rexp(n, 1 / m9) +
  14.     w10 * rexp(n, 1 / m10) +
  15.     w11 * rexp(n, 1 / m11)
  16.   }
  17.  
  18. datatibble <- tibble(
  19.   w1 = c(1/11, 1/11),
  20.   w2 = c(1/11, 1/11),
  21.   w3 = c(1/11, 1/11),
  22.   w4 = c(1/11, 1/11),
  23.   w5 = c(1/11, 1/11),
  24.   w6 = c(1/11, 1/11),
  25.   w7 = c(1/11, 1/11),
  26.   w8 = c(1/11, 1/11),
  27.   w9 = c(1/11, 1/11),
  28.   w10 = c(1/11, 1/11),
  29.   w11 = c(1/11, 1/11),
  30.   m1 = c(1/11, 1/11),
  31.   m2 = c(1/11, 1/11),
  32.   m3 = c(1/11, 1/11),
  33.   m4 = c(1/11, 1/11),
  34.   m5 = c(1/11, 1/11),
  35.   m6 = c(1/11, 1/11),
  36.   m7 = c(1/11, 1/11),
  37.   m8 = c(1/11, 1/11),
  38.   m9 = c(1/11, 1/11),
  39.   m10 = c(1/11, 1/11),
  40.   m11 = c(1/11, 1/11)
  41.   )
  42.      
  43. n <- 10
  44.  
  45. loss.test <- datatibble %>% mutate(severity =
  46.                                        pmap(
  47.                                          list(n, w1, w2, w3, w4, w5,
  48.                                               w6, w7, w8, w9, w10, w11,
  49.                                               m1, m2, m3, m4, m5,
  50.                                               m6, m7, m8, m9, m10, m11),
  51.                                             function(n, w1, w2, w3, w4, w5,
  52.                                                      w6, w7, w8, w9, w10, w11,
  53.                                                      m1, m2, m3, m4, m5,
  54.                                                      m6, m7, m8, m9, m10, m11)
  55.                                               rmixexp(n, w1, w2, w3, w4, w5,
  56.                                                       w6, w7, w8, w9, w10, w11,
  57.                                                       m1, m2, m3, m4, m5,
  58.                                                       m6, m7, m8, m9, m10, m11))
  59.                                     ) %>%
  60.   mutate(severity = map(severity, ~ data.frame(severity = .x,
  61.                                                       sim = seq_along(.x))))     %>%
  62. unnest() %>% select(sim, severity)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top