I am trying to generate n points on a normal distribution(say, mean \mu and standard deviation \sigma) that are equidistant(Let's say the distance between pints is d) from each other in C. Points at normal distribution are from (-3\sigma + \mu) to (3\sigma + \mu). I am trying to have beads on the Gaussian curve, where beads are at equal distance (curved length).
Thank you in advance for the answer.
Curve length of a function in $x$ can be found as
$$\ell_f(a, b) =\int_a^b \sqrt{1+\left(\frac{df(x)}{dx}\right)^2}dx$$
Which is nasty enough that in general we don't get an integrable result out of it; in our case we need to perform the integral and then invert it, and this is a recipe for sadness.
So what we'll do instead of this is do it numerically, replacing integration with the Riemann sum and differentiation with the difference quotient and doing a little simplifying.
$$\ell_f(a, b) = \lim_{\Delta x \rightarrow 0} \sum_{t=\frac{a}{\Delta x} + 1}^{\frac{b}{\Delta x}}\sqrt{\Delta x^2+\left(f(t\Delta x)-f((t-1)\Delta x)\right)^2}$$
Which still looks kinda mean but is possible to plug & chug by picking a reasonable value for $\Delta x$.
Of course, that only works forward, and we have to work backwards. Our best bet, since this is a series, is to do linear interpolation: draw straight lines between the points that make up the series. This gives a monotonic piecewise linear function, which is trivial to invert.
The procedure
We have our function $f(x)$, a low and high end of the interval in question $p$ and $q$, and a number of intervals to break the function into $n$.
Calculate $\Delta x = \frac{q-p}{n}$
For each integer $k$, $x_k = a + k\Delta x$, $y_k = f(x_k)$.
$d_k = \sqrt{(x_k - x_{k-1})^2 + (y_k - y_{k-1})^2} = \sqrt{\Delta x^2 + (y_k - y_{k-1})^2} $
$\ell_k = \sum_{i=1}^{k} d_k$
$m_k = \frac{\Delta x}{d_k}$
$b_k = x_k - \ell_k m_k$
And now we have a piecewise linear function: $x_f(\ell) = m_k \ell + b_k \text{ for } x_{k-1} \le \ell < x_k$
Now we wish to place $m$ spaces between points, so we take values $\frac{\ell_ni}{m}$ for $i$ in $0 \le i \le m$, find their $x$ values from the piecewise linear function above, and then from there the $f(x)$ values.
Example
Our star today is the standard normal distribution density function, $$f(x) = \frac{1}{\sqrt{2\pi}}e^{-\frac{x^2}{2}}$$
over the interval $-3 \le x \le 3$. I'll use $n = 6$ here for relative brevity and for relatively nice $x$ values.
at this point I want to point something out: the curve length of this function is only about 1% more than the width of our interval in $x$. There isn't going to be much difference between evenly spaced on $x$ and evenly spaced along the curve! In fact when we get our points, the largest difference between the two is about $0.008$. Still, the point here is a reasonably general procedure, so let's continue.
Now that we've got our piecewise linear function, we'll just plug in evenly-spaced $\ell$ values.
And we can plot these.