MathGroup Archive 2010

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

Search the Archive

Creating sub-list based on a given criterion


I was wondering if there is any straightforward way to bin a list into sub-lists containing those elements that full-fill a given criterion. Consider the following list


The criterion is that the sum of the second elements in each new sub-list should be at least 25?

After the re-binning we should get something like:


The first bin has a total of the second elements 588, the second 2345, the third 2418,...,the sixth 46, the seventh 29, â?¦,the eleventh 53, and the last one 35.

In other words, imagine that these are the results of a counting experiment and the second element in every entry (in  ds) corresponds to counts. The question is how can we re-bin the data in order to have at least 25 counts per new-bin?
Of course it is straightforward to do it using a Do-loop, but I was wondering if there is any simpler way to do it using the efficient Mathematica syntax in an â??one-liner expressionâ??.

Thanks a lot

  • Prev by Date: Re: precedence for ReplaceAll?
  • Next by Date: how to automatically include own package into different demonstration
  • Previous by thread: Orthogonalize in a discrete setting
  • Next by thread: Re: Creating sub-list based on a given criterion