# Exponential Distribution deductibles
scale = 30

f <- function(x, theta=scale) { # X ~ exp(theta)
  1/theta * exp(-x/theta)
}
F <- function(x, theta=scale) { # X ~ exp(theta)
  1 - exp(-x/theta)
}

fP <- function(x, d=50) { # X^d 
   fns = c(function(x, theta=scale) 1/theta * exp(-x/theta), 
           function(x, theta=scale) exp(-50/theta), 
           function(x) 0*x)
   breaks = c(0, 49.9999, 50.00001, 1000)
   g<-cut(x, breaks)
   unsplit(Map(function(f,x) f(x), fns, split(x, g)), g)
}
FP <- function(x, d=50) {
  fns = c(function(x, theta=scale) 1 - exp(-x/theta),
          function(x) x^0)
  breaks = c(0, 49.9999, 1000)
  g <- cut(x, breaks)
  unsplit(Map(function(f,x) f(x), fns, split(x, g)), g)
}

fL <- function(x, d=50, theta=scale) {
  1/theta * exp(-(x+d)/theta)
}
FL <- function(x, d=50, theta=scale) {
  1 - exp(-(x+d)/theta)
}

par(mfrow=c(2,3))
plot(f, 0, 200, main="X: f(x)")
plot(F, 0, 200, main="X: F(x)")
plot(fP, 0, 200, main="YP: f(x^50)")
plot(FP, 0, 200, main="YP: F(x^50)")
plot(fL, 0, 200, main="YL: f[(x-50)+]")
plot(FL, 0, 200, main="YL: F[(x-50)+]")

plot of chunk unnamed-chunk-1