Displaying 20 results from an estimated 18515 matches for "integration".
2008 Aug 21
2
Help Regarding 'integrate'
...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, B) can not occur. Also, the
theory tells me that the infinite in...
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
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 such as:
## a slowly-convergent integral
integrand
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 valu...
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)
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 theta gets large in absolute value, such as -1 as shown in the example below,...
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 omitted?
Bill Dunlap
TIBCO Software
wdunlap tibco.com
[...
2007 Aug 23
1
nls() and numerical integration (e.g. integrate()) working together?
...r 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 to three errors shown below:
1) How to make clear that in the integrand z is the integration variable and
b1 is a parameter while x1 is a data variable
2) and 3) How to set up a correct estimation of the integral?
library(stats)
y <- c(2,15,24,21,5,6,)
x1 <- c(2.21,5,3,5,2,1)
x2 <- c(4.51,6,2,11,0.4,3)
f <- function(z) {z + b1*x1}
vf <- Vectorize(f)
g <- function(z) {z +...
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
...ss 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 functions to integrate below *one* line (I'm thinking about
the trapz function in caTools).
Do you know if there is a function to do this integration properly with
two lines (and especially their absolute difference)?
Regards,
Xavier
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
...e 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 random variable is
(-Inf, 0]. The scale parameter of the distribution is quite small
(around 0.01), so often, the standard integration routine would fail to
integrate a function that 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 b...
2007 May 24
3
Problem with numerical integration and optimization with BFGS
Hi R users,
I have a couple of questions about some problems that I am facing with
regard to numerical integration and optimization of likelihood
functions. Let me provide a little background information: I am trying
to do maximum likelihood estimation of an econometric model that I have
developed recently. I estimate the parameters of the model using the
monthly US unemployment rate series obtained from the Fe...
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 <