hi all. I am working with a list and would like to choose from the list randomly but not uniformly. I am interested in several distributions but the first one i looked at is Gaussian.
which you call like so: random.gauss(mean, dev) You can try this code courtesy of effbot (http://effbot.org/ librarybook/random.htm) # File: random-example-3.py import random histogram = [0] * 20 # calculate histogram for gaussian # noise, using average=5, stddev=1 for i in range(1000): i = int(random.gauss(5, 1) * 2) histogram[i] = histogram[i] + 1 # print the histogram m = max(histogram) for v in histogram: print "*" * (v * 50 / m) fine this works and works well... one problem with this... if you are using this to create an index to a list you might be in trouble as each time you run it you get a slightly different min and max value. so... how does one safely pick from a list of say 15 elements with a large bias towards the center values without over or under-running the bounds of your list? cheers, kevin ps. what would be the opposite of the Gaussian distro the scoop like one, the one where the outer elements are favored. Is that in the python standard lib? (or numpy?) _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor