samedi 18 mars 2017

Coin flip, which way is would produce a more accurate 50%

I'm mostly curious on this, and it doesn't really matter that much, but given the these two blocks of code, which would more accurately produce a 50% probability?

let x = arc4random_uniform(2) //Between 0 & 1
let coin = x == 0 ? "heads" : "tails"

let x = arc4random_uniform(5000)
if x.truncatingRemainder(dividingBy: 2) == 0 {
   coin = "heads"
}




Aucun commentaire:

Enregistrer un commentaire