Often in statistics we’re interested in determining the p-value associated with a certain z-score that results from a hypothesis test.

If this p-value is below some significance level, we can reject the null hypothesis of our hypothesis test.

To find the p-value associated with a z-score in MATLAB, we can use the **normcdf()** function, which uses the following syntax:

**normcdf(x)**

where:

**x:**The z-score

The following examples illustrate how to find the p-value associated with a z-score for a left-tailed test, right-tailed test, and a two-tailed test.

**Left-Tailed Test**

We can use the following code to find the p-value associated with a z-score of **-0.77** in a left-tailed hypothesis test:

%find p-value for z-score = -0.77 in left-tailed test normcdf(-0.77) ans = 0.2206

The p-value is **0.2206**. If we use a significance level of α = 0.05, we would fail to reject the null hypothesis of our hypothesis test because this p-value is not less than 0.05.

**Right-Tailed Test**

We can use the following code to find the p-value associated with a z-score of **1.87** in a right-tailed hypothesis test.

%find p-value for z-score = 1.87 in right-tailed test 1 - normcdf(1.87) ans = 0.0307

The p-value is **0.0307**. If we use a significance level of α = 0.05, we would reject the null hypothesis of our hypothesis test because this p-value is less than 0.05.

**Two-Tailed Test**

Suppose we want to find the p-value associated with a z-score of **1.24** in a two-tailed hypothesis test.

%find p-value for z-score = 1.24 in two-tailed test (1-normcdf(1.24)) * 2 ans = 0.2150

**Note**: To find this two-tailed p-value we simply multiplied the one-tailed p-value by two.

The p-value is **0.2150**. If we use a significance level of α = 0.05, we would fail to reject the null hypothesis of our hypothesis test because this p-value is not less than 0.05.

**Bonus: **You can also use this online Z Score to P Value Calculator to find p-values.

**Additional Resources**

The following tutorials provide additional information about hypothesis testing:

Introduction to Hypothesis Testing

How to Identify a Left Tailed Test vs. a Right Tailed Test