public static double geometric ( int k , double p ) { if ( k <= 0 || p < 0 ) { throw new IllegalArgumentException ( "All the parameters must be positive." ) ; } double probability = Math . pow ( 1 - p , k - 1 ) * p ; return probability ; }
Returns the probability that the first success requires k trials with probability of success p