So I have two points in 1D, point A at 0, and point B at 1. Now I want to place X number points between these two points and control how close each point is to A and B based on a "shift" value. A lower value would push the X points closer to A, while a higher value pushes the points closer to B.

For example, when Shift = 0 and X = 2, then two points would lie equidistant between A and B (at .33 and .66). As shift increases, the two points start getting closer to B (ie, .5 and .75). However, I am having a hard time finding an equation that will produce the desired results. Any ideas?

link|improve this question
Try mathoverflow.com – heavyd Mar 5 '10 at 7:52
feedback

closed as off topic by Diago Mar 5 '10 at 7:42

Questions on Super User are expected to generally relate to computer software or computer hardware, within the scope defined in the faq.

1 Answer

You can use, for example, the following process:

  • start from distributing uniformly the X points points xi:

    xi = i/(X+1) , (i=1,2,...,X)

  • now, given a shift S, S>0, transform each point xi using

    x'i = f(xi) = xi^(1/S) , (i=1,2,...,X)

that, given X=3, will give you:

L=1 -> x1 = 0.25; x2 = 0.50; x3 = 0.75;
L=2 -> x1 = 0.50; x2 = 0.71; x3 = 0.87;
L=3 -> x1 = 0.63; x2 = 0.79; x3 = 0.91;

compressing toward the value 1 the uniformly distributed x values using an exponential function with exponent < 1. If you want to compress toward the value 0, than just use an exponent > 1.

link|improve this answer
awesome, moves the points just like I need... however, what would be a good way to go about making the shift more easily understood.... ie S=0 means all points lie on A, and S=2 means all points lie on B. The exponential increase works, but isn't as intuitive. – user24055 Mar 5 '10 at 8:01
feedback

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