def two_proportion_z_score(control_size, control_conversion, attribute_size, attribute_conversion, pooled_sample=True):
    """
    Calculate the z-score between two proportions (often used for A/B testing)

    Answers the question: Is the difference in conversion rate between two sample groups due to chance? Or is it a significant difference?

    Parameters
    -----------
    attribute vs. control : The labels are arbitrary and you will get the same result with opposite sign if the values are swapped

    attribute/control_size : total number of people in this sample
    attribute/control_conversion : subgroup of people in the sample (should always be <= attribute/control_size)

    pooled_sample : Choose between pooling the sample for calculating the Standard Error, or not
        This assumes the null hypothesis (attribute_pct == control_pct) and can be derived from the non-pooled-sample Standard Error
        Most resources I found had the pooled sample as standard (so I defaulted to it)

    Example
    -----------
    66,471 people were part of a study. Of those 5,201 were shown an ad.
    And of the 5,201 67 bought the product.
    Of the unexposed people (66,471 - 5,201 = 61,270) 200 bought the product.
    Are the exposed and unexposed conversion rates significantly different?

    control_size = 61,270
    control_conversion = 200
    attribute_size = 5,201
    attribute_conversion = 67

    zscore = 10.52848...

    Assumptions
    -----------
    - The test statistic follows a Normal Distribution (this is generally true the larger the sample per the Central Limit Theorem)
        - This is an approximate measure (unlike "exact" tests) approximations are used for mean and variance measures
        - For small sample sizes use Fisher's Exact Test
    - Each sample is independent
    - The sample is obtained by simple random sampling (every member of the total population has an equal chance of being selected)


    For more information, see:
    - https://onlinecourses.science.psu.edu/stat414/node/268
    - http://stattrek.com/hypothesis-test/difference-in-proportions.aspx?Tutorial=AP
    """
    attribute_pct = float(attribute_conversion) / attribute_size
    control_pct = float(control_conversion) / control_size

    if pooled_sample:
        total_pct = float(attribute_conversion + control_conversion) / (attribute_size + control_size)
        standard_error = ( total_pct * (1. - total_pct) * (1. / attribute_size + 1. / control_size) ) ** .5
    else:
        standard_error = ( (attribute_pct * (1. - attribute_pct) / attribute_size) + (control_pct * (1. - control_pct) / control_size) ) ** .5

    zscore = (attribute_pct - control_pct) / standard_error
    return zscore