Pseudorandom numbers - Get a sequence of number not close each others

128 Views Asked by At

I have this function inside a software:

a+(SeededRand(Round((SongTime-0.5+(Round(1000*c)))*1))-0.5)*b

it creates a pseudo-random numbers sequence inside the [0,1] interval.

The problem is that some values can be so close each others, such as :

6° number is 0.77569580078125
7° number is 0.781097412109375

is there a way to have a sequence of numbers not close each others? In the order of 0,2 distance, for example.

Hope the question is clear, else let me know and I'll try to explain it better...

2

There are 2 best solutions below

0
On

There is no way to do this, if you want (pseudo) random properties. Even if you randomly select from the numbers 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 there must be a positive probability that a number is the same as its neighbour in the generated sequence.

1
On

Do you want random numbers or maybe evenly-spaced numbers? The more evenly-spaced your numbers are, the less random those will be.

If you don't care how much random your numbers will be, you can always discard a newly selected point you and try again and again until you have found one that is not as close to the others. Other methods would involve introducing "safe zones", calculating the total size of it, selecting randomly and adjusting the result back into $[0,1]$ interval. There are yet other approaches, but remember, it will be less random, than just plain picking. Random numbers intrinsically form (random) clusters and it's just a popular human misconception that random should be evenly-spaced.

I hope this helps ;-)