search for: integral

Displaying 20 results from an estimated 18404 matches for "integral".

2008 Aug 21
2
Help Regarding 'integrate'
...n defined as: f<-function(x){ return(dchisq(x,9,77)*((13.5/x)^5)*exp(-13.5/x)) } Numerically integrating this function, I observed a couple of things: A) Integrating the function f over the entire positive real line gives an error: > integrate(f,0,Inf) Error in integrate(f, 0, Inf) : the integral is probably divergent B) Increasing the interval of integration actually decreases the value of the integral: > integrate(f,0,10^5) 9.813968e-06 with absolute error < 1.9e-05 > integrate(f,0,10^6) 4.62233e-319 with absolute error < 4.6e-319 Since the function f is uniformly positive...
2009 Jan 24
2
Different values for double integral
Dear R useRs, i have the function f1(x, y, z) which i want to integrate for x and y. On the one hand i do this by first integrating for x and then for y, on the other hand i do this the other way round and i wondering why i doesn't get the same result each way? z <- c(80, 20, 40, 30) "f1" <- function(x, y, z) {dgamma(cumsum(z)[-length(z)], shape=x, rate=y)}
2009 Apr 22
2
integrate lgamma from 0 to Inf
Dear R users, i try to integrate lgamma from 0 to Inf. But here i get the message "roundoff error is detected in the extrapolation table", if i use 1.0e120 instead of Inf the computation works, but this is against the suggestion of integrates help information to use Inf explicitly. Using stirlings approximation doesnt bring the solution too. ## Stirlings approximation lgammaApprox
2004 Mar 02
2
Problem with Integrate
....8) 1.831093e-73 with absolute error < 3.6e-73 > integrate(PLN1, -1000, 1000, Count=73, mu=2, sigma2=2.8) Error in integrate(PLN1, -1000, 1000, Count = 73, mu = 2, sigma2 = 2.8): non-finite function value In addition: Warning message: NaNs produced in: dpois(x, lambda, log) So, the integral gets smaller, and then gives an error. I then tried entering the formula directly: PLN2 <- function(LL, Count, mu, sigma2) { exp(-LL-(log(LL)-mu)^2/(2*sigma2))*LL^(Count-1)/(gamma(Count+1)*sqrt(2*pi*sigma2)) } > integrate(PLN2, 0, 100, Count=73, mu=2, sigma2=2.8) 0.001287821 with absolute...
2013 Jan 17
1
Fwd: Re: Inconsisten declaration of ssh_aes_ctr_iv()
Oops, I meant to CC the list on this. -- Iain ----- Forwarded message from Iain Morgan <Iain.Morgan at nasa.gov> ----- Date: Thu, 17 Jan 2013 14:51:01 -0800 From: Iain Morgan <Iain.Morgan at nasa.gov> To: Damien Miller <djm at mindrot.org> Subject: Re: Inconsisten declaration of ssh_aes_ctr_iv() On Wed, Jan 16, 2013 at 21:26:39 -0600, Damien Miller wrote: > On Mon, 14 Jan
2018 Mar 23
1
Integrate erros on certain functions
In the help for ?integrate: >When integrating over infinite intervals do so explicitly, rather than just using a large number as the endpoint. This increases the chance of a correct answer ? any function whose integral over an infinite interval is finite must be near zero for most of that interval. I understand that and there are examples such as: ## a slowly-convergent integral integrand <- function(x) {1/((x+1)*sqrt(x))} integrate(integrand, lower = 0, upper = Inf) ## don't do this if you really want...
2012 Jul 24
4
Integrate(dnorm) with different mean and standard deviation help
I'm trying to provide different parameters to the integrate function for various probability functions. I'm using dnorm as the simplest example here. For instance integrate(dnorm, -1.96, 1.96) produces the correct answer for a normal distribution with mean 0 and standard deviation 1. I've tried two ways to use mean=2.0 and standard deviation 1, but with no luck. The examples follow.
2012 Mar 23
3
R numerical integration
Hi all, Is there any other packages to do numerical integration other than the default 'integrate'? Basically, I am integrating: integrate(function(x) dnorm(x,mu,sigma)/(1+exp(-x)),-Inf,Inf)$value The integration is ok provided sigma is >0. However, when mu=-1.645074 and sigma=17535.26 It stopped working. On the other hand, Maple gives me a value of 0.5005299403. It is an
2011 Jun 06
2
Taking Integral and Optimization using Integrate, Optim and maxNR
Dear All, Hello! I have some questoins in R programming as follows: Question 1- How to take the integral of this function with respect to y, such that x would appear in the output after taking integral. f(x,y)=(0.1766*exp(-exp(y+lnx))*-exp(y+lnx))/(1-exp(-exp(y+lnx))) y in (-6.907,-1.246) It is doable in maple but not in R. At least I could not find the way. p.s: result from maple is: g(x)=dilog*e...
2007 Mar 08
2
integrate function (PR#9557)
...eck Version: R 2.2.0 OS: Windows Submission from: (NULL) (157.193.193.152) I think there is a bug when using integrate for integrating a function which is 0 in a whole sub-interval. For example: #define uniform function f<-function(x){ifelse(x<1,0,ifelse(x<3,1,0))} #this is the correct integral integrate(f,-10,10) #here there is a problem integrate(f,-50,50) integrate(f,-10,50) integrate(f,-50,10) integrate(f,-50,50,sub=10000) # I noticed this for a more complex function, but as you see even for a trivial # function there is a serious problem
2008 Aug 26
2
Problem with Integrate for NEF-HS distribution
I need to calcuate the cumulative probability for the Natural Exponential Family - Hyperbolic secant distribution with a parameter theta between -pi/2 and pi/2. The integration should be between 0 and 1 as it is a probability. The function "integrate" works fine when the absolute value of theta is not too large. That is, the NEF-HS distribution is not too skewed. However, once the
2015 Apr 09
3
typo in R-exts.html section 6.9
In 'Writing R Extensions' section 6.9 there is the paragraph There are interfaces (defined in header R_ext/Applic.h) for definite and for indefinite integrals. ?Indefinite? means that at least one of the integration boundaries is not finite. An indefinite integral usually means an antiderivative, not an integral over an infinite spread. Should that first sentence end with 'for integrals over finite and infinite ranges' and the second sentence...
2007 Aug 23
1
nls() and numerical integration (e.g. integrate()) working together?
Dear List-Members, since 3 weeks I have been heavily working on reproducing the results of an economic paper. The method there uses the numerical solution of an integral within nonlinear least squares. Within the integrand there is also some parameter to estimate. Is that in the end possible to implement in R [Originally it was done in GAUSS]? I'm nearly into giving up. I constucted an example to showing the problems I face. I have three questions - related t...
2005 Jul 28
3
using integrate with optimize nested in the integration
Hi guys im having a problem getting R to numerically integrate for some function, say f(bhat)*optimize(G(bhat)), over bhat. Where id like to integrate this over some finite range, so that here as we integrate over bhat optimize would return a different optimum. For instance consider this simple example for which I cannot get R to return the desired result: f <- function(bhat) exp(bhat) g
2011 Jan 25
3
Integration of two lines
Hello, I need to integrate the absolute difference between two lines measured on different points. # For example : x <- seq(0, 1, 1/100) f_x <- runif(101) + x y <- seq(0, 1, 1/23) f_y <- runif(24) + (1 - y) plot(x, f_x, type="l") lines(y, f_y) Then I would like to compute Integral( | f_x - f_y | )dx. (This is not the same as | Integral(f_x)dx - Integral(f_y)dx |.) Computing this integral looks non trivial. I guess I should interpolate the points of f_y over x and integrate both lines on these intervals. Even then I would miss points where the lines cross. There are functi...
2005 Jul 17
1
Strange problems with lattice plots
...ons of them. Variable year varies from 1990 to 2004. Variables V_A2 and V_A3 contain floating point values and several NAs (as sometimes measurements were unavailable). I draw plots: xyplot((V_A3/25)~year| factor(month,labels=c(month.name,"Annual mean", "Annual integral","Integral (Jan-Mar)","Integral (Apr-Jun)","Integral (Jul-Sep)","Integral (Oct-Dec)", "Integral (Jan-Feb)","Integral (Jan-Mar)","Integral (Jan-Apr)","Integral (Jan-May)","Integral (Jan-Jun)"...
2011 Mar 04
3
integrate a fuction
...e any constant. One way would be to set a value for p globally and then call integrate function: p=2 integrate(f, lower = -1, upper = 1) However, I would like to use 'integrate' inside a function, so I could call it passing p as a parameter. I tried something like this: 1> p=1 1> integral<-function(p){ 1+ integrate(f, lower = -1, upper = 1) 1+ 1+ } 1> 1> integral(2) 0 with absolute error < 1.1e-14 ,but it doesn't work as the integral of f is evaluated with p=1 (the value of the global variable p) and not with the value of p=2 when the function integral is calle...
2019 Apr 12
2
integrate over an infinite region produces wrong results depending on scaling
...is non-zero on a very small section of the negative line (like [-0.02, -0.01], where it takes huge values, and almost 0 everywhere else). R?s integrate would often return the machine epsilon as a result. So I stretch the function around the zero by an inverse of the scale parameter, compute the integral, and then divide it by the scale. Sometimes, this re-scaling also failed, so I did both if the first result was very small. Today when integration of the rescaled function suddenly yielded a value of 1.5 instead of 3.5 (not even zero). The MWE is below. cons <- -0.020374721416129591 sc <...
2007 May 24
3
Problem with numerical integration and optimization with BFGS
...tly. I estimate the parameters of the model using the monthly US unemployment rate series obtained from the Federal Reserve Bank of St. Louis. (The data is freely available from their web-based database called FRED-II). For my model, the likelihood function for each observation is the sum of three integrals. The integrand in each of these integrals is of the following form: A*exp(B+C*x-D*x^2) where A, B, C and D are constants, exp() is the exponential function and x is the variable of integration. The constants A and D are always positive; B is always negative, while there is no a priori knowledge...
2010 Dec 02
4
Integral of PDF
The integral of any probability density from -Inf to Inf should equal 1, correct? I don't understand last result below. > integrate(function(x) dnorm(x, 0,1), -Inf, Inf) 1 with absolute error < 9.4e-05 > integrate(function(x) dnorm(x, 100,10), -Inf, Inf) 1 with absolute error < 0.00012 > i...