R/gumbel.R

### Gumbel distributions: borrowed from VGAM.
### amended to make dgumb(-Inf) = 0

dgumbel <- function(x, location = 0, scale = 1, log = FALSE) {
  if (!is.logical(log.arg <- log) || length(log) != 1)
    stop("bad input for argument 'log'")
  zedd <- (x - location) / scale
  logdensity <- -zedd - exp(-zedd) - log(scale)
  logdensity[is.infinite(x)] <- -Inf
                           # works for both +Inf and -Inf
  if(log.arg)
     logdensity
  else {
     exp(logdensity)
  }
}

pgumbel <- function(q, location = 0, scale = 1) {
  answer <- exp(-exp(-(q - location) / scale))
  answer[scale <= 0] <- NaN
  answer
}

Try the intReg package in your browser

Any scripts or data that you put into this service are public.

intReg documentation built on May 2, 2019, 4:43 p.m.