I have a list of names sorted from most common to most rare. I needed to choose random names where the most common names would show up more often. So I used your RandomDist function like so. All the names were placed into an array, with element 0 being the most common name, all the way up to element 5000 (or whatever) being most rare.
int t = nameList.length;
int n = randomDist(0, t * 2, 3); // n is between 0 and t, with most numbers around half t
n -= t; // range is now -t to t with most numbers being around 0
int index = math.abs(n); // index is now range 0 to t, with most numbers being around 0
string name = nameList[index];
Hello Mr. Peters, your tutorials are the best i found on youtube, if you would write a book on physics/math with javascript i would buy it, no doubt. Thank you very much for helping us out with such great tutorials. Respect!
@kevnar