You will need the cumulative distribution function and link for the Standard Normal Distribution. Remember to make allowances for 1 and 2 tailed tests.
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 by solospirit; 10-13-2014 at 03:24 PM.
You will need the cumulative distribution function and link for the Standard Normal Distribution. Remember to make allowances for 1 and 2 tailed tests.
Thanks Miner,
It looks really complicated, can you dumb it down for me? Steps would be helpful.
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/com...tribution.html
I don't have emotions and sometimes that makes me very sad.
solospirit (10-13-2014)
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?
I don't have the code readily available at the moment. It was part of senior project I did in undergrad so it's been a while since I've looked at that code. It basically was just a numeric approximation to the CDF though. It looked all messy but got the job done. I didn't learn anything from coding that particular bit in other than "Huh - I guess you can use numeric approximations to get good approximations - cool". Using the library would probably be fine if you're alright with adding that dependency/bloat.
I don't have emotions and sometimes that makes me very sad.
Dragan makes this post (#8).
Tweet |