File size: 367 Bytes
490d970
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

pdf <- function(a, b, cuantil, pdf) {
  # To convert pmf to a function
  pdf <- gsub(" ", "", pdf)
  pdf <- substr(pdf, start=6, stop=nchar(pdf))
  pdf <- paste(pdf, ' * x^0')
  fun <- function(x) eval(parse(text=pdf))
  prob <- integrate(fun, lower=a, upper=cuantil)$value
  area <- integrate(fun, lower=a, upper=b)$value
  list(prob=prob, area=area, fun=fun)
}