in reply to Rand() with ?log10? distribution?
10**( log(1/(1-rand()))/log(2) ) - 1
[Update: You may want to shorten the range if you get too many small (0.x) values or values that are too large. Replace 1-rand() with, for example .9-.8*rand().]
10**( -log(1-rand())/log(2) ) - 1 # (same thing) (1-rand())**(log(.1)/log(2)) - 1 # (same thing)
- tye
I'd show the (interesting) derivation, except the more words I include in a reply to you, the more likely the whole thing will turn ugly.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Rand() with ?log10? distribution? (math)
by BrowserUk (Patriarch) on Jun 07, 2013 at 05:51 UTC |