Re: simple vactor magitude question
- To: mathgroup at smc.vnet.net
- Subject: [mg43811] Re: simple vactor magitude question
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Tue, 7 Oct 2003 02:40:51 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <blj5e0$1dv$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi, p = Table[Random[], {10}]; and Sum[p[[i]]*(i-1),{i,1,Length[p]}] can be written as MapIndexed[#1*(First[#2] - 1) &, p] Regards Jens Nathan Moore wrote: > > Suppose I generate a 1-d vecctor of "N" numbers, p[i], and now I want to > find the sum of (the vector element * index). I think the syntax should look > something like, > > Sum[p[i]*i,{i,0,N}] > > but this doesn't seem to be the correct syntax - any help would be > appreciated. > > Nathan Moore, > University of Minnesota Physics