简体   繁体   中英

R Language program for inverse gaussian distribution

The cumulative density function of Inverse Gaussian Distribution can be written as; F(t; µ,λ)= Φ [√((λ )/t ) (t/µ-1)]+ 〖exp〗^(2 λ⁄µ) Φ[- √(λ/t) (t/µ+1)], Where Φ show the cumulative distribution function of a standard normal distribution. plz tell me how can i write this function in R

The normal distribution is included in R. See ?qnorm for details of how to calculate quantiles of the normal distribution. It will also show you other helpful functions.

The statmod package, available from CRAN, includes the function pinvgauss() for the cumulative density function of the inverse Gaussian distribution, as well as other basic probability functions for that distribution. There is an accompanying article:

Giner, G, and Smyth, GK (2016). statmod: probability calculations for the inverse Gaussian distribution . R Journal 8(1), 339-351.

Here's a solution that uses the pnorm of the standard normal distribution.

在此处输入图像描述

pinvgauss <- function(x, mu, lambda) {
  a = sqrt(lambda/x) * (x/mu-1)
  b = exp(2*lambda/mu)
  c = -sqrt(lambda/x) * (x/mu+1)
  result = pnorm(a)+b*pnorm(c)
  return(result)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM