1
$\begingroup$

I have an x-axis which is in logarithmic scale representing frequency, I would like to have NumPoints on this axis that are equidistant on the log scale, I have the following variables:

Fmin = 100 Fmax = 4000 or 8000 NumPoints = 10

What formula should i use to calculate where the NumPoints-2 points between Fmin and Fmax should go? (Fmin and Fmax should each have a point on them)

Additionally, when i switch from Fmax = 4000 -> 8000 i would like to keep the equidistant points already calculated between Fmin->4000 and add extra points between 4000 and 8000.

Summary

Generate NumPoints between FMan -> Fmax(4000), equidistant on a log scale. Change Fmax -> 8000 Generate more points between 4000->8000.

Many thanks in advance

Andy

$\endgroup$
3
$\begingroup$

Since it's a log scale the ratio between two adjacent points is constant, i.e. you get the next point by multiplication: x[n] = x[n-1]*k. After ten multiplications you need to get from 100 to 4000 so k can be determined as $k = (4000/100)^{1/(n-1)} = 1.5066$. Your x points are then simply $x[n]= 100*k^{n}$ or

      100
   150.66
   226.99
      342
   515.26
   776.31
   1169.6
   1762.2
   2654.9
     4000

You can't get exactly to 8000 though. The next points would be 6026.5 and 9079.7. What would get you very close would be 17 points from 99.213 to 4000, the next points being 5039.7 6349.6 and 8000.

$\endgroup$
3
$\begingroup$

Take the log of your extremities, find your points as if it were on a linear scale beween these extremities, take the exponential of the result.

Example:

The log of your extremities are $\log 100$ and $\log 4000$. Your 10 points on a linear scale between these values would be: $\log 100 + k \frac{\log 4000 - \log 100}{9}$, $k \in \{0, 1, \ldots, 9\}$.

Taking the exponential: $e^{\log 100 + k \frac{\log 4000 - \log 100}{9}}$. Notice that the first and last values are 100 and 4000 as expected.

This works well with linspace in programming languages which have this primitive, for example with python/numpy:

numpy.exp(numpy.linspace(numpy.log(100), numpy.log(4000), 10))

The second part of your question is not clear. To generate more points by preserving the same spacing, continue increasing $k$ above 9.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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