Displaying 20 results from an estimated 4000 matches similar to: "Integrate and subdivisions limit"
2013 Jul 16
2
Problem following an R bug fix to integrate()
I have been told by the CRAN administrators that the following code generated
an error on 64-bit Fedora Linux (gcc, clang) and on Solaris machines (sparc,
x86), but runs well on all other systems):
> fn <- function(x, y) ifelse(x^2 + y^2 <= 1, 1 - x^2 - y^2, 0)
> tol <- 1.5e-8
> fy <- function(x) integrate(function(y) fn(x, y), 0, 1,
2012 Sep 25
1
how to pass a function to a function inside a function
Hi,
I'm trying to compile two functions into one function. the first funtion is
called 'fs' which is self-made function, another function is from the
built-in 'integration' function that is copy-paste-edited. If built
separatey, these functions work well. However that is not the case if
combines together, where certainly I made mistake somewhere when
constructing the code.
2011 Aug 29
1
maximum number of subdivisions reached
Why I am getting
Error in integrate(f, x1, x1 + dx) :
maximum number of subdivisions reached
and can I avoid this?
func <- function(y, a, rate, sad){
f3 <- function(z){
f1 <- function(y,a,n){
dpois(y,a*n)
}
f2 <- function(n,rate){
dexp(n,rate)
}
f <- function(n){
f1(y,a,n)*f2(n,rate)
}
r <- 0
r1 <- 1
x1 <- 0
dx <- 20
while(r1 >
2004 Dec 09
3
surf.ls
Hello,
I am looking into description of surf.ls(spatial)
and see under value $beta - the coefficients.
When I use polynomial of degree 2 to fit surface
I expect to get 4 coefficients:
z = a_1 x^2 + a_2 xy + a_3 y^2 + a_4
What do beta really stand for and why do I get
$beta vector of length 6?
Thakns,
Mark
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
2005 Sep 16
4
Integrate functions with loops
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 results gives errors
###########
Error in integrate(integrandtotest, lower = 0.1, upper =
2007 Jun 28
2
minor flaw in integrate()
Hi,
I noticed a minor flaw in integrate() from package stats:
Taking up arguments lower and upper from integrate(),
if (lower == Inf) && (upper == Inf)
or
if (lower == -Inf) && (upper == -Inf)
integrate() calculates the value for (lower==-Inf) && (upper==Inf).
Rather, it should return 0.
Quick fix:
### old code ###
### [snip]
else {
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
2006 Jun 02
1
doubt with integrate ()
Dear members,
I'm getting an error with the "integrate" function. Searching in the r-help
archives, I think this may have something to do with the function (it is not
returning a vector but a number), but I don't see exactly what.
The function to integrate was defined with a for loop first:
for (i in 1:(nbcol-1))
{tdon1<-tdon[,i]
2010 Apr 27
1
TikzDevice and texi2dvi
Dear All,
I am starting to use the tikzDevice package, but I am experiencing some
(minor problems).
If I try to run the script at the end of the email, I get the following
error
Error in tools::texi2dvi("normal.tex", pdf = T) :
Running 'texi2dvi' on 'normal.tex' failed.
Messages:
sh: /usr/bin/texi2dvi: not found
How do I install the missing texi2dvi?
I found some
2013 Feb 05
1
integrate: 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 <- integrate(fcn, 0, 100)
cbind(f.Inf, f.100)
}
I get, for n = 9 and
2011 Nov 10
2
performance of adaptIntegrate vs. integrate
Dear list,
[cross-posting from Stack Overflow where this question has remained
unanswered for two weeks]
I'd like to perform a numerical integration in one dimension,
I = int_a^b f(x) dx
where the integrand f: x in IR -> f(x) in IR^p is vector-valued.
integrate() only allows scalar integrands, thus I would need to call
it many (p=200 typically) times, which sounds suboptimal. The
2004 Jul 08
1
(PR#7070)
> version
_
platform i686-pc-linux-gnu
arch i686
os linux-gnu
system i686, linux-gnu
status
major 1
minor 7.1
year 2003
month 06
day 16
language R
Bug:
integrate(f,lower,upper,extra_args)
where
f <- function(x,extra_args)
{
body
}
integrate doesn't pass the extra arguments when calling f.
As a first check of this finding I integrated dnorm from
2008 Sep 30
2
R's integrate function
Hello,
I am trying to use R's integrate function to calculate the following
integral for z=423:
integrate(function(y,z){
sapply(y, function(y,z){
integrate(function(x,z)
1/x*dbeta(0.01,x/(0.005/1.005),(1-x)/(0.005/1.005))*dbeta(y,x/(0.005/1.005),(1-x)/(0.005/1.005))*(1-y)^z,0,1,423)$value
})
},0,1,423)$value
but I receive an error message saying that the maximum number of
subdivisions is
2013 Apr 03
1
Problem with integrate function
Hello,
The following code of mine is giving the error:
Error in integrate(fx[[2]], 0.056, 1) :
maximum number of subdivisions reached
Can anyone help?
Thanks and Regards.
Swagato
--------------------------
fv<-vector("list")
fx<-vector("list")
v<-0
c<-0
n<-0
NOV<-0
i<-0
while(n<200){
fv[[1]]<-function(x)1 #prior function
2001 Nov 20
1
warning message
Hello everybody.
I would like to pose a question regarding a warning message after running
a function of my own. The function I created for computing the p-value of
the dw statistic has a command line like this:
»dwf0 <- function(dw,eigen) { carfun <- function(x) {
(prod(1+2*(eigen-dw)*1i*x)^(-1/2)-prod(1-2*(eigen-dw)*1i*x)^(-1/2))/(1i*x) }
; 1/2+integrate(f=carfun,lower = 0,upper =
2008 Oct 15
4
a really simple question on polynomial multiplication
Dear R people:
Is there a way to perform simple polynomial multiplication; that is,
something like
(x - 3) * (x + 3) = x^2 - 9, please?
I looked in poly and polyroot and expression. There used to be a
package that had this, maybe?
thanks,
Erin
--
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodgess at
2011 Nov 23
2
How to increase precision to handle very low P-values
Hello, Rlisters
I have to compute p-values that are on the tail of the distribution,
P-values < 10^-20.
However, my current implementations enable one to estimate P-values up to
10^-12, or so.
A typical example is found below, where t is my critical value.
########### example - code adapted from Rassoc #######################
rho01 = 0.5
rho105 = 0.5
rho005 = 0.5
t = 8
z = 2
2002 May 07
4
Putting obejct into Graph title
Hello all -
If I want to put mean value of a matrix into the title or subtitle of a graph, how would I do this? For example, in a set of commands like below,
> m.mean<-mean(m)
> gplot (m, thresh=m.mean)
> title (main="A2. Block Density of Matrix m\nplotted based on MDS",
+ sub="lines below mean density (**0.435**) suppressed")
I want to ask [R] to put the
2009 Dec 18
1
Numerical Integration
Dear @ll. I have to calculate numerical integrals for triangular and trapezoidal figures. I know you can calculate the exactly, but I want to do it this way to learn how to proceed with more complicated shapes. The code I'm using is the following:
integrand<-function(x) {
print(x)
if(x<fx[1]) return(0)
if(x>=fx[1] && x<fx[2]) return((x-fx[1])/(fx[2]-fx[1]))