vendredi 24 février 2017

UNBELIEVABLE: Image generated from random (?) numbers [JavaScript]

What I just discovered completelly confused me. I still think there is some simple explanation of what is going on.

I had free time, so I used to play with random numbers, image processing, generating different fractals etc. So, I created an image of 618x412 pixels and I wanted to plot javascript random numbers (each representing RGB value from 0 to 255). Of course, the resulting image looks pretty random, I couldn't find any pattern (which means JavaScript uses good pseudorandom number generator).

But, then I tried something other. I created an array of length 618 * 412 * 3 (3 bytes for RGB) and filled the array with results of Math.random().toString(). So, array is now filled with strings. Then for each element I calculated CRC32 modulo 256, so I got array filled with proper RGB values. And finally I plotted that array to image.

At first, I was shocked. I didn't believe what I see. So, THIS IS THE RESULT. Maybe I am wrong, but this DOESN'T look as random numbers at all. Can youu see the same thing as mine? I have no explanations.

Ok, then I tried to do similar things. For example, I changed dimensions of image. The resulting image looks pretty same, but each row is shifted (left or right). Changing height doesn't affects image. I tried to calculate some other CRC function, I tried to use toString(16) instead of toString, but the results in all these cases looks pretty normal LIKE THIS. Only using the exact same parameters I got unexpected result. If I change any parameter, it works pretty random.

What is happening here? Is this a JavaScript easter egg, or it has something to do with the way we calculate CRC32? Is this a v8 easter egg? Any explanations? Are we really facing the fact that we do not understand this world at all?




Aucun commentaire:

Enregistrer un commentaire