# How to calculate a p-value without using a lookup table [duplicate]

I'm looking for the formula to calculate a p-value for statistical hypothesis testing by hand without using the lookup table. I've found something here (Calculating P-Value of a Z-Score without using Z-Table), but I don't really understand the formula. Can someone help me by showing some data and how you come up with a p-value based on that data. So, simply filling in the formula. For a Z-test, T-test or what is feasible. Would be much appreciated!

• In general, this will involve an integral with typically no closed form, so you need to do numerical integration. You could also use built-in commands of standard statistical tools like R or Pythong - which again rely internally on tables. In some cases, e.g., in a permutation or bootstrap test, it would be a matter of evaluating the empirical cumulative distribution function - which is nothing else than counting outcomes. Can you be more precise as to what test you are interested in, and on why you don't want to use a table? Jul 18 at 12:40
• The duplicate has an extensive (and very good) discussion of various ways to do this calculation "by hand." When I'm in the field and need to do such a calculation I find that Simpson's Rule (consult your favorite Calculus textbook) works quite well.
– whuber
Jul 18 at 13:11
• Yes, I recognized the integral part in the formula, but have difficulty with applying it to data. The reason I'm interested in the calculation of the p-value is to get a deeper understanding of how statistical testing works. In the past, I used Excel and R to get p-values, but now I want to try to calculate it manually in Excel. The type of test doesn't really matter, let's say to use the Z-test. Could you provide an example how the formula is used, including the numerical integration? Jul 18 at 13:12
• We have a great many self-study questions here on CV that perform this calculation (probably several thousands by now). Although it's difficult to suggest a search term, I'm pretty sure a review of these textbook questions will quickly turn up some good examples. Here's a refined search that has some promising hits on the first page of its results. It found the illustrated answer at stats.stackexchange.com/a/52545/919, for instance.
– whuber
Jul 18 at 13:14
• Thanks a lot for your help, whuber. I'll dive deeper in the sources you suggest. Jul 18 at 13:28