Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
Solved

# generating logarithmically distributed numbers

Posted on 2009-02-17
Medium Priority
268 Views
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.
0
Question by:bmihura
• 4

LVL 85

Expert Comment

ID: 23659361
e^(log(1),
e^(log(1)*2+log(10))/3
e^(log(1)+2*log(10)/2
e^log(10)
0

LVL 85

Expert Comment

ID: 23659368
e^(log(1),
e^(log(1)*2+log(10))/3
e^(log(1)+log(10)*2)/3
e^log(10)
0

LVL 85

Accepted Solution

ozo earned 500 total points
ID: 23659393
e^(log(X)*i+log(Y)*(N-1-i))/(N-1)
for i=0..N-1
0

LVL 85

Expert Comment

ID: 23659683
equivalently
Y * (X/Y)^(i/(N-1))
0

Author Comment

ID: 23659859
Thanks, ozo, that got me most of the way there. I just needed to adjust your parentheses a little like this:

e^((log(X)*i+log(Y)*(N-1-i))/(N-1))
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);
``````
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
###### Suggested Courses
Course of the Month15 days, 21 hours left to enroll