Hello Nigel.
I agree to everything you have written. The random number generator, is very hard to replicate in AppleScript preserving almost the same quality. So, I have given up on making one to replace it in pure AS, with regards to saving any speed, retaining somewhat the quality. (But at least I figured out, what is doable with regards to speed. I realized the overhead of using a random number generator, when I performed the times, regarding the partitioning of quick sort. )
I might slack on quality at a later point, however, and maybe make something that can beat random number, still give sufficient quality with regards to the distribution of randomness. -I may also want to port this to “C”, so therefore I stuck with the random number.
I figured both the item, and the median was reasonable to return, all the time I had computed the median. It works as it should now, and it isn’t really meant to be used as a statistic median, more of a “computerese” median, for creating or manipulating partitions of datasets, or datasets, and such.
Thank you for finding the error in my first version.
Edit
It may be feasible to make a simple random number generator, that just gives you a random distance to one of the sides in the current range. The hard part, is to prove that it will work out feasibly.
The precursor to this algorithm, was invented in order to find the k’th runner up in a sports tournament.