Find the maximum of the function in R
问题 I have the following function. Let F(.) is the cumulative distribution function of the gamma distribution with shape = 1 and rate =1 . The denominator is the survival function S(X) = 1 - F(X) . The g(x) is the mean residual life function. I wrote the following function in r. x = 5 denominator = 1 -pgamma(x, 1, 1) numerator = function(t) (1 - pgamma(t, 1, 1)) intnum = integrate(numerator , x, Inf) frac = intnum$value/denominator frac How can I find the maximum of the function g(x) for all