I'm trying to convert a series of Z scores into 2-tailed P values in MATLAB. I can see many solutions online that use the MATLAB statistics toolbox, but I don't have this additional package. How can convert my Z scores to p values using only functions in core MATLAB?
Asked
Active
Viewed 2,710 times
0
-
If all you really need is `normcdf` from the Statistics Toolbox, you can find another implementation for it (or, if you have the toolbox and just lack the license, you can simply copy MATLAB's implementation into a new function and use that instead). – buzjwa Apr 19 '14 at 10:23
1 Answers
0
This is going to come down to finding the area under the standard normal curve. If you let Y be a continuous random variable, finding the probability of your two tails comes down to the following:
Approximating these integrals is what the statistics toolbox would've done for you. The easiest thing to do would be a rectangle-rule type approximation of the integral. They only take a few minutes to code, and can be very accurate. Here is an explanation of the method, as well as error you can expect:
http://en.wikipedia.org/wiki/Rectangle_method
Of course, the easiest thing to do is find another implementation of normpdf
!

mkierc
- 1,193
- 2
- 15
- 28

Russ Phelan
- 1
- 2
-
The function f(Y) is the probability density function for the Standard Normal distribution, just to be clear. – Russ Phelan Nov 29 '14 at 20:29