Re: [R] multiplication question

From: Moshe Olshansky <m_olshansky_at_yahoo.com>
Date: Mon, 07 Jul 2008 15:54:12 -0700 (PDT)


The answer to your first question is
sum(x)8sum(y) - sum(x*y)

and for the second one

x %*% R %*% y - sum(x*y*diag(R))

> From: Murali Menon <feanor0_at_hotmail.com>
> Subject: [R] multiplication question
> To: r-help@stat.math.ethz.ch
> Received: Thursday, 3 July, 2008, 2:30 AM
> folks,
>
> is there a clever way to compute the sum of the product of
> two vectors such that the common indices are not multiplied
> together?
>
> i.e. if i have vectors X, Y, how can i compute
>
> Sum (X[i] * Y[j])
> i != j
>
> where i != j
>
> also, what if i wanted
>
> Sum (X[i] * Y[j] * R[i, j])
> i != j
>
> where R is a matrix?
>
> thanks,
>
> murali
>
>
> _________________________________________________________________
> Enter the Zune-A-Day Giveaway for your chance to win —
> day after day after day
>
> M_Mobile_Zune_V1
> [[alternative HTML version
> deleted]]______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 07 Jul 2008 - 22:58:36 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 Jul 2008 - 23:31:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive