-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Yes. That's it.
Thanks, a lot, really.
Marko
On 02/27/2015 02:46 PM, David Winsemius wrote:
>
>> On Feb 27, 2015, at 4:49 AM, marKo wrote:
>>
> Gee. That simple. I knew that! Thanks a lot. Essentially, I needed
> only the diagonal elements. Easi
> On Feb 27, 2015, at 4:49 AM, marKo wrote:
>
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Gee. That simple. I knew that!
> Thanks a lot.
> Essentially, I needed only the diagonal elements.
> Easily solved by:
>
> diag(outer( X=v1,Y=v2, FUN= fV)
>
> I am sure that there are simpler o
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Gee. That simple. I knew that!
Thanks a lot.
Essentially, I needed only the diagonal elements.
Easily solved by:
diag(outer( X=v1,Y=v2, FUN= fV)
I am sure that there are simpler options, but that works like a charm.
Thanks a lot.
Cheers,
Marko
Hi,
The following works.
> f2
function(z)
{
f1 <- function(t)
{
z*t + z*t^2
}
return(f1)
}
> sapply(1:5,function(x)integrate(f2(x),0,1)$value)
[1] 0.83 1.67 2.50 3.33 4.17
--
View this message in context:
http://r.789695.n4.nabble.com/inte
> On Feb 26, 2015, at 1:49 PM, marKo wrote:
>
> v1<-c(1:5)
> v2<-c(1:5)
>
> f1<-function (x) {v1*x+v2*x^2}
>
> The problem is that integrate(f1, 0, 1) does not work.
> I does not, even if a pas the arguments (v1, v2)
>
> f1<-function (x, v1, v2) {v1*x+v2*x^2}
>
> or if i try to vectorize the
marKo ffri.hr> writes:
>
> I'm a bit stuck.
> I have to integrate a series of polynomial functions with vector
> arguments.
>
> v1<-c(1:5)
> v2<-c(1:5)
>
> f1<-function (x) {v1*x+v2*x^2}
>
> The problem is that integrate(f1, 0, 1) does not work.
The point is not that there are "vector arguments"
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
I'm a bit stuck.
I have to integrate a series of polynomial functions with vector
arguments.
v1<-c(1:5)
v2<-c(1:5)
f1<-function (x) {v1*x+v2*x^2}
The problem is that integrate(f1, 0, 1) does not work.
I does not, even if a pas the arguments (v1, v2)
That works.
Thanks a lot!
On Wed, Nov 20, 2013 at 11:52 PM, David Winsemius wrote:
>
> On Nov 20, 2013, at 8:39 PM, David Winsemius wrote:
>
> >
> > On Nov 20, 2013, at 7:12 PM, dan wang wrote:
> >
> >> Hi all,
> >>
> >> Can anyone help me with below integrate function?
> >>
> >> Basically, I w
On Nov 20, 2013, at 8:39 PM, David Winsemius wrote:
>
> On Nov 20, 2013, at 7:12 PM, dan wang wrote:
>
>> Hi all,
>>
>> Can anyone help me with below integrate function?
>>
>> Basically, I want to calculate the integral of the sum of two kernel
>> density functions.
>> But the error shows th
On Nov 20, 2013, at 7:12 PM, dan wang wrote:
> Hi all,
>
> Can anyone help me with below integrate function?
>
> Basically, I want to calculate the integral of the sum of two kernel
> density functions.
> But the error shows that:
> In x - a :
> longer object length is not a multiple of short
Hi all,
Can anyone help me with below integrate function?
Basically, I want to calculate the integral of the sum of two kernel
density functions.
But the error shows that:
In x - a :
longer object length is not a multiple of shorter object length
y1 = rnorm(10)
y2 = rnorm(10)
fhat <- functio
sunny0 wrote
> I'd like to integrate vectors 't' and 'w' for log(w)/(1-t)^2 where i can
> vary the upper limit of the integral to change with each value of 't' and
> 'w', and then put the output into another vector.
>
> So, something like this...
>
> w=c(.33,.34,.56)
> t=c(.2,.5,.1)
> k-c(.3,.4,
pmax instead of min or max.
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf
> > Of dan wang
> > Sent: Tuesday, February 12,
half
> Of dan wang
> Sent: Tuesday, February 12, 2013 7:41 AM
> To: r-help@r-project.org
> Subject: [R] integrate function
>
> Hi All,
>
> Can any one help to explain why min and max function couldn't work in the
> integrate function directly.
>
> For exa
use pmin instead of min.
hth
Matthias
On 12.02.2013 16:41, dan wang wrote:
Hi All,
Can any one help to explain why min and max function couldn't work in the
integrate function directly.
For example, if issue following into R:
integrand <- function(x) {min(1-x, x^2)}
integrate(integrand, lower
To answer my own question: I thought for a while that centering is the
solution to the problem, but it is not:
> integrate(dnorm, 0, Inf, mean = 25)
3.187474e-05 with absolute error < 5.9e-05
> integrate(dnorm, -25, Inf, mean = 0)
3.187474e-05 with absolute error < 5.9e-05
Here "Don't do this"
When I run the following function
HQ2 <- function(n) {
nv <- 6 * sqrt(n)
fcn <- function(z) {
pchisq(z^2 / 36, n - 1) * dnorm(nv - z)
}
## I want the integral from 0 to infinity:
f.Inf <- integrate(fcn, 0, Inf)
## Doc: "Don't do this":
f.100 <- integrat
Dag Rui,
Yes, it helped a lot!
Thanks and greetings,
Gerrit.
Op 10/4/2012 12:06 AM, Rui Barradas schreef:
Hello,
Try
Fnum <- function(x, beta){
sapply(x, function(x) integrate(f,lower=-x,upper=0,beta=beta)$value)
}
And all results were the same.
Hope this helps,
Rui Barradas
Em 03-10-
Hello,
Try
Fnum <- function(x, beta){
sapply(x, function(x) integrate(f,lower=-x,upper=0,beta=beta)$value)
}
And all results were the same.
Hope this helps,
Rui Barradas
Em 03-10-2012 21:59, Gerrit Draisma escreveu:
Dear R-users,
I want to use the function Fnum below
in another integra
Dear R-users,
I want to use the function Fnum below
in another integrate procedure.
How do I write Fnum so that it returns a vector of values?
And will the last integrate return the right answer?
(I tried Vectorize() in several places,
but got all sorts of errors.)
Thanks for helping out.
Ger
On 27/07/12 20:55, David Winsemius wrote:
On Jul 26, 2012, at 10:06 AM, FJ M wrote:
It would be a useful additon to the help page to add
integrate(dnorm, lower = -1.96, upper = 1.96, mean = 2, sd = 1)
Wouldn't most statisticians instead use the more accurate and
undoubtedly faster:
-0700
From: ehl...@ucalgary.ca
To: kri...@ymail.com
CC: chicagobrownb...@hotmail.com; r-help@r-project.org
Subject: Re: [R] Integrate(dnorm) with different mean and standard
deviation help
On 2012-07-23 19:48, Pascal Oettli wrote:
Hello,
Maybe the following could help:
f <- function(x) dno
ample.
>
> Thanks,
>
> Frank
> Chicago
>
>
>> Date: Mon, 23 Jul 2012 19:54:45 -0700
>> From: ehl...@ucalgary.ca
>> To: kri...@ymail.com
>> CC: chicagobrownb...@hotmail.com; r-help@r-project.org
>> Subject: Re: [R] Integrate(dnorm) with different mean
.com; r-help@r-project.org
> Subject: Re: [R] Integrate(dnorm) with different mean and standard deviation
> help
>
> On 2012-07-23 19:48, Pascal Oettli wrote:
> > Hello,
> >
> > Maybe the following could help:
> >
> > > f <- function(x) dnorm(x, mean
Dear All,
thanks in advance for your attention. I'm struggling with this for a few
weeks now, and figured it's time to get some help. I want to
integrate(f(x), lower=-Inf, upper=Inf)
with f(x) =
((gamma(K+1)/(gamma(r+1)*gamma(K-r+1)))*(q(x)^r)*(((1-q(x))^(K-r))*phi(x),
where phi(x) is the stand
Hi,
Check this link
(https://stat.ethz.ch/pipermail/r-help/2010-February/227902.html).
Hope it helps.
A.K.
- Original Message -
From: FJ M
To: R
Cc:
Sent: Monday, July 23, 2012 10:23 PM
Subject: [R] Integrate(dnorm) with different mean and standard deviation help
I'm tryi
Hello,
Yes, I should learn to read.
Regards
Le 24/07/2012 11:54, Peter Ehlers a écrit :
On 2012-07-23 19:48, Pascal Oettli wrote:
Hello,
Maybe the following could help:
> f <- function(x) dnorm(x, mean=2, sd=1)
> integrate(f, -1.96, 1.96)
0.4840091 with absolute error < 1.4e-12
Or yo
integrate(dnorm, -1.96, 1.96, mean=2, sd=1)
Read the help for integrate! It tells you that the
integrate function has a "..." argument which consists of
"additional arguments to be passed to f".
cheers,
Rolf Turner
On 24/07/12 14:23, FJ M wrote:
I'm trying to provide different
On 2012-07-23 19:48, Pascal Oettli wrote:
Hello,
Maybe the following could help:
> f <- function(x) dnorm(x, mean=2, sd=1)
> integrate(f, -1.96, 1.96)
0.4840091 with absolute error < 1.4e-12
Or you could note the '...' argument indicated on the help page:
integrate(dnorm, lower = -1.96
Try
> integrate(dnorm, mean = 2, sd = 1, -1.96, 1.96)
0.4840091 with absolute error < 1.4e-12
HTH,
Jorge.-
On Mon, Jul 23, 2012 at 10:23 PM, FJ M <> wrote:
>
> I'm trying to provide different parameters to the integrate function for
> various probability functions. I'm using dnorm as the simpl
Hello,
Maybe the following could help:
> f <- function(x) dnorm(x, mean=2, sd=1)
> integrate(f, -1.96, 1.96)
0.4840091 with absolute error < 1.4e-12
HTH
Regards.
Le 24/07/2012 11:23, FJ M a écrit :
I'm trying to provide different parameters to the integrate function for
various probabilit
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
On 2012-04-06 07:19, Navin Goyal wrote:
Thank you so much for your help Berend.
I did not see that my code had a typo and it was thus wrongly written ( I
overlooked the i that was supposed to be actually 1)
instead of for (q in *1*:length(comb1$ID))
I had it as for (q in *i*:leng
Thank you so much for your help Berend.
I did not see that my code had a typo and it was thus wrongly written ( I
overlooked the i that was supposed to be actually 1)
instead of for (q in *1*:length(comb1$ID))
I had it as for (q in *i*:length(comb1$ID))
It works correctly as expect
On 06-04-2012, at 13:14, Navin Goyal wrote:
> Apologies for the lengthy code.
> I tried a simple (and shorter) piece of code (pasted below) and it still
> gives me the same error for last few rows. Is this a bug or am I doing
> something totally wrong? Could anyone please provide some help/poi
Apologies for the lengthy code.
I tried a simple (and shorter) piece of code (pasted below) and it still
gives me the same error for last few rows. Is this a bug or am I doing
something totally wrong? Could anyone please provide some help/pointers ?
PS. beta0 was fixed to 0.001 in the previous c
Apologies for the lengthy code.
I tried a simple (and shorter) piece of code (pasted below) and it still
gives me the same error for last few rows. Is this a bug or am I doing
something totally wrong? Could anyone please provide some help/pointers ?
PS. beta0 was fixed to 0.001 in the previous c
On 06-04-2012, at 00:55, Navin Goyal wrote:
> Hi,
> I am using the integrate function in some simulations in R (tried ver 2.12
> and 2.15). The problem I have is that the last few rows do not integrate
> correctly. I have pasted the code I used.
> The column named "integral" shows the output from
Hi,
I am using the integrate function in some simulations in R (tried ver 2.12
and 2.15). The problem I have is that the last few rows do not integrate
correctly. I have pasted the code I used.
The column named "integral" shows the output from the integrate function.
The last few rows have no integ
I don't believe you did anything wrong here, just that integrate()
itself isn't (can't?) be vectorized.
E.g.,
x <- integrate(function(x) x^2, 0, 2)
y <- integrate(function(x) x^2, 0, c(2,3))
identical(x, y) # FALSE -- so there's a difference.
# Take a look
str(x)
str(y)
# It's just in the call
Dear David and Micheal,
thanks for your suggestion. Vectorize does what I need.
David you suggest me that I didn't built the function in a manner that
would vectorize. Could you please explain me what's wrong?
Thanks,
Mauro
>
> On Mar 15, 2012, at 6:08 AM, Mauro Rossi wrote:
>
>> Dear R users,
On Mar 15, 2012, at 6:08 AM, Mauro Rossi wrote:
Dear R users,
first I take this opportunity to greet all the R community for
your continuous efforts.
I wrote a function to calculate the pdf and cdf of a custom
distribution (mixed gamma model).
The function is the following:
pmixedgamma
I believe the difficulty is that the integrate function isn't
vectorized: add this line and you should be good
pmixedgamma3 <- Vectorize(pmixedgamma3)
Read ? Vectorize for details if you only need to vectorize certain arguments.
Michael
On Thu, Mar 15, 2012 at 6:08 AM, Mauro Rossi wrote:
> Dea
Dear R users,
first I take this opportunity to greet all the R community for your
continuous efforts.
I wrote a function to calculate the pdf and cdf of a custom distribution
(mixed gamma model).
The function is the following:
pmixedgamma3 <- function(y, shape1, rate1, shape2, rate2, prev)
On 15.02.2012 17:33, Dimitris.Kapetanakis wrote:
Dear all,
I am trying to use the integrate function in R but it seems that it does not
work in my example and I cannot figure out why. I create a function Mu1
(which works fine) and try to integrate by the code:
n <- 100
Ctrl<
Integrate works on functions that are vectorized (i.e., the algorithm
puts in N inputs and expects N outputs) -- your function is not
vectorized (and I'm not sure what integrating it means, but I'm not
looking too closely) but you can make it "look vectorized" with the
Vectorize() HOF. Note that th
Dear all,
I am trying to use the integrate function in R but it seems that it does not
work in my example and I cannot figure out why. I create a function Mu1
(which works fine) and try to integrate by the code:
n <- 100
Ctrl<- as.matrix(cbind(runif(n, -30, 30)))
W
On first glance it seems like it should work, perhaps a minimal
working example would help.
Also, if logictoReduce is a boolean vector, you probably don't need to
test for equality with TRUE; if that test seems necessary (i.e., if
Overloads <- Overloads[logictoReduce] doesn't work) that may be tie
Dear all,
I would like to put these two lines together
logictoReduce<-((Overloads-1)%%FreqN)==(SpanIndex-1) #0...3 refer to sub spans
1 to 4
Overloads<-Overloads[logictoReduce==TRUE]
and do it like this
Overloads<-Overloads[((Overloads-1)%%FreqN)==(SpanIndex-1)]
which does not seem to work.
What exactly is the problem?
Please read the posting guide and follow it. Your message is hard to
interpret as is (in no small part because it looks like markup),
contains no R code, and has no mention of an error at all.
2011/5/15 meltem gölgeli :
> Dear R-users,
> I'am really new at R. That's w
On May 15, 2011, at 6:51 AM, meltem gölgeli wrote:
Dear R-users,
I'am really new at R. That's why I probably have a basic quastion. I
have a
function like f(x,y)=\int^{0}_{y}(2*x)*exp(y-t)dt or
f(x,y)=\int^{0}_{y}((2*x)*exp(\int^{0}_{t}(x*k)dk)dt and I can also
define
some basic loops for
Dear R-users,
I'am really new at R. That's why I probably have a basic quastion. I have a
function like f(x,y)=\int^{0}_{y}(2*x)*exp(y-t)dt or
f(x,y)=\int^{0}_{y}((2*x)*exp(\int^{0}_{t}(x*k)dk)dt and I can also define
some basic loops for x&y like x in 1:3 and y in 1:2. Could anybody please
help me
On 20/04/11 22:25, vioravis wrote:
This should work!!
rmse<-function (x){
dquared<-x^2
sum1<-sum(x^2,na.rm=TRUE)
rmse<-sqrt((1/length(x))*sum1)
rmse}
Shouldn't the divisor be the number of non-missing values in x?
Rather than the length of x? (Like, e.g. sum(!is.na(x)) ?)
cheers,
Am 20.04.2011 10:59, schrieb Mauro:
It`s probably an easy question, but couldn`t figure it out.
I`ve defined a function like:
rmse<-function (x){
dquared<-x^2
sum1<-sum(x^2)
rmse<-sqrt((1/length(x))*sum1)
rmse}
My problem is, that I have NA Values in x and the above function returns NA.
I`m l
This should work!!
rmse<-function (x){
dquared<-x^2
sum1<-sum(x^2,na.rm=TRUE)
rmse<-sqrt((1/length(x))*sum1)
rmse}
--
View this message in context:
http://r.789695.n4.nabble.com/Integrate-na-rm-in-own-defined-functions-tp3462492p3462615.html
Sent from the R help mailing list archive at Nab
It`s probably an easy question, but couldn`t figure it out.
I`ve defined a function like:
rmse<-function (x){
dquared<-x^2
sum1<-sum(x^2)
rmse<-sqrt((1/length(x))*sum1)
rmse}
My problem is, that I have NA Values in x and the above function returns NA.
I`m looking for a way to use "na.rm=TRUE"
I received the solution...
Hi:
This is what David means:
f <- function(x, p) x^p
integrate(f, lower = -1, upper = 1, p = 2)
0.667 with absolute error < 7.4e-15
integrate(f, lower = -1, upper = 1, p = 3)
0 with absolute error < 5.6e-15 # this is correct
--
View this message
If f is a two-parameter function, how can I integrate it with respect to p?
--
View this message in context:
http://r.789695.n4.nabble.com/integrate-one-single-variable-functions-with-constant-parameters-tp3336066p3336693.html
Sent from the R help mailing list archive at Nabble.com.
On Mar 4, 2011, at 6:01 PM, santiagorf wrote:
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
funct
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)
Howe
Hi Dennis,
Thank you for your kind reply. Yes, essentially, we take integration
twice. However, I still have a few questions:
First, if we consider doing a double integration at the end, since the
first integration in within the indicator function,
it seems to be difficult.
Second, m1star is
Hi Hannah:
You have a few things going on, but the bottom line is that numer and denom
are both double integrals.
On Thu, Feb 17, 2011 at 1:06 PM, li li wrote:
> Hi all,
> I have some some problem with regard to finding the integral of a
> function containing an indicator function.
> please s
Hi all,
I have some some problem with regard to finding the integral of a
function containing an indicator function.
please see the code below:
func1 <- function(x, mu){
(mu^2)*dnorm(x, mean = mu, sd = 1)*dgamma(x, shape=2)}
m1star <- function(x){
integrate(func1, lower = 0, upper = Inf,x
> Dear all,
> I have some issues with integrate in R thus I would like to request
> your help. I am trying to calculate the integral of f(x)*g(x).
> The f(x) is a step function while g(x) is a polynomial.
> If f(x) (step function) changes its value only few times (5 or 6 'steps')
> everything is ca
Dear all,
I have some issues with integrate in R thus I would like to request your help.
I am trying to calculate the integral of f(x)*g(x).
The f(x) is a step function while g(x) is a polynomial.
If f(x) (step function) changes its value only few times (5 or 6 'steps')
everything is calulated ok
still a room when its empty? Does the room,
the thing itself have purpose? Or do we, what's the word... imbue it."
- Jubal Early, Firefly
r-help-boun...@r-project.org wrote on 12/16/2010 09:11:33 AM:
> [image removed]
>
> Re: [R] Integrate two function in R
>
see inline.
On Thu, Dec 16, 2010 at 10:11 AM, Ben Bolker wrote:
> Alaios yahoo.com> writes:
>
>>
>> Hello I have two function in R
>> like
>> g(x)=2x-3
>> and s(x)=5x^2+2
>>
>> and I want to find the integrafl of the g(x)*s(x) inside the interval of
>> [a,b]
>>
>
> Analytically or numerically?
I guess what you have is
g <- function(x){ 2*x-3 }
s <- function(x){ 5*x^2+2 }
and what you want is
f<-function(x){ g(x)*s(x) }
integrate(f,a,b)
Try that and see if it works. If not (that is, if your actual g and s are
not as in the example), maybe you'll have to do this:
integrate(Vectorize(
On Dec 16, 2010, at 7:27 AM, Alaios wrote:
Hello I have two function in R
like
g(x)=2x-3
and s(x)=5x^2+2
and I want to find the integrafl of the g(x)*s(x) inside the
interval of [a,b]
Could you please help me find the proper function?
It depends on what you are doing:
None of what appea
Ben Bolker gmail.com> writes:
> Analytically or numerically?
> It sounds like you want the answer analytically, in which case R
> can't do it, but it is an easy integral
>
> g(x)*s(x) = 10*x^3-15*x^2+4*x-6
> indefinite integral = 10/3*x^4 -15/3*x^3 + 4/2*x^2 - 6*x + C
oops, the first
Alaios yahoo.com> writes:
>
> Hello I have two function in R
> like
> g(x)=2x-3
> and s(x)=5x^2+2
>
> and I want to find the integrafl of the g(x)*s(x) inside the interval of [a,b]
>
Analytically or numerically?
It sounds like you want the answer analytically, in which case R
can't do it
Hello I have two function in R
like
g(x)=2x-3
and s(x)=5x^2+2
and I want to find the integrafl of the g(x)*s(x) inside the interval of [a,b]
Could you please help me find the proper function?
I would like to thank you in advance for your help
Regards
Alex
[[alternative HTML ve
, Harold
> Gesendet: Montag, 15. November 2010 18:11
> An: Douglas Bates
> Cc: r-help@r-project.org
> Betreff: Re: [R] Integrate to 1? (gauss.quad)
>
> Thank you, Doug. I am still missing something here. Should
> this simply be sum(f(x_i) * w_i) where x_i is node i and w_i
>
, November 14, 2010 2:28 PM
> To: Doran, Harold
> Cc: r-help@r-project.org
> Subject: Re: [R] Integrate to 1? (gauss.quad)
>
> I don't know about the statmod package and the gauss.quad function but
> generally the definition of Gauss-Hermite quadrature is with respect
> to
I don't know about the statmod package and the gauss.quad function but
generally the definition of Gauss-Hermite quadrature is with respect
to the function that is multiplied by exp(-x^2) in the integrand. So
your example would reduce to summing the weights.
On Sun, Nov 14, 2010 at 11:18 AM, Dora
Does anyone see why my code does not integrate to 1?
library(statmod)
mu <- 0
s <- 1
Q <- 5
qq <- gauss.quad(Q, kind='hermite')
sum((1/(s*sqrt(2*pi))) * exp(-((qq$nodes-mu)^2/(2*s^2))) * qq$weights)
### This does what's it is supposed to
myNorm <- function(theta) (1/(s*sqrt(2*pi))) * exp(-((th
Hi,
I still do not really understand, but I have a couple ideas:
On Sun, Nov 7, 2010 at 11:09 AM, Vaiva P wrote:
> Thank you guys for a quick reaction. I decided it to write a common
> letter to you both at once.
> I tried to calculate the value of a a function without integration. I
> gave the
Hi,
Have you tried just your function (undint) on its own (i.e., without
trying to feed it to integrate)? If you did, you would notice that it
does not return anything (hence, "I could not get any result"). See
inline comments for some additional thoughts.
On Sun, Nov 7, 2010 at 8:01 AM, Vaiva
So undint(u) is a 15 dimensional vector. What do the different
dimensions mean? How would you define the integral of a 15 dimensional
vector? It would help if you could provide some background on what your
code is supposed to do.
Uwe Ligges
On 07.11.2010 17:01, Vaiva P wrote:
Hi,
I need
Hi,
I need some help on integrating a function that is a vector.
I have a function - vector which each element is different. And,
naturally, function integrate() does not work
I checked the article of U. Ligges and J. Fox (2008) about code
optimization "How Can I Avoid This Loop or Make It Faster?
Dear:
Anyone has experience to use R integrate a function with more than two
dimensions, but
you only need to integrate the function respect to one variable, say x. Because
I also
want to maximise the log-likelihood after integration of function respect to x.
Thanks!
Xin
---
Dr.Xin Shi
r will ask 'f' for a vector of
function
evaluations at the set of nodes). This can be achieved either explicitly or
implicitly
(by calling the sapply inside the function).
Christos
Date: Wed, 23 Jun 2010 20:22:15 -0400
Subject: Re: [R] integrate dmvtnorm
From: carrieands...@gmail.c
une 23, 2010 8:23 pm
Subject: Re: [R] integrate dmvtnorm
To: Christos Argyropoulos
Cc: r-help@r-project.org
> Thanks!
> Both suggestions are very helpful.
> One more question:
> Can I use Vectorize to solve double integration question ?
>
> Now that
> f=function(x, y)
From: carrieands...@gmail.com
> To: R-help@r-project.org
> Subject: [R] integrate dmvtnorm
>
> Hello, everyone,
>
> I have a question about integration of product of two densities.
> Here is the sample code; however the mean of first density is a function of
> another r
00e-14 1.887638e-17
>
>
> suggesting the solution:
>
> vf<-Vectorize(f)
>
> > integrate(vf,lower=-Inf, upper=Inf)
>
> 0.1314427 with absolute error < 4e-05
>
>
> Christos
>
>
>
>
> > Date: Wed, 23 Jun 2010 19:05:53 -0400
> > From: car
r < 4e-05
>
Hope this helps,
Ravi.
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Carrie Li
Sent: Wednesday, June 23, 2010 7:06 PM
To: r-help
Subject: [R] integrate dmvtnorm
Hello, everyone,
I have a question about integratio
Hello, everyone,
I have a question about integration of product of two densities.
Here is the sample code; however the mean of first density is a function of
another random variable, which is to be integrated.
##
f=function(x) {dmvnorm(c(0.6, 0.8), mean=c(0.75, 0.75/x))*dnorm(x, mean=0.6,
sd=0.15
li li-13 wrote:
>
> Yes, f2 is the function I wanted to write. I tried to do use "Vectorize"
> function to f1, it did not work.
>> f2 <- function(x)
> + {
> + integrate(Vectorize(f1,vectorize.args =p), lower=0,upper=1, x)
> + }
>> f2(c(2,3))
> Error in Vectorize(f1, vectorize.ar
f Medicine
Johns Hopkins University
Ph. (410) 502-2619
email: rvarad...@jhmi.edu
- Original Message -
From: li li
Date: Saturday, December 5, 2009 7:13 pm
Subject: Re: [R] integrate function
To: David Winsemius
Cc: r-help@r-project.org
> Thank you very much for your reply!
>
__
>
> Ravi Varadhan, Ph.D.
> Assistant Professor,
> Division of Geriatric Medicine and Gerontology
> School of Medicine
> Johns Hopkins University
>
> Ph. (410) 502-2619
> email: rvarad...@jhmi.edu
>
>
> - Original Message -
>
rom: li li
Date: Saturday, December 5, 2009 7:13 pm
Subject: Re: [R] integrate function
To: David Winsemius
Cc: r-help@r-project.org
> Thank you very much for your reply!
> It is not an assignment.
> What I want to do is what we often do. If we have a bivariate
> function of x
&g
Thank you very much for your reply!
It is not an assignment.
What I want to do is what we often do. If we have a bivariate function of x
and p,
I first fix x and integrate out p. Then the resultant function is only in
terms of x.
Here f1 is a bivariate function of x and p.
> f1 <- function (p,x
On Dec 5, 2009, at 4:59 PM, li li wrote:
Hello,
I have some trouble in terms of using integrate function in R.
f1 is a function of p and x where x is supposed to be a vector. (See
the
code).
Then I want to write function f2 which is a function of the vector
x after I integrate out p.
Can
Hello,
I have some trouble in terms of using integrate function in R.
f1 is a function of p and x where x is supposed to be a vector. (See the
code).
Then I want to write function f2 which is a function of the vector
x after I integrate out p.
Can some one give me some help? Many thanks!
Change e2 to the following and it works
e2 <- function(a) a^2/2
The reason it doesn't is that e2 must be able to handle vector inputs
correctly. Your original function does not do this.
from ?integrate
f - an R function taking a numeric first argument and returning a
numeric vector of the sam
This is my code , when i run it ,error happed . can you tell me what's the
reason and modify it ?thank you very much !! the error is "evaluation of
function gave a result of wrong length"
e2<-function(a) integrate(function(x) x,lower=0,upper=a)$value
integrate(e2,lower=0, upper=0.5)$value
?integrate, it is in the documentation
Bhargab Chattopadhyay wrote:
Hi!
Can anyone please let me know what numerical integration procedure does the
integrate function in package stats follow?
Thank you in advance
Shant
[[alternative HTML version deleted]]
Hi!
Can anyone please let me know what numerical integration procedure does the
integrate function in package stats follow?
Thank you in advance
Shant
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://
On 01/05/2009 5:46 AM, Andreas Wittmann wrote:
Dear R-users,
i have to integrate the following function
`fun1` <- function (a, l1, l2)
{
exp(log(l1) * (a - 1) - l2 * lgamma(a))
}
but if l1 is large, i get the "non-finite function value" error, so my
idea is to rescale with exp(-l1)
`fun2`
Dear R-users,
i have to integrate the following function
`fun1` <- function (a, l1, l2)
{
exp(log(l1) * (a - 1) - l2 * lgamma(a))
}
but if l1 is large, i get the "non-finite function value" error, so my
idea is to rescale with exp(-l1)
`fun2` <- function (a, l1, l2)
{
exp(log(l1) * (a - 1)
1 - 100 of 118 matches
Mail list logo