0
$\begingroup$

Are the algorithms for picking between 2 numbers randomly a lot less computer intensive than the algorithms for picking almost any number randomly? The definition of random for our purpose is anything that's random enough to be thought as being random by the general population. I am thinking it is true, but I wouldn't be able to say the exact reason why it would be the case.

$\endgroup$
3
  • $\begingroup$ I don't think we can answer, since your definition of random is not really a definition. It's not clear whether you talk of fix-length computer numbers (in this case, just select each bit randomly) or of $\mathbb R$ (in this case, you must specify a distribution). $\endgroup$
    – user114966
    Dec 6, 2020 at 17:32
  • $\begingroup$ It's trivial to pick a natural number between 41 and 43 at random. $\endgroup$
    – greybeard
    Dec 6, 2020 at 17:56
  • $\begingroup$ (There are "RNG"s giving values in [0, 1), to be scaled and shifted as needed.) $\endgroup$
    – greybeard
    Dec 6, 2020 at 17:57

1 Answer 1

1
$\begingroup$

In principle yes, but in practice probably not; both of them are likely to be extremely fast.

You can randomly choose between two numbers by generating a random bit. That is extremely fast in practice.

You can't "pick almost any number randomly". Instead, all you can do is sample from a distribution. The time it takes to sample from a distribution depends on the specific distribution you have in mind. However, for most cases commonly encountered, this too is very fast. For instance, if you want to pick uniformly at random an integer from a particular range, that can be done in a standard way by generating some random bits and then using them to select an integer; it will be very fast in practice.

So, while picking between two numbers might be quicker, both operations are likely to be so fast that it's not clear it is worth worrying too much about which is faster.

If you want to understand why this is the case, I suggest you study algorithms for picking a random number and for sampling from various distributions; that will give you a concrete understanding.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.