R/Psi.R

Defines functions Psi

Psi <- function(x, y, mu, variance){
  # This function calculates
  # Psi(x,y,mu,variance) which equals to
  # P(x le Z le y) = P(Z le y) - P(Z le x)
  # where Z ~ N(mu,variance).
  #
  # Inputs:
  # x: given value
  # y: given value that is greater than or equal
  #    to x
  # mu: mean of the normal distribution
  # variance: variance of the normal distribution
  #
  # Output:
  # A value for Psi(x,y,mu,variance)
  #
  # Written by N. Ranathunga in September 2020

  sigma <- sqrt(variance)
  term1 <- stats::pnorm(y, mean = mu, sd = sigma)
  term2 <- stats::pnorm(x, mean = mu, sd = sigma)
  out <- term1 - term2

}

Try the ciuupi2 package in your browser

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

ciuupi2 documentation built on March 11, 2021, 5:06 p.m.