MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Sum of list elements

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49315] Re: [mg49313] Sum of list elements
  • From: "Ravinder Kumar B." <ravi at crest.ernet.in>
  • Date: Tue, 13 Jul 2004 05:23:18 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

It is easy to acheive using Map (@@) function as follows:

A={1,2,3,4,5};
B=A/Plus@@A;
gives the desired result
B={1/15,2/15,3/15,4/15,5/15}



On Tue, 13 Jul 2004, Per Rønne wrote:

> I'm trying to find a function [possibly a way to make a function] which
> calculate the sum of the elements of a list.
>
> Right now, the purpose is to find the relative distribution of the
> elements of a list. That is, I need a way to get out that the
> distribution of:
>
> {2, 2, 1}
>
> is
>
> {2/5, 2/5, 1/5}.
>
> Had I been able to get the sum of the list elements in this way:
>
> Sum[{2, 2, 1}]
>
> it could had been done with:
>
> l = {2, 2, 1}
> l / Sum[l]
>
>

-- 
 Regards,                                   Jul 13
    Ravi



         |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
         |           Ravinder Kumar Banyal (SRF),                |
         |          Indian Institute of Astrophysics,            |
         |           Koramangala Bangalore - 560 034. INDIA      |
         | email : banyal at iiap.res.in, ravi at crest.ernet.in       |
         | Ph No : 080 25530672 (IIA)       080 7931972 (Hoskote)|
         |                                     7931952           |
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Philosophers have interpreted the world in various ways, but the point is
to change it. --Karl Marx


  • Prev by Date: Re: customizing Integrate with Unprotect
  • Next by Date: Re: ArcCos[x] with x > 1
  • Previous by thread: Re: Sum of list elements
  • Next by thread: Re: Re: Sum of list elements