Skip to content

Commit

Permalink
Fixed error in surprisal calculation for normal distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
robjhyndman committed Nov 13, 2024
1 parent 3312024 commit 0a395c2
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions R/surprisal_prob.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ surprisal_gpd_prob <- function(s, threshold_p) {

# Surprisal probabilities for normal distributions
surprisal_normal_prob <- function(s, distribution) {
mu <- mean(distribution)
sigma2 <- distributional::variance(distribution)
x <- sqrt(2 * s - log(2 * pi * sigma2))
z <- (x - mu)/sqrt(sigma2)
z <- sqrt(2 * s - log(2 * pi * sigma2))
2 * (1 - stats::pnorm(abs(z)))
}

Expand Down

0 comments on commit 0a395c2

Please sign in to comment.