public static double pbarVariance ( double pbar , int sampleN , int populationN ) { if ( populationN <= 0 || sampleN <= 0 || sampleN > populationN ) { throw new IllegalArgumentException ( "All the parameters must be positive and sampleN smaller than populationN." ) ; } double f = ( double ) sampleN / populationN ; double pbarVariance = ( ( 1.0 - f ) * pbar * ( 1.0 - pbar ) ) / ( sampleN - 1.0 ) ; return pbarVariance ; }
Calculates Variance for Pbar for a finite population size