CDF в логарифмическом масштабе - PullRequest
0 голосов
/ 22 апреля 2020

У меня есть функция плотности вероятности, скажем, f (x), и я знаю ее CDF. Теперь я хочу работать в масштабе журнала. Я определяю g (x) = log (f (x)), как я могу определить CDF для g (x)? Я ожидаю, что при заданном значении x (x0) вероятность падения ниже x0 одинакова независимо от того, работаю ли я в необработанном или логарифмическом масштабе. Однако это не так, но меня смущает то, как это работает математически.

Чтобы уточнить, рассмотрим следующий код R:

# Given an "unormalized" standard normal distribution and its log
  f <- function(x) 2 * dnorm(x)
  lf <- function(x) 2 + dnorm(x, log = TRUE)

# Raw scale
  bounds <- c(-Inf, -1.64, 1.96, Inf)
  # Compute normalizing constant
  Kf <- integrate(f, bounds[1], bounds[4])$value
  # Equivalently
  area <- c()
  for (i in 1:(length(bounds)-1)) {
    area[i] <- integrate(f, bounds[i], bounds[i+1])$value
  }
  Kf <- sum(area) # normalising constant

  # Compute Cumulative probabilities for given values of x
  p_bw <- 0
  for (i in 1:((length(bounds))-1)) {
    p_bw[i+1] <- p_bw[i] + area[i]
  }
  cumuP <- p_bw/Kf
  all.equal(cumuP, pnorm(bounds)) # true!
  rbind(cumuP, pnorm(bounds)) # the same

# Log Scale
  # bounds <- c(-Inf, -1.64, 1.96, Inf) # does not work
  bounds <- c(-1e3, -1.64, 1.96, 1e3)
  area <- c()

  # Compute normalizing constant
  Kf <- integrate(lf, bounds[1], bounds[4])$value
  # Equivalently
  for (i in 1:(length(bounds)-1)) {
    area[i] <- integrate(lf, bounds[i], bounds[i+1])$value
  }
  Klf <- sum(area)

  # Compute Cumulative probabilities for given values of x
  p_bw <- 0
  for (i in 1:((length(bounds))-1)) {
    p_bw[i+1] <- p_bw[i] + integrate(lf, bounds[i], bounds[i+1])$value
  }
  cumuP <- p_bw/sum(area)
  cumuP
  rbind(cumuP, pnorm(bounds, log.p = TRUE)) # not the same
  log(pnorm(bounds)) # ok but I need to get here from a different route

Другими словами, вопрос просто: учитывая pdf f (x), что происходит с CDF, когда я рассматриваю log (f (x))?

Мне кажется, что я делаю неправильно определение домена ( крайности объекта bounds ) в логарифмическом масштабе.

...