]
Subject: Re: [R] integrate
Hi Andy,
Thank your very much for your input. I also tried something like that
which gives a value close to 20, basically using the same trapezoidal
rule.
> sum(apply(as.matrix(seq(-10,10,by=0.1)),1,my.fcn))*0.1
[1] 20.17385
Actually my function is much more complica
To
.umd.edu>
Sent by:
cc
[EMAIL PROTECTED]
at.math.ethz.ch
at.math.ethz.ch Subject
[R] integrate
08/22/2007 02:56
On 8/22/2007 3:54 PM, Santanu Pramanik wrote:
> Hi,
> I am trying to integrate a function which is approximately constant
> over the range of the integration. The function is as follows:
That's not a function of the input mu. It includes a random component:
> my.fcn(10)
[1] 0.9786558
> my.fcn(
Hi,
I am trying to integrate a function which is approximately constant
over the range of the integration. The function is as follows:
> my.fcn = function(mu){
+ m = 1000
+ z = 0
+ z.mse = 0
+ for(i in 1:m){
+ z[i] = rnorm(1, mu, 1)
+ z.mse = z.mse + (z[i] - mu)^2
+ }
+ return(z.mse/m)
+ }
> my.
Hi,
I am trying to integrate a function which is approximately constant
over the range of the integration. The function is as follows:
> my.fcn = function(mu){
+ m = 1000
+ z = 0
+ z.mse = 0
+ for(i in 1:m){
+ z[i] = rnorm(1, mu, 1)
+ z.mse = z.mse + (z[i] - mu)^2
+ }
+ return(z.mse/m)
+ }
> my.
On 2/14/2007 9:06 PM, Haiyong Xu wrote:
> Hi there,
>
> I want to integrate a function over an irregular polygon. Is there
> any function which can implement this easily? Otherwise, I am
> thinking of divide the polygon into very small rectangles and use
> "adapt" to approximate it. Do you h
If you can integrate over a trapezoid (with horizontal base and
vertical sides) then it's fairly easy to integrate over any (non-self
intersecting) polygon. ``Draw'' a line which is below the polygon.
For each segment in the polygon, integrate over trapezoid whose base
is on the aforesaid line and
Oops. I just re-read your message and saw you were trying to
integrate a function over a polygon, not calculate its area. I'm
sorry I didn't read more carefully.
--Paul
On 2/15/07, Paul Lynch <[EMAIL PROTECTED]> wrote:
> I'm still pretty ignorant about R, but I think it might be possibl
I'm still pretty ignorant about R, but I think it might be possible to
work out an algorithm using cross products. First you would want to
subdivide the polygon into convex polygons. I haven't tried to do
that before, but it looks like it might be possible by looking at the
sign of cross product
Haiyong,
There may be better ways, but this what I'd do. (And I'm not an expert
on this.)
(a) surround the polygon with a rectangle,
(b) define, via an indicator function, a new function that is equal to
your desired function within the polygon, and zero outside it,
(c) use adapt() to integr
Hi there,
I want to integrate a function over an irregular polygon. Is there
any function which can implement this easily? Otherwise, I am
thinking of divide the polygon into very small rectangles and use
"adapt" to approximate it. Do you have any suggestions to get the
fine division? Any
As the documentation for integrate() says, the function must be vectorized
f: an R function taking a numeric first argument and returning a
numeric vector of the same length.
so you can't use sum(). You need matrix operations or an explicit loop to
add up the terms.
-th
Thanks Jim. But a narrower problem still remains.
Please, look at this new code:
lambda=c(.6,.3)
integral = function(u) {
theta = (atan(.6*u) + atan(.3*u))/2 - .1*u/2
rho = (1+.6^2*u^2)^(1/4) * (1+.3^2*u^2)^(1/4)
integrand = sin(theta)/(u*rho)
}
> integrate(integral,0,Inf)$value
[1] 1.22268
The do give the same answer, unfortunately the examples you sent were not
the same. Integral2 was missing a 'sin'. So I would assume there might be
something else wrong with your functions. You might want to try breaking it
down into smaller steps so you can see what you are doing. It definite
Hi all.
I'm trying to numerically invert the characteristic function
of a quadratic form following Imhof's (1961, Biometrika 48)
procedure.
The parameters are:
lambda=c(.6,.3,.1)
h=c(2,2,2)
sigma=c(0,0,0)
q=3
I've implemented Imhof's procedure two ways that, for me,
should give the same answer:
Aimin Yan wrote:
> I want to integrate R code to my WinEdt file.
> Can someone tell me how to do this?
> I copy R code to my WinEdt file, but it does't work.
I do not understand your question.
Are you trying to install the RWinEdt package, which acts as a plug in
for WinEdt to support writing R
I want to integrate R code to my WinEdt file.
Can someone tell me how to do this?
I copy R code to my WinEdt file, but it does't work.
Aimin Yan
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the post
> "Leo" == Leo G?rtler <[EMAIL PROTECTED]>
> on Tue, 08 Aug 2006 00:13:19 +0200 writes:
Leo> Dear R-list,
Leo> I try to transform a mathematica script to R.
Leo> ###relevant part of the Mathematica script
Leo> (* p_sv *)
Leo> dd = NN (DsD - DD^2);
Leo> lown
Thomas Lumley wrote:
> On Fri, 23 Jun 2006, Rogério Rosa da Silva wrote:
>
>> Dear All,
>>
>> My doubt about how to integrate a simple kernel density estimation
>> goes on.
>>
>> I have seen the recent posts on integrate density estimation, which seem
>> similar to my question. However, I haven
On Fri, 23 Jun 2006, Rogério Rosa da Silva wrote:
Dear All,
My doubt about how to integrate a simple kernel density estimation goes on.
I have seen the recent posts on integrate density estimation, which seem
similar to my question. However, I haven't found a solution.
I have made two simple
Dear All,
My doubt about how to integrate a simple kernel density estimation goes on.
I have seen the recent posts on integrate density estimation, which seem
similar to my question. However, I haven't found a solution.
I have made two simple kernel density estimation by:
kde.1 <-density(x
Thankyou Brian
> integrandtotest <- function(x) colSums(outer(t, x, "^"))
>
This worked fine
>in fact this integration can be done analytically (it is a
> sum of exponentials).
I know but i have another five terms in the integrand as well as the
one that was causing the trouble
Many, m
Thanks Sundar
what you suggested worked fine
> You will see that "x" is a vector and "tt[i]^x" returns a vector of the
> same length. You are trying to place this vector into "a[i]" which is
> length 1. Try the following *untested* code instead:
>
>
> integrandtotest <- function(x) {
>sum
Try to give a vector result with one element for each of element of x,
e.g.
integrandtotest <- function(x) colSums(outer(t, x, "^"))
works, although in fact this integration can be done analytically (it is a
sum of exponentials).
On Fri, 16 Sep 2005, A.Brennan wrote:
> Hi
>
> i am hav
A.Brennan wrote:
> Hi
>
> i am having a problem with the 'integrate' function
> the function i want to integrate has the form
> sum(vector^x)
>
> i have defined the function with a for loop first -
> integrandtotest <- function(x)
> {a<-rep(0,len=2)
> for (i in 1:2)
> {a[i]<-t[
Hi
i am having a problem with the 'integrate' function
the function i want to integrate has the form
sum(vector^x)
i have defined the function with a for loop first -
integrandtotest <- function(x)
{a<-rep(0,len=2)
for (i in 1:2)
{a[i]<-t[i]^x}
sum(a)
}
the resul
On Tue, 19 Jul 2005, [iso-8859-1] [EMAIL PROTECTED] wrote:
>
> beta0,eta0,n are initialized as single integer, temp is a 1 dimension array
> containing 9 integer.
>
> integrate(function(beta)
> ((beta/(eta0)^beta)^n)*prod(temp^(1-beta)*exp(-sum(temp^beta)/(eta^beta)))*(1/(sqrt(2*pi))*exp(((beta-
Hi all,
i'm new to R,
I need to modelize in R a statistic algorithm,
This algo use Weibull, normal law, linear regression, normalisation, root mean
square, to find eta and beta fitting the weibull model (to analyse few results)
and further when we will get more information apply bayes model .
th
On Tue, 11 Jan 2005, Robin Hankin wrote:
> The manpage for integrate() does not mention imaginary numbers.
The help page does say
f: an R function taking a numeric first argument and returning a
numeric vector of the same length.
and in R complex numbers are not numeric (see ?n
[apologies for possible multiple post]
Hi
The manpage for integrate() does not mention imaginary numbers.
I found the following unexpected:
> integrate(function(x){0*x+1+1i},0,1)
1 with absolute error < 1.1e-14
>
(I would expect 1+1i here)
One can write a little wrapper, but it's not straightforwar
Hi
I found the following unexpected:
> integrate(function(x){0*x+1+1i},0,1)
1 with absolute error < 1.1e-14
>
One can write a little wrapper, but it's messy. Would it be hard to
accommodate such functions?
The manpage for integrate() does not mention imaginary numbers.
--
Robin Hankin
Uncertainty
.ac.be/biostat/
> http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
>
>
> - Original Message -
> From: "yyan liu" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, October 28, 2004 12:56 AM
> Subject: [R] integrate a fu
On 27-Oct-04 yyan liu wrote:
> Hi:
> I want to integrate the following function with
> respect to "z", "u" is another argument in the
> function. My program is a loop and in each loop the
> argument "u" will be given a specified numeric values.
> But how can I use the "integrate" function with "u
riginal Message -
From: "yyan liu" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 28, 2004 12:56 AM
Subject: [R] integrate a function in R
Hi:
I want to integrate the following function with
respect to "z", "u" is another argume
Hi:
I want to integrate the following function with
respect to "z", "u" is another argument in the
function. My program is a loop and in each loop the
argument "u" will be given a specified numeric values.
But how can I use the "integrate" function with "u" in
R?
The function is:
zfz<-function(
u might be interested in
http://www.stats.gla.ac.uk/~simon/simon/ddefit.html
Regards
Wayne Jones
-Original Message-
From: Ronaldo Reis Jr. [mailto:[EMAIL PROTECTED]
Sent: 25 August 2004 21:02
To: R-Help
Subject: [R] integrate function
Is possible to integrate this diferential equati
On Wed, 2004-08-25 at 23:44, Peter Dalgaard wrote:
> "Ronaldo Reis Jr." <[EMAIL PROTECTED]> writes:
>
> > Is possible to integrate this diferential equation:
> >
> > dN/dt = Nr(1-(N/K))
> >
> > in R using the integrate() function?
>
> No.
>
However, you could use
N = K/(1 + exp(log((K-N0)/
"Ronaldo Reis Jr." <[EMAIL PROTECTED]> writes:
> Is possible to integrate this diferential equation:
>
> dN/dt = Nr(1-(N/K))
>
> in R using the integrate() function?
No.
> Or any other diferential equation?
Only if the right hand side does not depend on the dependent variable
(N in this case
Is possible to integrate this diferential equation:
dN/dt = Nr(1-(N/K))
in R using the integrate() function?
Or any other diferential equation?
If yes, how?
If no, anybody know any software on linux that make this?
Inte
Ronaldo
--
O problema de ter os dois pés bem firmes no chão é que você
Hi all;
I've got temporal series of data. And I'm plotting it with the type 'l', and
with a interpolating slipe.
Could you advise me about the best way to calculate the area under any of
these curves.
I know it is very easy to calculate the first one, although have no idea of
the second on
Im tryng to understand an error i get with integrate. this is 1.7.0 on
solaris 2.8.
##i am trying to approximate an integral of this function,
f<-function(b) exp(-(b-mu)^2/(2*tau2))/(p-exp(b))*10^6
##with
tau2 <- .005;mu <- 7.96;p <- 2000
##from -inf to different upper limits. using
integrate(f,
42 matches
Mail list logo