Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a random ordered list from an ordered list

Tags:

algorithm

I have an application that takes the quality results for a manufacturing process and creates graphs both to show Pareto charts of the bad, and also to show production throughput.

To automate the task of testing these statistical procedures I would like to deterministically be able to add records into the database and have the quality tech go to certain graphs and compare to a known good graph. But, I also would like to simulate the results so they would go into the database as if a user was running through the testing process.

One idea I have had is to fill a list with i number good, j number bad1, k number bad 2, etc. And then somehow randomly sort the list before insertion into the database.

So, my question, is there a standard algorithm to take a sorted list of values and create a randomly sorted list?

like image 724
Ray Jenkins Avatar asked Oct 03 '08 17:10

Ray Jenkins


1 Answers

You'll want to use a shuffle algorithm. Make sure to use a proper shuffle algorithm and not a home-baked one, because it may introduce some form of subtle pattern to the data. See this post by Jeff Atwood about the problem with using "random enough" shuffles.

like image 92
Neil Williams Avatar answered Oct 20 '22 05:10

Neil Williams