Displaying 20 results from an estimated 10000 matches similar to: "Summing functions of lists"
2010 Jun 15
1
Error in nlm : non-finite value supplied by 'nlm'
Hello,
I am trying to compute MLE for non-Gaussian AR(1). The error term follows a difference poisson distribution. This distribution has one parameter (vector[2]).
So in total I want to estimate two parameters: the AR(1) paramter (vector[1]) and the distribution parameter.
My function is the negative loglikelihood derived from a mixing operator.
f=function(vector)
2019 Feb 19
4
code for sum function
The algorithm does make a differece. You can use Kahan's summation
algorithm (https://en.wikipedia.org/wiki/Kahan_summation_algorithm) to
reduce the error compared to the naive summation algorithm. E.g., in R
code:
naiveSum <-
function(x) {
s <- 0.0
for(xi in x) s <- s + xi
s
}
kahanSum <- function (x)
{
s <- 0.0
c <- 0.0 # running compensation for lost
2003 Dec 30
1
Accuracy: Correct sums in rowSums(), colSums() (PR#6196)
Full_Name: Nick Efthymiou
Version: R1.5.0 and above
OS: Red Hat Linux
Submission from: (NULL) (162.93.14.73)
With the introduction of the functions rowSums(), colSums(), rowMeans() and
colMeans() in R1.5.0, function "SEXP do_colsum(SEXP call, SEXP op, SEXP args,
SEXP rho)" was added to perform the fast summations. We have an excellent
opportunity to improve the accuracy by
2008 Oct 24
3
Computational problems in R
Dear all,
I would be grateful if anyone can help me with the following:
My aim is to compute explicitely the sum S=A+B where A=sum(exp(c_i/d)),
i=1,...,n;
B, c_i, and d are real numbers with -Inf<B,c_i<+Inf; and d>0.
The problem is that when c_i/d >710 (for some i) R is setting
exp(c_i/d) to be equal to +Inf and hence the whole summation S.
So in simple cases where for example c_i=8
2009 May 01
2
Double summation limits
Dear R experts
I need to write a function that incorporates double summation, the problem
being that the upper limit of the second summation is the index of the first
summation, i.e:
sum_{j=0}^{x} sum_{i=0}^{j} choose(i+j, i)
where x variable or constant, doesn't matter.
The following code obviously doesn't work:
f=function(x) {j=0:x; i=0:j; sum( choose(i+j,i) ) }
Can you help?
Thanks
2004 Mar 16
3
multiple summation
Hello,
I have to compute a multiple summation (not an integration because the
independent variables a
are discrete) for all the values of a function of several variables f
(x_1,...,x_n), that is
sum ... sum f(x_1,...,x_n)
x_1 x_n
have you some suggestion? Is it possible?
I know that for multiple integration there is the function adapt, but it has at
most n=20. In my case n depends on the
2017 Dec 27
2
Numerical stability in chisq.test
The chisq.test on line 57 contains following code:
STATISTIC <- sum(sort((x - E)^2/E, decreasing = TRUE))
However, based on book "Accuracy and stability of numerical algorithms" available from:
http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf
Table 4.1 on page 89, it is better to sort the data in increasing order
2011 Jul 11
1
Summation resulting in a list?
Probability <- function(N, f, m, b, x, t) {
#N is the number of lymph nodes
#f is the fraction of Dendritic cells (in the correct node) that have the
antigen
#m is the number of time steps
#b is the starting position (somewhere in the node or somewhere in the gap
between nodes. It is a number between 1 and (x+t))
#x is the number of time steps it takes to traverse the gap
#t is the number
2011 Feb 12
1
how to improve the precison of this calculation?
Hello
T
I want to order some calculation "result", there will be lots of "result" that need to calculate and order
PS: the "result" is just a intermediate varible and ordering them is the very aim
# problem:
# For fixed NT and CT, and some pair (c,n). order the pair by corresponding result
# c and n are both random variable
CT<-6000 #assignment to CT
2009 Mar 26
2
sum to infinity
Hi r-users,
How do we evaluate the summation of (1/m!) from 0 to infinity (for example).
Any help is very much appreciated.
Thank you.
2008 Aug 29
1
more efficient double summation...
Dear R users...
I made the R-code for this double summation computation
http://www.nabble.com/file/p19213599/doublesum.jpg
-------------------------------------------------
Here is my code..
sum(sapply(1:m, function(k){sum(sapply(1:m,
function(j){x[k]*x[j]*dnorm((mu[j]+mu[k])/sqrt(sig[k]+sig[j]))/sqrt(sig[k]+sig[j])}))}))
-------------------------------------------------
In fact, this is
2012 Oct 18
7
summation coding
I would like to code the following in R: a1(b1+b2+b3) + a2(b1+b3+b4) +
a3(b1+b2+b4) + a4(b1+b2+b3)
or in summation notation: sum_{i=1, j\neq i}^{4} a_i * b_i
I realise this is the same as: sum_{i=1, j=1}^{4} a_i * b_i - sum_{i=j} a_i
* b_i
would appreciate some help.
Thank you.
--
View this message in context: http://r.789695.n4.nabble.com/summation-coding-tp4646678.html
Sent from the R
2009 Aug 20
1
how to compute this summation...
Dear R users,
I try to compute this summation,
http://www.nabble.com/file/p25054272/dd.jpg
where
f(y|x) = Negative Binomial(y, mu=exp(x' beta), size=1/alp)
http://www.nabble.com/file/p25054272/aa.jpg
http://www.nabble.com/file/p25054272/cc.jpg
In fact, I tried to use "do.call" function to compute each u(y,x) before the
summation, but I got an error, "Error in X[i, ]
2007 Oct 25
3
Deparsing part of a list argument
Here's a simple example of the type of function I'm trying to write,
where the first argument is a list of functions:
myfun <- function(funlist, vec){
tmp <- lapply(funlist, function(x)do.call(x, args = list(vec)))
names(tmp) <- names(funlist)
tmp
}
> myfun(list("Summation" = sum, prod, "Absolute value" = abs), c(1, 4, 6, 7))
$Summation
[1]
2012 May 18
3
LM with summation function
Hi all,
I'm trying to model some data where the y is defined by
y = summation[1 to 50] B1 * x + B2 * x^2 + B3 * x^3
Hopefully that reads clearly for email.
Anyway, if it wasn't for the summation, I know I would do it like this
lm(y ~ x + x2 + x3)
Where x2 and x3 are x^2 and x^3.
However, since each value of x is related to the previous values of x, I
don't know how to do this.
2012 Oct 26
3
summation sign
Hi all,
I have a very quick question on how to use the summation sign in R for the
function.
Here?s a basic example: the function is sum(i=1 to 5)log(1-xi^2)
Id be grateful if someone knows how to do this without writing it out 5
times - I am looking sth along the lines of the following:
computeR <- function(x)
{
return (-sum(log(1-x^2))
}^
thank you vm in advance!
--
View this
2008 Nov 15
1
make a triple summation more efficient
Dear R users...
I made the R-code for this triple summation computation
http://www.nabble.com/file/p20517134/a.jpg
-------------------------------------------------
Here is my code..
x=seq(.1,1,.1); l=10
y=seq(1,10); m=10
z=seq(.1,1,.1); n=10
sum(sapply(1:l, function(i) {sum(sapply(1:m, function(j) {sum(sapply(1:n,
function(k){exp(x[i]*y[j]*z[k] )/gamma(y[j]+1)}))^(1.5) }))}))
2006 Feb 19
2
Computing means, variances and sums
There has been a recent thread on R-help on this, which resurrected
concepts from bug reports PR#1228 and PR#6743. Since the discussion has
included a lot of erroneous 'information' based on misunderstandings of
floating-point computations, this is an attempt to set the record straight
and explain the solutions adopted.
The problem was that var(rep(0.02, 10)) was observed to be (on
2019 Feb 14
5
code for sum function
Hello,
I am trying to write FORTRAN code to do the same as some R code I have.
I get (small) differences when using the sum function in R. I know there
are numerical routines to improve precision, but I have not been able to
figure out what algorithm R is using. Does anyone know this? Or where
can I find the code for the sum function?
Regards,
Rampal Etienne
2019 Feb 20
0
code for sum function
Dear Will,
This is exactly what I find.
My point is thus that the sum function in R is not a naive sum nor a
Kahansum (in all cases), but what algorithm is it using then?
Cheers, Rampal
On Tue, Feb 19, 2019, 19:08 William Dunlap <wdunlap at tibco.com wrote:
> The algorithm does make a differece. You can use Kahan's summation
> algorithm