RE: On partitioning lists by intervals

• To: mathgroup at smc.vnet.net
• Subject: [mg80414] RE: [mg80396] On partitioning lists by intervals
• From: "David Annetts" <davidannetts at aapt.net.au>
• Date: Wed, 22 Aug 2007 04:37:29 -0400 (EDT)
• References: <200708210903.FAA14595@smc.vnet.net>

```Hi Mauricio

> I'm just starting in mathematica and I realise this is a very
> basic question, but I tried to find an answer on the
> documentation center for a couple of hours and on the archive
> for mathgroup, but couldn't find it.
> I have a list of say 500 different random values. I need to
> divide it in n intervals of fixed length (for example, the
> lowest value is 0 and the maximum 100 so I need to get
> sublists of values that go from 0 to 10, 10 to 20, etc.)

... You want to bin your data into particular intervals.

The easiest way is using BinLists.  First, generate some data

data = RandomReal[{0, 100}, 500];
Length@data

... And bin them

datab = BinLists[data, 10];

If you only want to count the number of samples in a particular bin (ie for
a histogram), you can use BinCounts or you can Map[] the function Length[]
to each element of the array datab

binc = Length[#]& /@ datab
SameQ[binc, BinCounts[data, 10]]

Regards,

Dave.

```

• Prev by Date: Re: generalized 2d IFS for D_n Cartan group using MathWorld
• Next by Date: Re: But is it worth to use Mathematica ?
• Previous by thread: Re: On partitioning lists by intervals
• Next by thread: Re: On partitioning lists by intervals