# Kendall rank correlation coefficient's p-value

I'm trying to compute a p-value for a two tailed test following Wikipedia formula which indicates that:

one computes Z, and finds the cumulative probability for a standard normal distribution at -|Z|. For a 2-tailed test, multiply that number by two to obtain the p-value

I'm using this Rust's library which computes Tau value and then you can get the significance from this source code.

The problem is that this calculator (with default values) gives a 2-sided p-value = 0.0389842391014099. Which is far from the p-value I'm getting. The steps I'm following are these:

1. Compute Tau
2. Compute the statistical significance: Z with significance = kendall::significance(tau, x.len())
3. Gets the CDF from Gaussian Distribution with sigma = 1 using this GSL library's function: cdf = gaussian_P(-significance.abs(), 1.0)
4. Multiply that value by 2

I'm getting a very different value: 0.011946505026920469. I don't understand what I'm missing. Perhaps it's a misunderstanding of Gaussian distribution and it's sigma param. Any kind of help would be really appreciated

• Seems to be a bug with the Rust's library: issue Commented Dec 28, 2020 at 13:46
• More a statistics question I guess... You should try here Commented Dec 28, 2020 at 14:05
• Thanks! I've submited there few minutes ago Commented Dec 28, 2020 at 14:07

It looks like the issue is that you are using the wrong function to compute the cumulative distribution function (CDF) of the normal distribution. The function you are using, gaussian_P(), computes the CDF of the standard normal distribution, with mean 0 and standard deviation 1. However, the Z-score you are using (the output of kendall::significance()) is not necessarily normally distributed with mean 0 and standard deviation 1.
To compute the p-value for your two-tailed test, you need to use the CDF of the normal distribution with mean 0 and the same standard deviation as your Z-score. In the GSL library, this function is called gsl_cdf_gaussian_P(). You can use this function to compute the CDF of the normal distribution with the same standard deviation as your Z-score, and then multiply the result by 2 to get the p-value for your two-tailed test.
let z = kendall::significance(tau, x.len());