How do I generate N numbers from X to Y, distributed logarithmically?

For example, if I wanted 4 numbers from 1 to 10, distributed logarithmically, these numbers would be roughly 1, 2, 5, and 10. But I'd like to compute the exact numbers.

For example, if I wanted 4 numbers from 1 to 10, distributed logarithmically, these numbers would be roughly 1, 2, 5, and 10. But I'd like to compute the exact numbers.

e^((log(X)*i+log(Y)*(N-1-i

for i=0..N-1

I've attached some working C# code in case it will help anybody.

```
// e^((log(X)*i+log(Y)*(N-1-i))/(N-1))
// for i=0..N-1
string s = "";
double X = 10;
double Y = 100;
double N = 5;
for (int i = 0; i < N; i++)
{
double value = Math.Exp((Math.Log(X) * i + Math.Log(Y) * (N - 1 - i)) / (N - 1));
s += value + "\r\n";
}
MessageBox.Show(s);
```

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

for i=0..N-1