Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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'm given a number (n), an interval (i), and the number of steps (s). I want to distribute these numbers over that criteria as best as possible. The upper bounds would be n (which is critical) and lower bounds is greater than or equal to 0.75 * n (but divisible by the interval). So, if n=100, i=5, and s=6, you'd have [100, 95, 90, 85, 80, 75]. This one is easy because 100*.75 is <= s*i. How would you do n=25, i=2.5, and s=6?

This was a problem I came across while programming and was wondering if there was some mathematical concept that fit this problem.

Also, I had no idea what to tag this under.

share|cite|improve this question
up vote 2 down vote accepted

If I understand you, the ideal situation is to have your set be $[n, n-i, n-2i, \ldots,n-(s-1)i]$, which has s members. To keep this within the top $0.75n$, you need $(s-1)i\leq .25n$, which is just satisfied in your first example. In your second it is not, so you need to decide what to give up. You could forget about the 0.75 criterion and keep the interval, giving $[25, 22.5, \ldots,12.5]$ Or you could maintain the 0.75 criterion and reduce the step size, giving an interval of 1.25.

share|cite|improve this answer
The interval must stay the same and the 0.75 criterion must stay. My only option is to duplicate [20, 20, 22.5, 22.5, 25, 25] – Bradford Dec 7 '10 at 1:25
Then you can calculate how many intervals fit in the allowable range. The number of intervals is $\lfloor\frac{.25n}{i}\rfloor$ and so you have one more than that allowable values. Then there will be $$\lfloor \frac {s}{1+\lfloor\frac {.25n}{i}\rfloor}\rfloor $$ copies of each one plus the remainder, presumably starting from the top. The floor should surround the whole fraction, but I don't know how. – Ross Millikan Dec 7 '10 at 1:34
\left\lfloor\frac{s}{1+\left\lfloor\frac{n}{4i}\rfloor\right}\right\rfloor – J. M. Dec 7 '10 at 1:56
@J.M.: seems to work. I'll use that next time. Thanks – Ross Millikan Dec 7 '10 at 2:42

in R:

seq(from=25, by=-2.5, length=6)

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.