# How do you calculate the p-value by hand? Only learned how to do it electronically

#### solospirit

##### New Member
Hello,

I am making a Java program that can run a full 1-sample z-test for sample mean and I would like to know how to calculate the p-value by hand once you have the z-statistic. I have learned how to calculate it by looking at the z-table and with a calculator, but for the sake of my program I would need to be able to understand how to calculate it manually or through some kind of formula.

EDIT:
I'm explicitly asking how to do what a z-table or calculator does when it gives you the p-value. It would be great if the process could be told as simply as possible, I am not the most advanced statistician.

Thanks!
-A possible stat major and freshman in college

Last edited:

#### Miner

##### TS Contributor
Re: How do you calculate the p-value by hand? Only learned how to do it electronicall

You will need the cumulative distribution function and link for the Standard Normal Distribution. Remember to make allowances for 1 and 2 tailed tests.

#### solospirit

##### New Member
Re: How do you calculate the p-value by hand? Only learned how to do it electronicall

Thanks Miner,

It looks really complicated, can you dumb it down for me? Steps would be helpful.

#### Dason

Re: How do you calculate the p-value by hand? Only learned how to do it electronicall

Do you know how to calculate the p-value in theory? Like what it represents? If so then your question basically boils down to "how do I evaluate the CDF of a normal distribution at a specific point" and that isn't an easy thing to do. There are many approximations that you could program yourself (when I did the task that you're essentially doing this is pretty much what I did - it's not too bad but isn't really too enlightening either). Otherwise you could use an external library. I know the Apache commons-math libraries are useful for this. Here is a class that would be useful for your task: http://commons.apache.org/proper/co...ns/math3/distribution/NormalDistribution.html

#### solospirit

##### New Member
Re: How do you calculate the p-value by hand? Only learned how to do it electronicall

Thanks for the input Dason,

Yes I know what the p-value presents, and I'm not even close to learning about all the math behind it. I consider myself to be fairly high level at Java so your library may be useful.

If you still have it, would you mind posting what you did when you did this task?