Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Sum of list elements

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49325] Re: [mg49313] Sum of list elements
  • From: DrBob <drbob at bigfoot.com>
  • Date: Wed, 14 Jul 2004 07:29:30 -0400 (EDT)
  • References: <200407130832.EAA09643@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

a = {2, 2, 1};
a/Total[a]

{2/5, 2/5, 1/5}

Bobby

On Tue, 13 Jul 2004 04:32:49 -0400 (EDT), Per Rønne <spam at husumtoften.invalid> 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]
>



-- 
DrBob at bigfoot.com
www.eclecticdreams.net


  • Prev by Date: Re: Sum of list elements
  • Next by Date: Re: Sum of list elements
  • Previous by thread: Sum of list elements
  • Next by thread: Re: Sum of list elements