MathGroup Archive 2007

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

Search the Archive

Re: On partitioning lists by intervals

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80493] Re: On partitioning lists by intervals
  • From: Donald DuBois <donabc at comcast.net>
  • Date: Thu, 23 Aug 2007 01:18:59 -0400 (EDT)

> Hello there.
> 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!
> 
> cd
> 

Since the lowewt value is 0 and the  highest is 100
there are 101 possible values which is not divided evenly
by an interval of 10.  Suppose the values go from 1 to 100 with a fixed interval of 10 then the following should
work.

lst = RandomInteger[{1,100}, 500];
BinCounts[lst, {Range[1,101,10]}]

{43, 45, 44, 53, 50, 59, 53, 52, 57, 44}

The intervals are 1 to 10, 11 to 20, ... 91 to 100.
 
Hope that helps,
Don


  • Prev by Date: Re: PlotStyle in version 6
  • Next by Date: Re: Redefine Arg to return a value from 0 to 2 pi
  • Previous by thread: Re: On partitioning lists by intervals
  • Next by thread: Re: On partitioning lists by intervals