I need to get a sequence of shuffled elements in a range, but I want to determine how much this sequence should be shuffled. For example, suppose our range is 1-100 and I want a sequence of 10 numbers. All of these sequences are valid:{1,5,17,43,44,67,77,77,83,90}{1,90,17,43,44,77,77,67,83,5}{67,5,90,77,43,77,17,1,83,44}As you can see, all of elements of the three sequences are the same, but they are shuffled with different intensity. The first sequence is sorted, (that is, is not shuffled), the second one is shuffled a little, and the last one is shuffled much more ( and perhaps only this one is really shuffled :) ).Now I want a method so that I can get such sequences based on an indicator called shuffle intensity indicator, or si2.My ApproachI hope this section doesn't make my question a XY problem. I only want to share my approach and it is not point of the question. However, I will be happy if my questions in this section are answered. I used the following series of commands in order to get a sequence of 2,000,000 numbers in the range 1-2000000:  for i in `seq 10000`; do     shuf -i 1-2000000 -r -n 100 | sort ; shuf -i 1-2000000 -r -n 100;     done > input As you can see, the sequence has 10,000 chunks of 100 numbers that are decussate  sorted and shuffled sequences. I can, for instance, use 150 instead of first 100 and 50 instead of second, so the shuffle intensity gets quadruple. But this approach has some problems (at least for me).This approach is too slow ( and I want to know why. I found that the bigger the chunks are, the faster the operation will be.).It also requires manual determination of the two numbers thatindicate shuffle intensity.And, perhaps most importantly, it is not really shuffled randomly. Asyou can see, the chunk sizes are the same.Ideal solutionIdeally, I want a script with options like this:myshuf SI2 MIN MAX NUM [OUTPUT] while MIN and MAX determine the range, NUM determines the size of sequence and SI2 is shuffle intensity indicator. The higher the SI2 is, the more intense shuffle will be. SI2 will be between 0 and 10.  Somyshuf 0 0 2000000 2000000gives a sorted sequence of 2,000,000 numbers between 0 and 2,000,000 andmyshuf 10 0 2000000 2000000gives a very-good-shuffled sequence. If you are curios to know why I need such sequences, I should say I have some sorting algorithms and I want to try each one and see their time complexity on different kinds of inputs.
How to get a randomly shuffled sequence based on shuffle intensity indicator?
shell script