Is there a random sampling function for the iphone?
For example, if you want to flip a coin that returns heads 25% of the times it’s flipped, and you want to flip it and see if you get heads this time? I googled for random sampling probability for iphone and couldn’t find anything.
Is there a random sampling function for the iphone? For example, if you want
Share
Since you can use any standard C function in Objective-C, you could use drand48 to obtain a random double in the range [0,1]. Success with probability p is obtained by testing if the value is < p. Ex: