{"id":2675,"date":"2026-11-04T13:37:22","date_gmt":"2026-11-04T13:37:22","guid":{"rendered":"https:\/\/prwatech.in\/blog\/?p=2675"},"modified":"2026-11-05T15:50:20","modified_gmt":"2026-11-05T15:50:20","slug":"two-tailed-test-tutorial","status":"publish","type":"post","link":"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/","title":{"rendered":"Two Tailed Test"},"content":{"rendered":"<h1><strong><b>Two Tailed Test: Definition, Formula and Worked Examples<\/b><\/strong><\/h1>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">A factory says that its bolts are 70 millimetres long. You measure a sample and find an average of 71.9. Is the factory off target? It could be producing bolts that are too long, but it could just as well produce bolts that are too short. If you only watch for one direction, you can miss the problem in the other. A two tailed test watches both.<\/p>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">It is the default hypothesis test in research and data science. A and B tests, quality checks and medical trials are usually two tailed, because you want to know if anything changed, not only if something went up. The name sounds technical, but the idea is simple: the rejection area is split between the two ends, or tails, of a curve.<\/p>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">This tutorial explains what a two tailed test is, why and when to use it, the formula, the cut off values, two worked examples with every step shown, how it differs from a one tailed test, and how to run it in Python. You should know what a null hypothesis and a p value are, and have some idea of the normal curve.<\/p>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Two Tailed Test Definition<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">A two tailed test is a hypothesis test in which the rejection region lies in both tails of the sampling distribution. You reject the null hypothesis if your test statistic is either very low or very high. The test is used when the alternative hypothesis says that a value is different, without saying in which direction.<\/p>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">At a 5 percent significance level, the 5 percent is split in two: 2.5 percent in the left tail and 2.5 percent in the right tail. On the standard normal curve, the cut off values are minus 1.96 and plus 1.96. If your Z value falls beyond either of them, you reject the null hypothesis.<\/p>\n<div style=\"margin: 16px 0 24px;\"><img decoding=\"async\" style=\"display: block; max-width: 100%; height: auto; border: 1px solid #d9e0ea; border-radius: 8px;\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/twotailtest.gif\" alt=\"Two tailed test with rejection regions in both tails of the normal curve\" \/><\/div>\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\n<table style=\"width: 100%; min-width: 760px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\">\n<caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Critical Z values for a two tailed test<\/caption>\n<thead>\n<tr>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 220px;\" scope=\"col\">Significance level (alpha)<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Area in each tail<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Critical Z values<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">0.10<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">0.05<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Minus 1.645 and plus 1.645<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">0.05<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">0.025<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Minus 1.960 and plus 1.960<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; vertical-align: top;\" scope=\"row\">0.01<\/th>\n<td style=\"padding: 12px 16px; vertical-align: top;\">0.005<\/td>\n<td style=\"padding: 12px 16px; vertical-align: top;\">Minus 2.576 and plus 2.576<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The live page calls these Z cut offs a standard deviation value. They are Z values, which count the number of standard errors from the mean.<\/p>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Why do We Use a Two Tailed Test?<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">You use it for a non directional hypothesis, one that says there is a difference, not that the value is higher or lower.<\/p>\n<ul style=\"font-family: Arial,Helvetica,sans-serif; margin: 0 0 16px; padding-left: 24px; font-size: 17px; line-height: 1.7; color: #1f2937;\">\n<li style=\"margin: 0 0 8px;\">Null hypothesis, H0: the mean is 70.<\/li>\n<li style=\"margin: 0 0 8px;\">Alternative hypothesis, H1: the mean is not 70, so it may be less than or more than 70.<\/li>\n<\/ul>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The advantage is that it catches changes in both directions. It protects you when you do not know which way the effect will go, or when a change either way is a problem, as with the bolt length. The cost is that it is harder to reach significance, because the 5 percent of risk is spread over two tails.<\/p>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">In symbols: H0: mu = mu0, and H1: mu is not equal to mu0. The live page writes the alternative as H1&lt;&gt;, which may not display on all screens.<\/p>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">The Two Tailed Test Formula<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">For a test of a mean with a known population standard deviation (a Z test):<\/p>\n<div style=\"background: #f5f8fc; border-left: 4px solid #0f2a4a; border-radius: 4px; padding: 14px 18px; margin: 16px 0 8px; font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #0f2a4a; font-weight: bold;\">Z = (sample mean minus hypothesised mean) divided by (standard deviation divided by the square root of n)<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The bottom part, the standard deviation divided by the square root of n, is the standard error. The live page prints it with the square root part missing.<\/p>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The p value for a two tailed test counts both tails:<\/p>\n<div style=\"background: #f5f8fc; border-left: 4px solid #0f2a4a; border-radius: 4px; padding: 14px 18px; margin: 16px 0 8px; font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #0f2a4a; font-weight: bold;\">two tailed p value = 2 times the probability of a Z value as extreme as the one you got, in one tail<\/div>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">How to Use a Two Tailed Test? Step by Step<\/h2>\n<ol style=\"font-family: Arial,Helvetica,sans-serif; margin: 0 0 16px; padding-left: 28px; font-size: 17px; line-height: 1.7; color: #1f2937;\">\n<li style=\"margin: 0 0 8px;\">State the hypotheses. H0: the mean equals the hypothesised value. H1: it does not.<\/li>\n<li style=\"margin: 0 0 8px;\">Choose the significance level, alpha, such as 0.05. Do this before looking at the data.<\/li>\n<li style=\"margin: 0 0 8px;\">Find the critical values. For 0.05, they are minus 1.96 and plus 1.96.<\/li>\n<li style=\"margin: 0 0 8px;\">Calculate the test statistic, Z or t.<\/li>\n<li style=\"margin: 0 0 8px;\">Decide. Reject H0 if the statistic is beyond a critical value, or if the p value is below alpha.<\/li>\n<li style=\"margin: 0 0 8px;\">State the conclusion in plain words.<\/li>\n<\/ol>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Example 1: Brokerage Fees<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The live page: the average brokerage fee in the population is 22 dollars, with a standard deviation of 9. A sample of 600 accounts has a mean of 15 dollars and a standard deviation of 9. Is the sample different from the population?<\/p>\n<ul style=\"font-family: Arial,Helvetica,sans-serif; margin: 0 0 16px; padding-left: 24px; font-size: 17px; line-height: 1.7; color: #1f2937;\">\n<li style=\"margin: 0 0 8px;\">Hypotheses. H0: the mean fee is 22. H1: the mean fee is not 22. The live page sets H0 to 15, which is the sample mean. A null hypothesis is about the population, so it must be 22.<\/li>\n<li style=\"margin: 0 0 8px;\">Alpha = 0.05. The critical values are minus 1.96 and plus 1.96.<\/li>\n<li style=\"margin: 0 0 8px;\">Standard error = 9 divided by the square root of 600 = 0.3674.<\/li>\n<li style=\"margin: 0 0 8px;\">Z = (15 minus 22) divided by 0.3674 = minus 19.05.<\/li>\n<li style=\"margin: 0 0 8px;\">Decision. Minus 19.05 is far below minus 1.96. The p value is about 6 times 10 to the power minus 81, which is below 0.05.<\/li>\n<\/ul>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Conclusion: we reject the null hypothesis. The sample fees are different from the population average, and with a mean of 15 against 22, they are lower. The live page concludes that there is not enough evidence of a difference, which does not follow from its own numbers. If the claim was only that the fees are lower, a one tailed test would also fit. Here the answer is the same.<\/p>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Two Tailed Test Example 2<\/h3>\n<div style=\"margin: 16px 0 24px;\"><img decoding=\"async\" style=\"display: block; max-width: 100%; height: auto; border: 1px solid #d9e0ea; border-radius: 8px;\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/twotailtest1.png\" alt=\"Two tailed test example 2 on the normal curve\" \/><\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The live page: the hypothesised mean is 18, the sample mean is 18.75, and the standard deviation is 6. It never gives n, and it mixes the null values 15 and 18. I use H0: the mean is 18, and a sample size of 100. The value 100 is my assumption, and it is the only n for which the page&#8217;s Z of 1.25 works.<\/p>\n<ul style=\"font-family: Arial,Helvetica,sans-serif; margin: 0 0 16px; padding-left: 24px; font-size: 17px; line-height: 1.7; color: #1f2937;\">\n<li style=\"margin: 0 0 8px;\">Hypotheses. H0: the mean is 18. H1: the mean is not 18.<\/li>\n<li style=\"margin: 0 0 8px;\">Standard error = 6 divided by the square root of 100 = 0.6.<\/li>\n<li style=\"margin: 0 0 8px;\">Z = (18.75 minus 18) divided by 0.6 = 1.25.<\/li>\n<li style=\"margin: 0 0 8px;\">Critical values at 0.05: minus 1.96 and plus 1.96. The value 1.25 lies between them, so it is not in the rejection region.<\/li>\n<li style=\"margin: 0 0 8px;\">p value = 2 times P(Z greater than 1.25) = 2 times 0.1056 = 0.2113. This is above 0.05.<\/li>\n<\/ul>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Conclusion: we do not reject the null hypothesis. There is not enough evidence that the mean differs from 18. A 95 percent interval for the true mean runs from 17.57 to 19.93, which contains 18. This agrees with the test, because a two tailed test at 0.05 and a 95 percent interval always agree.<\/p>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">What Happens with More Data?<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The same gap of 0.75 looks different with a bigger sample. With n = 400, the standard error is 0.3, Z = 2.50 and the two tailed p value is 0.0124, which is significant. Not significant here means that we do not have enough data. It does not mean that the difference is zero.<\/p>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Two Tailed vs One Tailed Test<\/h2>\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\n<table style=\"width: 100%; min-width: 900px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\">\n<caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Two tailed test and one tailed test compared<\/caption>\n<thead>\n<tr>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 240px;\" scope=\"col\">Point<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Two tailed<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">One tailed<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">Alternative hypothesis<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Different from the value, in either direction<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Greater than, or less than, the value, in one direction<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">Rejection region<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Both tails, 2.5 percent each at alpha 0.05<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">One tail, 5 percent at alpha 0.05<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">Critical Z at 0.05<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Minus 1.96 and plus 1.96<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">1.645 in the direction you chose<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">p value<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Both tails counted, twice the one tail area<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">One tail area<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; vertical-align: top;\" scope=\"row\">Use when<\/th>\n<td style=\"padding: 12px 16px; vertical-align: top;\">Any change matters, or you have no strong reason to expect a direction<\/td>\n<td style=\"padding: 12px 16px; vertical-align: top;\">Only one direction matters, decided before the data<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">For Example 2, the one tail area is 0.1056, so a one tailed test would give a p value of 0.1056, which is still not significant.<\/p>\n<h3 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 21px; line-height: 1.35; font-weight: bold; color: #0f2a4a; margin: 28px 0 10px;\">Why the Choice Must Be Made Before You See the Data?<\/h3>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Here is a case in which the choice matters. Twelve bolts measure 68, 72, 75, 66, 74, 71, 73, 69, 77, 70, 76 and 72 millimetres. The mean is 71.92 and the target is 70. A one sample T test gives t = 2.00.<\/p>\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\n<table style=\"width: 100%; min-width: 760px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\">\n<caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Two tailed and one tailed p values for the bolt data<\/caption>\n<thead>\n<tr>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 420px;\" scope=\"col\">Test<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">p value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">Two tailed, H1: the mean is not 70<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">0.0705, not significant<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; vertical-align: top;\" scope=\"row\">One tailed, H1: the mean is greater than 70<\/th>\n<td style=\"padding: 12px 16px; vertical-align: top;\">0.0352, significant<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">The one tailed test looks stronger, because it puts all 5 percent in one tail. But if you pick the direction after seeing that the mean is above 70, you are cheating, and you double your real false positive rate. Use a one tailed test only if the direction was fixed before the data, for a good reason. When in doubt, use two tailed.<\/p>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Run a Two Tailed Test in Python<\/h2>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">I ran the code below, and the output is real.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">python<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #f5f8fc;\">import numpy as np\r\nfrom scipy import stats\r\n\r\n# Example 2: Z test, n assumed to be 100\r\nz = (18.75 - 18) \/ (6 \/ 100 ** 0.5)\r\np_two = 2 * stats.norm.sf(abs(z))\r\nprint(\"Z:\", round(z, 2), \" two tailed p:\", round(float(p_two), 4))\r\nprint(\"Critical value at 0.05:\", round(float(stats.norm.ppf(0.975)), 3))\r\n\r\n# Bolts: one sample t test, two sided and one sided\r\ndata = np.array([68, 72, 75, 66, 74, 71, 73, 69, 77, 70, 76, 72])\r\ntwo = stats.ttest_1samp(data, 70, alternative=\"two-sided\")\r\none = stats.ttest_1samp(data, 70, alternative=\"greater\")\r\nprint(\"t:\", round(float(two.statistic), 3))\r\nprint(\"Two sided p:\", round(float(two.pvalue), 4))\r\nprint(\"One sided p:\", round(float(one.pvalue), 4))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre; background: #ffffff;\">Z: 1.25  two tailed p: 0.2113\r\nCritical value at 0.05: 1.96\r\nt: 2.003\r\nTwo sided p: 0.0705\r\nOne sided p: 0.0352<\/pre>\n<\/div>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">In SciPy, the alternative argument chooses the type of test. Two sided is the default for the T test functions.<\/p>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Common Mistakes to Avoid<\/h2>\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\n<table style=\"width: 100%; min-width: 760px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\">\n<caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Common mistakes and fixes<\/caption>\n<thead>\n<tr>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 420px;\" scope=\"col\">Mistake<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Fix<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">Setting the null hypothesis to the sample mean<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">The null hypothesis is a claim about the population<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">Forgetting to double the one tail area for the p value<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">A two tailed p value counts both tails<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">Choosing one tailed after seeing the data<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Fix the direction before the test<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">Using the one tailed cut off 1.645 in a two tailed test<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Use 1.96 at alpha 0.05<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">Concluding that no difference exists when p is high<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">It means not enough evidence<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; vertical-align: top;\" scope=\"row\">Leaving out the sample size<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; vertical-align: top;\">Report n, because it sets the standard error<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; vertical-align: top;\" scope=\"row\">Mixing the null values in different parts of a problem<\/th>\n<td style=\"padding: 12px 16px; vertical-align: top;\">Use one H0 throughout<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2 style=\"font-family: Arial,Helvetica,sans-serif; font-size: 26px; line-height: 1.3; font-weight: bold; color: #0f2a4a; margin: 36px 0 12px;\">Practice Questions<\/h2>\n<ol style=\"font-family: Arial,Helvetica,sans-serif; margin: 0 0 16px; padding-left: 28px; font-size: 17px; line-height: 1.7; color: #1f2937;\">\n<li style=\"margin: 0 0 8px;\">At alpha 0.05, what are the critical Z values for a two tailed test?<\/li>\n<li style=\"margin: 0 0 8px;\">A Z value of 2.30 is found. Is it significant in a two tailed test at 0.05?<\/li>\n<li style=\"margin: 0 0 8px;\">The area to the right of Z = 1.80 is 0.0359. What is the two tailed p value?<\/li>\n<li style=\"margin: 0 0 8px;\">When would you use a one tailed test?<\/li>\n<\/ol>\n<p style=\"font-family: Arial,Helvetica,sans-serif; font-size: 17px; line-height: 1.7; color: #1f2937; margin: 0 0 16px;\">Answers: 1) Minus 1.96 and plus 1.96. 2) Yes, because 2.30 is greater than 1.96. 3) 2 times 0.0359 = 0.0718, which is not significant at 0.05. 4) When only one direction matters and it was decided before seeing the data. These are my own answers, so please recheck them before publishing.<\/p>\n<p>A two tailed test asks a simple question: is the value different from what I expected, in either direction? Decide the hypotheses and alpha before you see the data, use the cut off values of minus and plus 1.96 at 0.05, and double the one tail area for the p value. That habit keeps your results honest.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Two Tailed Test: Definition, Formula and Worked Examples A factory says that its bolts are 70 millimetres long. You measure a sample and find an average of 71.9. Is the factory off target? It could be producing bolts that are too long, but it could just as well produce bolts that are too short. If [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,1704],"tags":[231,232,230,233,234,229],"class_list":["post-2675","post","type-post","status-publish","format-standard","hentry","category-data-science","category-data-science-modules","tag-two-tailed-hypothesis-test","tag-two-tailed-test-definition","tag-two-tailed-test-example","tag-two-tailed-test-formula","tag-two-tailed-test-in-data-science","tag-two-tailed-test-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Two Tailed Test: Definition, Formula and Examples | PrwaTech<\/title>\n<meta name=\"description\" content=\"Learn the two tailed test: definition, rejection region, Z formula, worked examples, one tailed vs two tailed difference and Python code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Two Tailed Test: Definition, Formula and Examples | PrwaTech\" \/>\n<meta property=\"og:description\" content=\"Learn the two tailed test: definition, rejection region, Z formula, worked examples, one tailed vs two tailed difference and Python code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Prwatech\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prwatech.in\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-04T13:37:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-05T15:50:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/twotailtest.gif\" \/>\n<meta name=\"author\" content=\"Prwatech\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:site\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prwatech\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/\",\"url\":\"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/\",\"name\":\"Two Tailed Test: Definition, Formula and Examples | PrwaTech\",\"isPartOf\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/twotailtest.gif\",\"datePublished\":\"2026-11-04T13:37:22+00:00\",\"dateModified\":\"2026-11-05T15:50:20+00:00\",\"author\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\"},\"description\":\"Learn the two tailed test: definition, rejection region, Z formula, worked examples, one tailed vs two tailed difference and Python code.\",\"breadcrumb\":{\"@id\":\"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/#primaryimage\",\"url\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/twotailtest.gif\",\"contentUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/twotailtest.gif\",\"width\":455,\"height\":333},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/prwatech.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Two Tailed Test\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/prwatech.in\/blog\/#website\",\"url\":\"https:\/\/prwatech.in\/blog\/\",\"name\":\"Prwatech\",\"description\":\"Share Ideas, Start Something Good.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/prwatech.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\",\"name\":\"Prwatech\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"caption\":\"Prwatech\"},\"url\":\"https:\/\/prwatech.in\/blog\/author\/prwatech123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Two Tailed Test: Definition, Formula and Examples | PrwaTech","description":"Learn the two tailed test: definition, rejection region, Z formula, worked examples, one tailed vs two tailed difference and Python code.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Two Tailed Test: Definition, Formula and Examples | PrwaTech","og_description":"Learn the two tailed test: definition, rejection region, Z formula, worked examples, one tailed vs two tailed difference and Python code.","og_url":"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/","og_site_name":"Prwatech","article_publisher":"https:\/\/www.facebook.com\/prwatech.in\/","article_published_time":"2026-11-04T13:37:22+00:00","article_modified_time":"2026-11-05T15:50:20+00:00","og_image":[{"url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/twotailtest.gif","type":"","width":"","height":""}],"author":"Prwatech","twitter_card":"summary_large_image","twitter_creator":"@Eduprwatech","twitter_site":"@Eduprwatech","twitter_misc":{"Written by":"Prwatech","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/","url":"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/","name":"Two Tailed Test: Definition, Formula and Examples | PrwaTech","isPartOf":{"@id":"https:\/\/prwatech.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/twotailtest.gif","datePublished":"2026-11-04T13:37:22+00:00","dateModified":"2026-11-05T15:50:20+00:00","author":{"@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3"},"description":"Learn the two tailed test: definition, rejection region, Z formula, worked examples, one tailed vs two tailed difference and Python code.","breadcrumb":{"@id":"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/#primaryimage","url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/twotailtest.gif","contentUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/07\/twotailtest.gif","width":455,"height":333},{"@type":"BreadcrumbList","@id":"https:\/\/prwatech.in\/blog\/data-science\/data-science-modules\/two-tailed-test-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/prwatech.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Two Tailed Test"}]},{"@type":"WebSite","@id":"https:\/\/prwatech.in\/blog\/#website","url":"https:\/\/prwatech.in\/blog\/","name":"Prwatech","description":"Share Ideas, Start Something Good.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/prwatech.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3","name":"Prwatech","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","caption":"Prwatech"},"url":"https:\/\/prwatech.in\/blog\/author\/prwatech123\/"}]}},"_links":{"self":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/2675","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/comments?post=2675"}],"version-history":[{"count":11,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/2675\/revisions"}],"predecessor-version":[{"id":12132,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/2675\/revisions\/12132"}],"wp:attachment":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/media?parent=2675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/categories?post=2675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/tags?post=2675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}