# How can I interpret the result of the 3D two-sample Kolmogorov-Smirnov test computed in R?

I would like to check if the two three-dimensional samples could come from the same distributions. In my data two dimensions are coordinates and third dimension is distances. In K-S test we have null hypothesis $H_0$ and alternative hypothesis $H_1$, so I would like to check: $$H_0 : F(x, y, z) = G(x, y, z),$$ $$H_1 : F(x, y, z) \neq G(x, y, z),$$ where F(x, y, z) and G(x, y, z) are distributions from which analyzed data come from. If I assume significance level $\alpha = 0.05$ I can reject $H_0$ when p-value < 0.05, but for me more interesting case is when p-value > 0.05, because it means that two samples can be draw from the same distribution.

To computed the 3D two-sample Kolmogorov-Smirnov test I used R with Peacock.test package (https://cran.r-project.org/web/packages/Peacock.test/index.html). In manual of this package we can find that author has used the original definition of the Kolmogorov-Smirnov statistic test from Peacock (1983). Using this package I can only compute the value of the test statistic, so to check hypothesis I need p-value.

In the original Peacock’s paper (DOI:10.1093/mnras/202.3.615) we can find expressions for the approximation of the p-value if we have the test statistic $D_n$ (page 626, Summary and conclusions). These expressions are given below: $$Z_n = D_n \cdot \sqrt{\frac{n_1 \cdot n_2}{n_1 + n_2}},$$ $$Z_\infty = \frac{Z_n}{\left(1-0.53 \cdot \left(\frac{n_1 \cdot n_2}{n_1+n_2}\right)^{-0.9}\right)},$$ $$p = 2 \cdot \exp{(-2 \cdot (Z_\infty-0.5)^2)},$$ where $n_1$ and $n_2$ are the samples sizes, and $n_1, n_2 \gtrsim 10$

My questions are:

1. Can I use these expressions to calculate p-value and check hypothesis?

2. If not, what should I do to compute p-value?