Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele z-test Proportions | Additional Tests
Quizzes & Challenges
Quizzes
Challenges
/
Applied Hypothesis Testing & A/B Testing

bookz-test Proportions

When comparing the proportions of a specific outcome between two groups—such as the conversion rates for two versions of a website—a z-test for proportions is a powerful tool.

A z-test for proportions helps you determine whether the difference between two observed proportions is statistically significant, or if it could have occurred by random chance.

Key applications:

  • A/B testing for product or website changes;
  • Clinical trials comparing treatment effects;
  • Survey analysis with binary outcomes (such as success/failure or yes/no).

You should use a z-test for proportions when:

  • You have large sample sizes;
  • Your data represent binary outcomes.

This test is essential for making confident decisions when evaluating differences between groups.

123456789101112131415161718192021222324252627282930313233
import numpy as np from scipy.stats import norm # Sample data: Group A and Group B # Let's say you run an A/B test for a new signup page. # Group A (control): 120 signups out of 600 visitors # Group B (variant): 150 signups out of 700 visitors success_a = 120 n_a = 600 success_b = 150 n_b = 700 # Calculate sample proportions p_a = success_a / n_a p_b = success_b / n_b # Pooled proportion p_pool = (success_a + success_b) / (n_a + n_b) # Standard error se = np.sqrt(p_pool * (1 - p_pool) * (1/n_a + 1/n_b)) # z-statistic z = (p_a - p_b) / se # Two-tailed p-value p_value = 2 * (1 - norm.cdf(abs(z))) print(f"Proportion A: {p_a:.3f}") print(f"Proportion B: {p_b:.3f}") print(f"z-statistic: {z:.3f}") print(f"p-value: {p_value:.4f}")
copy

After running the z-test for proportions, you interpret the results by looking at the z-statistic and the p-value. The z-statistic quantifies how many standard errors the observed difference in proportions is away from zero (the null hypothesis). The p-value tells you the probability of observing a difference at least as extreme as the one you found, assuming there is no real difference between the groups. If this p-value is below your chosen significance threshold (commonly 0.05), you can reject the null hypothesis and conclude that there is a statistically significant difference in proportions between the two groups. If the p-value is higher, you do not have enough evidence to say the proportions are different. Always consider the context of your experiment and the practical significance of the result, not just the statistical outcome.

question mark

When should you use a z-test for proportions?

Select the correct answer

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 2

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

Suggested prompts:

Can you explain how to interpret the z-statistic and p-value in this context?

What does it mean if the p-value is above or below 0.05?

Can you help me understand when to use a z-test for proportions versus other statistical tests?

Awesome!

Completion rate improved to 3.23

bookz-test Proportions

Pyyhkäise näyttääksesi valikon

When comparing the proportions of a specific outcome between two groups—such as the conversion rates for two versions of a website—a z-test for proportions is a powerful tool.

A z-test for proportions helps you determine whether the difference between two observed proportions is statistically significant, or if it could have occurred by random chance.

Key applications:

  • A/B testing for product or website changes;
  • Clinical trials comparing treatment effects;
  • Survey analysis with binary outcomes (such as success/failure or yes/no).

You should use a z-test for proportions when:

  • You have large sample sizes;
  • Your data represent binary outcomes.

This test is essential for making confident decisions when evaluating differences between groups.

123456789101112131415161718192021222324252627282930313233
import numpy as np from scipy.stats import norm # Sample data: Group A and Group B # Let's say you run an A/B test for a new signup page. # Group A (control): 120 signups out of 600 visitors # Group B (variant): 150 signups out of 700 visitors success_a = 120 n_a = 600 success_b = 150 n_b = 700 # Calculate sample proportions p_a = success_a / n_a p_b = success_b / n_b # Pooled proportion p_pool = (success_a + success_b) / (n_a + n_b) # Standard error se = np.sqrt(p_pool * (1 - p_pool) * (1/n_a + 1/n_b)) # z-statistic z = (p_a - p_b) / se # Two-tailed p-value p_value = 2 * (1 - norm.cdf(abs(z))) print(f"Proportion A: {p_a:.3f}") print(f"Proportion B: {p_b:.3f}") print(f"z-statistic: {z:.3f}") print(f"p-value: {p_value:.4f}")
copy

After running the z-test for proportions, you interpret the results by looking at the z-statistic and the p-value. The z-statistic quantifies how many standard errors the observed difference in proportions is away from zero (the null hypothesis). The p-value tells you the probability of observing a difference at least as extreme as the one you found, assuming there is no real difference between the groups. If this p-value is below your chosen significance threshold (commonly 0.05), you can reject the null hypothesis and conclude that there is a statistically significant difference in proportions between the two groups. If the p-value is higher, you do not have enough evidence to say the proportions are different. Always consider the context of your experiment and the practical significance of the result, not just the statistical outcome.

question mark

When should you use a z-test for proportions?

Select the correct answer

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 2
some-alt