Displaying 20 results from an estimated 2000 matches similar to: "make a triple summation more efficient"
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
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, ]
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
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
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
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.
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
2005 Jun 15
2
need help on computing double summation
Dear helpers in this forum,
This is a clarified version of my previous
questions in this forum. I really need your generous
help on this issue.
> Suppose I have the following data set:
>
> id x y
> 023 1 2
> 023 2 5
> 023 4 6
> 023 5 7
> 412 2 5
> 412 3 4
> 412 4 6
> 412 7 9
> 220 5 7
> 220 4 8
> 220 9 8
> ......
>
Now I want to compute the
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 Aug 02
1
My R code is not efficient
Dear R users,
I have two n*1 integer vectors, y1 and y2, where n is very very large.
I'd like to compute
elbp = 4^(y1) * 5^(y2) * sum_{i=0}^{max(y1, y2)} [{ (y1-i)! * (i)! *
(y2-i)! }^(-1)];
that is, I need to compute "elbp" for each (y1, y2) pair.
So I made R code like below, but I don't think it's efficient
Would you plz tell me how to avoid this "for"
2007 Oct 17
2
Need help with function that includes 2 summation
I am relatively new to R, so this may be a much simpler question than it
seems to me. I am trying to create a function that includes two
summations, and can't figure out how. I am attaching the equation as a
pdf file. This function will then be optimized over a chosen range of
values, but right now I just need help with the function. Thank you.
Zack Darnell
Duke University
--
Zack
2011 Aug 11
5
generate two sets of random numbers that are correlated
Dear R users
I'd like to generate two sets of random numbers with a fixed correlation
coefficient, say .4, using R.
Any suggestion will be greatly appreciated.
Regards,
Kathryn Lord
--
View this message in context: http://r.789695.n4.nabble.com/generate-two-sets-of-random-numbers-that-are-correlated-tp3735695p3735695.html
Sent from the R help mailing list archive at Nabble.com.
2012 Jun 25
4
do.call or something instead of for
Dear R users,
I'd like to compute X like below.
X_{i,t} = 0.1*t + 2*X_{i,t-1} + W_{i,t}
where W_{i,t} are from Uniform(0,2) and X_{i,0} = 1+5*W_{i,0}
Of course, I can do this with "for" statement, but I don't think it's good
idea because "i" and "t" are too big.
So, my question is that
Is there any better idea to avoid "for" statement
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
2011 Oct 13
5
Counting the number of integers at one swoop
Dear R users,
I'd like to count the number of integers in a vector y.
Here is an example.
y <- c(0,1,1,3,3,3,5,5,6)
In fact, I know how to count the number of specific number in y.
sum(y==0) -> 1
sum(y==1) -> 2
sum(y==2) -> 0
sum(y==3) -> 3
sum(y==4) -> 0
sum(y==5) -> 2
sum(y==6) -> 1
However, in one computation I want to get this vector [1,2,0,3,0,2,1].
Thank
2009 Jul 28
3
character vector -> numeric matrix ??
Dear R users...
I'd like to change this character vector, "zz",
zz <- c("12","56","89")
to the following numeric matrix.
[,1] [,2]
[1,] 1 2
[2,] 5 6
[3,] 8 9
Actually, "zz" vector has a long length.
Any comments will be greatly appreciated.
Kathryn Lord
--
View this message in context:
2016 Apr 08
1
write a function inside the summation in a more condensed form
Dear R Experts
that's my original equation
> x=c(2,4)
> Y1=sum(sapply(1:2,function(i){sum(sapply(1:i,function(j){(3^(x[i]+x[j]))}))}))
> y1
[1] 7371
I want to write the inside function (3^(x[i]+x[j])) in a more condensed form cause this will help me when the multiple summations are more than two
I've tried the following form
>
2006 Oct 03
1
Summation in R
Hello!
Maybe this is a trivial question as I'm still a new baby in R but I wish
that u will help me.
I want to calculate the following
U= sum (t_j*v_j)
where t_j is a vector
and v_j is the matrix
Thanks
Dina
2008 Oct 08
3
Re move repeated values
Dear R users,
I'd like to make this data
rem.y = c(-1,0,2,4,5)
from
y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5).
That is, I need to remove repeated values.
Here is my code, but I don't think it is efficient. How could I improve
this?
#------------------------------------------------------------------------
y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5)
n=length(y)
for (i in 1:n) #
2010 Apr 16
3
VERY SIMPLE QUESTION
Dear R users,
I am looking for more efficient way to compute the followings
--------------------------------------------------------------------------
a <- matrix(c(1,1,1,1,2,2,2,2),4,2)
b <- matrix(c(1,2,3,4),4,1)
Eventually, I want to get this matrix, `c`.
c <- matrix(c(1/1,1/2,1/3,1/4,2/1,2/2,2/3,2/4),4,2)
--------------------------------------------------------------------------