[R] Normal and Poisson tail area expectations in R

Charles C. Berry cberry at tajo.ucsd.edu
Wed Jun 13 23:29:21 CEST 2007

On Wed, 13 Jun 2007, kavindra malik wrote:

> I am interested in R functions for the following integrals / sums (expressed best I can in text)  -
> Normal: G_u(k) =  Integration_{Lower limit=k}^{Upper limit=infinity} [(u -k) f(u) d(u)], where where u is N(0,1), and f(u) is the density function.
> Poisson: G(lambda,k) = Sum_{Lower limit=k}^{Upper limit=infinity} [(x-k) p(x, lambda)] where P(x,lambda) is the Poisson prob function with parameter lambda.
> The Normal expression is very commonly used in inventory management to 
> determine safety stocks (and its tabular values can be found in some 
> texts) - and I am also looking for Poisson and/or Gamma as that'd fit 
> the situation better.
> I am wondering if there are standard functions in R that might allow me to get these values, instead of needing to do the numerical integration, etc. myself.

Not that I know of, but it is not difficult to do the integration:

> k <- 1.1 # for example
> integrate(function(x) (x-k)*dnorm(x),lower=k,upper=Inf)
0.06861951 with absolute error < 5.5e-07



>                                                    Thank you very much.
> ---------------------------------
> Sucker-punch spam with award-winning protection.
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

More information about the R-help mailing list