celestialgod

plot integral of cdf

Aug 5th, 2015
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.51 KB | None | 0 0
  1. prob_mat_1 = cbind(sort(rnorm(88)), rep(1/88, 88), cumsum(rep(1/88, 88)))
  2. prob_mat_2 = cbind(sort(rnorm(88)), rep(1/88, 88), cumsum(rep(1/88, 88)))
  3. cdf_int_f = function(prob_mat){
  4.   h = tail(prob_mat[,1], nrow(prob_mat)-1) - head(prob_mat[,1], nrow(prob_mat)-1)
  5.   u_plus_l = tail(prob_mat[,3], nrow(prob_mat)-1) + head(prob_mat[,3], nrow(prob_mat)-1)
  6.   cumsum(h*u_plus_l/2)
  7. }
  8. plot(prob_mat[2:nrow(prob_mat_1),1], cdf_int_f(prob_mat_1), type = "l")
  9. lines(prob_mat[2:nrow(prob_mat_2),1], cdf_int_f(prob_mat_2), col = 2)
Advertisement
Add Comment
Please, Sign In to add comment