1
$\begingroup$

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.

$\endgroup$

2 Answers 2

2
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ 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] $\endgroup$
    – Bradford
    Commented Dec 7, 2010 at 1:25
  • $\begingroup$ 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. $\endgroup$ Commented Dec 7, 2010 at 1:34
  • $\begingroup$ \left\lfloor\frac{s}{1+\left\lfloor\frac{n}{4i}\rfloor\right}\right\rfloor $\endgroup$ Commented Dec 7, 2010 at 1:56
  • $\begingroup$ @J.M.: seems to work. I'll use that next time. Thanks $\endgroup$ Commented Dec 7, 2010 at 2:42
0
$\begingroup$

in R:

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

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .