parameters: (population_size)
return_statement: return sample_size
docstring: calculates the sample size for a 99% confidence and 1% margin of error
docstring_summary: calculates the sample size for a 99% confidence and 1% margin of error
docstring_tokens: calculates the sample size for a 99% confidence and 1% margin of error
function: def get_sample_size(population_size):
      """calculates the sample size for a 99% confidence and 1% margin of error
      """
      margin_of_error = 0.01
      fraction_picking = 0.50
      z_score = 2.58  # Corresponds to confidence level 99%
      numerator = (z_score ** 2 * fraction_picking * (1 - fraction_picking)) / (
          margin_of_error ** 2
      )
      sample_size = 0
      for train_size in range(population_size, 0, -1):
          denominator = 1 + (z_score ** 2 * fraction_picking * (1 - fraction_picking)) / (
              margin_of_error ** 2 * train_size
          )
          sample_size = int(numerator / denominator)
          if 2 * sample_size + train_size <= population_size:
              break
      return sample_size
function_tokens: def get_sample_size ( population_size ) : margin_of_error = 0.01 fraction_picking = 0.50 z_score = 2.58 # Corresponds to confidence level 99% numerator = ( z_score ** 2 * fraction_picking * ( 1 - fraction_picking ) ) / ( margin_of_error ** 2 ) sample_size = 0 for train_size in range ( population_size , 0 , - 1 ) : denominator = 1 + ( z_score ** 2 * fraction_picking * ( 1 - fraction_picking ) ) / ( margin_of_error ** 2 * train_size ) sample_size = int ( numerator / denominator ) if 2 * sample_size + train_size <= population_size : break return sample_size