MathGroup Archive 2007

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

Search the Archive

RE: On partitioning lists by intervals

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

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.) 
> Thanks for your help!

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

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

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

... 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]]




  • 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