dbirkigt

Python Random.Sample does not seem that random

Discussion created by dbirkigt on Feb 7, 2012
Latest reply on Feb 9, 2012 by lpugh01
Hi, Please see the attached GIF image

I am trying to make a little tool to make random selections of features from feature classes by randomly selecting FIDs. What it does is:
1.Creates a python list of feature FIDs
2. Using the random.sample I draw a number of samples from my python list of FIDs, the number drawn is equivalent to what the user desires
3. This is then converted to a sql statement allowing a selection to be made and stored in a new feature class

I don't have trouble with my code, but the output does not seem to be that random, as the gif below shows

I have tried random.shuffle and other variations but seem to get a similar output.
Does anyone know anything about getting a better result, different method perhaps?
Right now I am working on some test data and my population is about 300 with a sample of 30.

Here is the part of my code that lists the FIDs and makes a selection
rows = arcpy.SearchCursor(InputToSample)
for row in rows:
    fidVal = row.getValue(FieldName)
    fidList.append(fidVal)
#make a random selection
rndList = random.sample(fidList, numSample)




Thanks
David


[ATTACH=CONFIG]11785[/ATTACH]

Attachments

Outcomes