Displaying 20 results from an estimated 1000 matches similar to: "R numerical integration"
2010 Sep 08
11
problem with outer
Hello,
i wrote this function guete and now i want to plot it: but i get this error
message. i hope someone can help me.
Error in dim(robj) <- c(dX, dY) :
dims [product 16] do not match the length of object [1]
p_11=seq(0,0.3,0.1)
p_12=seq(0.1,0.4,0.1)
guete = function(p_11,p_12) {
set.seed(1000)
S_vek=matrix(0,nrow=N,ncol=1)
for(i in 1:N) {
X_0=rmultinom(q-1,size=1,prob=p_0)
2011 Dec 10
2
efficiently finding the integrals of a sequence of functions
Hi folks,
I am having a question about efficiently finding the integrals of a list of
functions. To be specific,
here is a simple example showing my question.
Suppose we have a function f defined by
f<-function(x,y,z) c(x,y^2,z^3)
Thus, f is actually corresponding to three uni-dimensional functions
f_1(x)=x, f_2(y)=y^2 and f_3(z)=z^3.
What I am looking for are the integrals of these three
2010 Mar 04
2
which coefficients for a gam(mgcv) model equation?
Dear users,
I am trying to show the equation (including coefficients from the model
estimates) for a gam model but do not understand how to.
Slide 7 from one of the authors presentations (gam-theory.pdf URL:
http://people.bath.ac.uk/sw283/mgcv/) shows a general equation
log{E(yi )} = ?+ ?xi + f (zi ) .
What I would like to do is put my model coefficients and present the
equation used. I am an
2001 Oct 22
2
OT: compare several graphs
Hi all,
this is OT, but maybe someone can give me a clue. I've got data from eye
tracker experiments (750 data points). These figures show how the data
lock like
|** * ***** |*** ******
| ** **** | * *
| | * *
| | *
|-------------- |---------------
Y axes display velocity, x axes display time, * are the data points.
2012 May 09
2
problem with Gauss Hermite ( x and w )
Hi all,
I am using the 'gaussHermite' function from the 'pracma' library
############ CODES ###########
library(pracma)
cc=gaussHermite(10)
cc$x^2
cc$x^5
cc$x^4
############ CODES ###########
as far so good. However, it does NOT work for any NON integer values, say
############ CODES ###########
cc$x^(2.5)
cc$x^(-2.5)
############ CODES ###########
But just think about it
2003 Apr 21
2
piece wise functions
Hello,
Apologies if this question has already arised, hope you can
help me to the find the solution to this or point the place to look at.
I have a multidimensional piece-wise regression linear problem, i.e.
to find not only the regression coefficients for each "interval" but
also the beginning and ends of the intervals.
To simplify it to the one dimensional case and
two intervals,
2006 Nov 18
1
Questions regarding "integrate" function
Hi there. Thanks for your time in advance.
I am using R 2.2.0 and OS: Windows XP.
My final goal is to calculate 1/2*integral of
(f1(x)^1/2-f2(x)^(1/2))^2dx (Latex codes:
$\frac{1}{2}\int^{{\infty}}_{\infty}
(\sqrt{f_1(x)}-\sqrt{f_2(x)})^2dx $.) where f1(x) and f2(x) are two
marginal densities.
My problem:
I have the following R codes using "adapt" package. Although "adapt"
2003 Nov 10
1
ts package function filter: mismatch between function action and help (PR#5017)
Dear people,
I'm running
RedHat 9.0
and
R : Version 1.7.1 (2003-06-16)
from the help file
# Usage:
#
# filter(x, filter, method = c("convolution", "recursive"),
# sides = 2, circular = FALSE, init)
# init: for recursive filters only. Specifies the initial values of
# the time series just prior to the start value, in reverse
# time
2013 Nov 19
1
Generación de números aleatorios. Mixtura k-puntos
Saludo cordial para cada uno.
Les pido ayuda para generar números aleatorios de una mixtura k-puntos.
Sabemos que la función de distribución F es una mixtura k-puntos si es de
la forma F(x) = p_1 F_1(x) + p_2 F_2(x) + … + p_k F_k(x), donde F_j es una
función de distribución de probabilidad, p_j > 0 y suma(p_j) = 1, para j =
1, 2, …, k.
En mi caso particular F es la suavización de la
2004 Jul 10
1
Exact Maximum Likelihood Package
Dear R users,
I am a mathematics postdoc at UC Berkeley. I have written a package
in a Computational Algebra System named Singular
http://www.singular.uni-kl.de
to compute the Maximum Likelihood of a given probability distribution over
several discrete random variables. This package gives exact answers to the
problem. But more importantly, it gives All MLE solutions.
My understanding is that
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
2013 Aug 23
1
Setting up 3D tensor product interactions in mgcv
Hi,
I am trying to fit a smoothing model where there are three dimensions
over which I can smooth (x,y,z). I expect interactions between some,
or all, of these terms, and so I have set up my model as
mdl <- gam(PA ~ s(x) + s(y) + s(z) + te(x,y) + te(x,z) + te(y,z) +
te(x,y,z),...)
I have recently read about the ti(), "tensor product interaction
smoother", which takes care of these
2013 Feb 15
1
minimizing a numerical integration
Dear all,
I am a new user to R and I am using pracma and nloptr libraries to minimize
a numerical integration subject to a single constraint . The integrand
itself is somehow a complicated function of x and y that is computed
through several steps. i formulated the integrand in a separate function
called f which is a function of x &y. I want to find the optimal value of x
such that the
2012 Jan 27
3
Numerical instability in new R Windows development version
I have a question concerning the new Windows toolchain for R >= 2.14.2.
When trying out my package 'pracma' on the win-builder development version
it will stop with the following error message:
> f3 <- function(x, y) sqrt((1 - (x^2 + y^2)) * (x^2 + y^2 <= 1))
> dblquad(f3, -1, 1, -1, 1) # 2.094395124 , i.e. 2/3*pi , err = 2e-8
Warning in sqrt((1 - (x^2 + y^2)) *
2012 Apr 18
0
Numerical integration again
Hi all,
Here is an integration function
require(pracma) # for 'quadinf'
myint=function(j) {
quadinf(function(x)
(1/(1+exp(-x)))^j*(1-1/(1+exp(-x)))^(k-j)*dnorm(x,mu,casigma),-Inf,Inf)
}
in any optimization routine. It works fine most of the time but failed with
some particular sets of values, say one of the following:
k=20
mu=-1.978295
casigma=0.008326927
>
2013 Feb 16
3
two dimensional integration
Dear R-users,
I'm wondering how to calculate this double integral in R:
int_a^b int_c^y g(x, y) dx dy
where g(x,y) = exp(- alpha (y - x)) * b
Thanks for answering!
Cheers,
Alui
[[alternative HTML version deleted]]
2009 Aug 24
2
Formulas in gam function of mgcv package
Dear R-experts,
I have a question on the formulas used in the gam function of the mgcv
package.
I am trying to understand the relationships between:
y~s(x1)+s(x2)+s(x3)+s(x4)
and
y~s(x1,x2,x3,x4)
Does the latter contain the former? what about the smoothers of all
interaction terms?
I have (tried to) read the manual pages of gam, formula.gam, smooth.terms,
linear.functional.terms but
2009 Aug 24
2
Formulas in gam function of mgcv package
Dear R-experts,
I have a question on the formulas used in the gam function of the mgcv
package.
I am trying to understand the relationships between:
y~s(x1)+s(x2)+s(x3)+s(x4)
and
y~s(x1,x2,x3,x4)
Does the latter contain the former? what about the smoothers of all
interaction terms?
I have (tried to) read the manual pages of gam, formula.gam, smooth.terms,
linear.functional.terms but
2012 Mar 22
2
Quicker way to apply values to a function
Hi all,
myint=function(mu,sigma){
integrate(function(x) dnorm(x,mu,sigma)/(1+exp(-x)),-Inf,Inf)$value
}
mymu=seq(-3,3,length(1000))
mysigma=seq(0,1,length(500))[-1]
k=1
v=c()
for (j in 1:length(mymu)) {
for (i in 1:length(mysigma)) {
v[k]=myint(mymu[j],mysigma[i])
k=k+1
}
}
Basically, I want to investigate for what values of mu and sigma, the
integral is divergent.
Is there another way
2023 Nov 09
1
Dependency errors for package pracma
I tried to update my package {pracma} on CRAN from 2.4.2 (2022-09-21)
to version 2.4.4 (2023-11-08). This package reverse depends / imports
/ suggests on 350 packages on CRAN and 25 packages on Bioconductor.
The only changes are small corrections on some help files, a new
function for stereographic projection, and `gcd` and `Lcm` require
integer inputs now (these functions are not used in the