# Distirbution of Points along a Line

I am facing the following problem:

Given is a line of length $L$ which I want to split into $N$ segments. The lengths of the first $(s_1)$ and last segment $(s_N)$ are given. You can assume that the first and the last segment are shorter than the average length $s_{ave} = \frac{L}{N}$ but they are not required to be equal. There should be a smooth transition, no sudden jump. The segment length should therefore increase at the beginning and decrease again towards the end of the line.

I am looking for a simple algorithm that could do this for me. I was trying to use (one or multiple) geometric series: $s_i = \alpha s_{i-1}$. If you specify the growth factor $\alpha$, the length (partial sum) is given by $L = s_1 \frac{\alpha^N -1}{\alpha -1}$ and if you specify the first and last segment length, $\alpha$ must satisfy $\alpha = (\frac{s_N}{s_1})^{\frac{1}{N}}$. Thus the system is overspecified if you fix $N, L, s_1, s_N$. Even if you split the problem, say into an increasing section, one where the length is constant and another one wehere the length decreases. Eventually you have to specify everything in one section.

• What is your question specifically? You can use logarithmic sampling and change the base for different spacing. May 22 '17 at 13:55
• I want the distribution to match the spacing at both ends, where the spacing at the left end is not necessarily the same as at the right end. At the same time the overall length and the number of points is fixed. Logarithmic spacing would be fine if the spacing only had to match one end. May 22 '17 at 16:50
• I just noticed your answer. If you use the handle of the person, e.g. @benno, she will be notified. Jun 2 '17 at 4:48

You can uniformly distribute points and apply transformation, $$N_s(\zeta)=1-\zeta\\ N_e(\zeta)=\zeta\\ \phi(\zeta)=x_sN_s(\zeta)+x_eN_e(\zeta)+ \sum_i \alpha_i L_i(2\zeta-1) N_s(\zeta)N_e(\zeta)$$ where $L_i$ is Legendre polynomial. So if you set for example $\alpha_0=0$ and $\alpha_1=1$, you will get your distribution, when you apply function $\phi(\zeta)$ to points uniformly distributed between $(0,1)$.
• You can only have second one. You can add more if you like as well. This give you some flexibility to change density of the points. Density is derivative of $\phi(ksi)$. May 22 '17 at 17:38