Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a sequence $s$ of rational numbers where $|s|=n$. I am given a percentage $p$ to partition the sequence $s$ into $\frac{1}{p}$ parts, such that each part contains $p\%$ number of elements of the whole sequence.

However, it becomes problematic for certain $n$ and $p$ combinations. For example, for $n=50$ and $p=5\%$, we are supposed to obtain 20 parts/sub-sequences. If we have $3$ elements per part, we will only have 17 of them while the last one contains only $2$ elements. If we have $2$ elements per part, we will have 20 of them but the last one will contain $12$ elements.

The purpose of partitioning the sequence in the first place is to calculate the mean for each resulting sub-sequence, i.e. that of first $p\%$, that of second $p\%$, and so on.

So what is a good way to deal with this situation?

share|cite|improve this question
For 50 only partition into multiples of 2%. – i. m. soloveichik Aug 30 '12 at 20:38
@i.m.soloveichik, $p$ is given and I have to use that. – MLister Aug 30 '12 at 20:44

Obviously you can't divide it up exactly in these cases, so you have to approximate. If you have a set of $n$ elements to be partitioned into $m$ subsets, you can write $n = mq + r$ where $q = \lfloor n/m \rfloor$ and $r \in \{0,1,\ldots,m-1\}$. You can then take $m-r$ subsets of size $q$ and $r$ subsets of size $q+1$.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.