100%

if( true )

1/2

if( rand(0,1) === 0 )

1/3

if( rand(0,2) === 0 )

1/4

if( rand(0,3) === 0 )

1/x

if( rand(0,x) === 0 )

x%

if( rand(0,99) < x )

x‰

if( rand(0,999) < x )

x‱

if( rand(0,9999) < x )

/**
* 以$x/$y的概率返回true
*
* @param int $x
* @param int $y
* @return bool
*
* prob(1,2) = 1/2
* prob(1,100) = 1/100
*
*/
function prob($x, $y){
return ( mt_rand(0, $y-1) < $x );
}