Skip to main content
Commonmark migration
Source Link

First: if the challenge defines random as something other than the default or uniform, new Date%N may be valid or not on a case by case basis. For example, if random means "with non-zero probability" or something similar, new Date should be OK.

#Is the current time uniformly random?

Is the current time uniformly random?

I believe that answer to that question, which is the real question here, is no. If, for example, you want to get many truthy or falsey values, new Date%2 will give you something like 1,1,1,1,0,0,0,0,0,1,1,1. That doesn't look "uniform" to me.

First: if the challenge defines random as something other than the default or uniform, new Date%N may be valid or not on a case by case basis. For example, if random means "with non-zero probability" or something similar, new Date should be OK.

#Is the current time uniformly random?

I believe that answer to that question, which is the real question here, is no. If, for example, you want to get many truthy or falsey values, new Date%2 will give you something like 1,1,1,1,0,0,0,0,0,1,1,1. That doesn't look "uniform" to me.

First: if the challenge defines random as something other than the default or uniform, new Date%N may be valid or not on a case by case basis. For example, if random means "with non-zero probability" or something similar, new Date should be OK.

Is the current time uniformly random?

I believe that answer to that question, which is the real question here, is no. If, for example, you want to get many truthy or falsey values, new Date%2 will give you something like 1,1,1,1,0,0,0,0,0,1,1,1. That doesn't look "uniform" to me.

deleted 387 characters in body
Source Link
Stephen
  • 14k
  • 11
  • 24

I believe this challenge may have been what prompted your question. Usually,First: if the challenge creators should define random. Ifdefines random is not definedas something other than the default or uniform, it means use your language's builtin for random (see this meta post)new Date%N may be valid or not on a case by case basis. If the challenge creator says "uniformly" randomFor example, that usuallyif random means that a PRNG"with non-zero probability" or something similar is good enough, new Date should be OK.

However: in this case,#Is the challenge definescurrent time uniformly random as?

I believe that answer to that question, which is the real question here, is each possibility has a non-zero probability of being chosenno. It does not need to be uniformIf, it just needs to be possible for both choicesexample, you want to occur. Therforeget many truthy or falsey values, new Date%2, will give you something like (Math.random()*100)|01,1,1,1,0,0,0,0,0,1,1,1 (which will only return falsey about 1/100th of the time) and other non-uniform multi-choice options, are all valid, under non-zero probability random.

TL;DR read the challenge specs That doesn't look "uniform" to me.

I believe this challenge may have been what prompted your question. Usually, challenge creators should define random. If random is not defined, it means use your language's builtin for random (see this meta post). If the challenge creator says "uniformly" random, that usually means that a PRNG or similar is good enough.

However: in this case, the challenge defines random as each possibility has a non-zero probability of being chosen. It does not need to be uniform, it just needs to be possible for both choices to occur. Therfore, new Date%2, (Math.random()*100)|0 (which will only return falsey about 1/100th of the time) and other non-uniform multi-choice options, are all valid, under non-zero probability random.

TL;DR read the challenge specs

First: if the challenge defines random as something other than the default or uniform, new Date%N may be valid or not on a case by case basis. For example, if random means "with non-zero probability" or something similar, new Date should be OK.

#Is the current time uniformly random?

I believe that answer to that question, which is the real question here, is no. If, for example, you want to get many truthy or falsey values, new Date%2 will give you something like 1,1,1,1,0,0,0,0,0,1,1,1. That doesn't look "uniform" to me.

Source Link
Stephen
  • 14k
  • 11
  • 24

I believe this challenge may have been what prompted your question. Usually, challenge creators should define random. If random is not defined, it means use your language's builtin for random (see this meta post). If the challenge creator says "uniformly" random, that usually means that a PRNG or similar is good enough.

However: in this case, the challenge defines random as each possibility has a non-zero probability of being chosen. It does not need to be uniform, it just needs to be possible for both choices to occur. Therfore, new Date%2, (Math.random()*100)|0 (which will only return falsey about 1/100th of the time) and other non-uniform multi-choice options, are all valid, under non-zero probability random.

TL;DR read the challenge specs