Answer the question
In order to leave comments, you need to log in
Expose the probability of falling TRUE in an array of 100 elements with FALSE?
I tried to google, they use the mt_rand functions everywhere and it’s not clear what is involved with them. I think that in my case, since I only need to return TRUE or FALSE , it’s easier to take an array of 100 elements, we set the probability of TRUE falling out to be 30%, which means that in the array we have 30 elements with the TRUE value. We shuffle the array several times, and then we get a random index from there, look at the value, voila.
However, I'm wondering if there is anything else in this spirit that is simple and reliable? Will the result be affected if the array has 10, 1,000, or 1,000,000 elements?
Answer the question
In order to leave comments, you need to log in
random index
get a random index from there
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question