On 18/01/2021 12:07, H e wrote:
> I have noticed, that JavaScript Math.random() is a little bit slow.
Please stop posting this. You are wrong - you simply don't understand
how to benchmark and measure speed. Once you have learned that, you
will find that the function is extremely fast - so much so that the time
is negligible compared to the time it takes a JavaScript engine to call
a function.
>
> My function:
>
> Use smallest possible time, create digit of it. Make 10 digit number of it.
> Use function 2^a1+3^a2+...+11^a10 to create next digit with suming it until 1 digit. Function should always remember a2,...,a10, which will be next a1,...,a9. When the function is called in the same second(smallest clock unit usually), then increase a reminder variable digit when function is called again. When not, use next time produced digit as next a10.
>
> If it is already made, then please give me references.
>
Making a good random number generator is not easy. It is hard to make
it at least reasonably random, and hard to make it efficient. You are
not qualified to do either - it takes a lot of mathematical knowledge
and experience, as well as solid understanding of low-level coding.
It can be fun to /try/ to make a random number generator, and you can
learn a lot from experimenting and playing around. But don't kid
yourself that /you/ can do something better than the standard library in
JavaScript (or any other language). Maybe one day you will reach that
level, but it's twenty years down the road at least.
Learn to benchmark and to experiment.