search for: integrating

Displaying 20 results from an estimated 18392 matches for "integrating".

2008 Aug 21
2
Help Regarding 'integrate'
I have an R function 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...
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)} "g1" <- function(y, z) {integrate...
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
The background: I'm trying to fit a Poisson-lognormal distrbutuion to some data. This is a way of modelling species abundances: N ~ Pois(lam) log(lam) ~ N(mu, sigma2) The number of individuals are Poisson distributed with an abundance drawn from a log-normal distrbution. To fit this to data, I need to integrate out lam. In principle, I can do it this way: PLN1 <- function(lam, Count,
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 suc...
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 important line of the coding that I am doing...
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:
2007 Mar 08
2
integrate function (PR#9557)
Full_Name: Bert De Boeck 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,su...
2008 Aug 26
2
Problem with Integrate for NEF-HS distribution
...ssage for "non-finite function" when I put the lower bound as -Inf. I suspect that it is caused by the very heavy tail of the distribution. Is there any way that I can get around of this and let "integrate" work for the skewed distribution? Or is there any other function for integrating in R-package? Thanks a lot for your advice in advance! > theta<--1 > sech<-function(X) 2/(exp(-X)+exp(X)) > integrand <- function(X) {0.5*cos(theta)*exp(X*theta)*sech(pi*X/2)} > integrate(integrand, -3,1) 0.8134389 with absolute error < 7e-09 > integrate(integrand, -10...
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
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
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 |.)
2005 Jul 17
1
Strange problems with lattice plots
Dear r-help, I need to draw some lattice plots and have stuck in strange problems. I have a data frame of 405 rows: > str(dframe) `data.frame': 405 obs. of 4 variables: $ year : num 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 ... $ month: num 1 2 3 4 5 6 7 8 9 10 ... $ V_A2 : num NA NA NA NA NA ... $ V_A3 : num NA NA NA NA NA ... Variable month changes from 1 to 27
2011 Mar 04
3
integrate a fuction
I'm having a function of the form 1> f<-function(x){ 1+ 1+ return(x^p) 1+ 1+ } ,and I would like to integrate it with respect to x, where p should be 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
2019 Apr 12
2
integrate over an infinite region produces wrong results depending on scaling
Dear all, This is the first time I am posting to the r-devel list. On StackOverflow, they suggested that the strange behaviour of integrate() was more bug-like. I am providing a short version of the question (full one with plots: https://stackoverflow.com/q/55639401). Suppose one wants integrate a function that is just a product of two density functions (like gamma). The support of the
2007 May 24
3
Problem with numerical integration and optimization with BFGS
...(rho2*(-y[i]+rho1*y[i-1]-muep)*(z5))/((1-rho2^2)*sigep*sigeta) b53 <- ((z5)^2)/((-2)*(1-rho2^2)*(sigeta^2)) return((exp(b51+b52+b53))/denom) } for (i in 2:n) { # START FOR LOOP upr1 <- (y[i]-rho1*y[i-1]) upr2 <- (y[i]-y[i-1]+delta) # INTEGRATING THE THREE FUNCTIONS out1 <- integrate(f1, lower = (-1)*upr1, upper = upr1) out3 <- integrate(f3, lower = -Inf, upper = upr2) out5 <- integrate(f5, lower= -Inf, upper = upr2) pdf <- (out1$val + out3$val + out5$val) lglik[i] <- log(pdf) # LOGLIKELIHO...
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 > integrate(function(x) dnorm(x, 500,50), -Inf, Inf) 8.410947e-11 with absolute error <