I have a cluster of $p$-dimensional data from $n$ samples which is assumed to be normally distributed as a multivariate Gaussian with sample mean ${\bar{\mu}}$ and sample covariance matrix ${\bar{S}}$.
Given a new sample $x_i$ I want to test whether or not the sample belongs to this cluster. I am doing the following:
My null hypothesis, $H_o$, is: $x_i$ does belong to the cluster defined by the multivariate Gaussian with sample mean ${\bar\mu}$ and sample covariance $\bar{S}$
My alternate hypothesis, $H_a$, is: $x_i$ does not belong to the cluster
My test statistic, $T(\bar{\mu},\bar{S})$, is defined as the Mahalanobis distance which, according to this post and the paper Gaussian mixture modeling by exploiting the Mahalanobis distance (page 13, Appendix), is distributed as a scaled ${\beta}$ distribution:
$$ \frac{n}{(n-1)^2}T(\bar{\mu},\bar{S}) \sim \beta\left(\frac{p}{2}, \frac{(n-p-1)}{2}\right) $$
If I want to use a significance level ${\alpha} = 0.05$ then I believe I need to calculate my $p-value$ which, in this example, shows the probability of getting a sample as extreme (far from this distribution) or worse (further) from the underlying multivariate Gaussian as $x_i$. With this $p-value$ I will then check:
if $p-value < {\alpha}$ :
then reject $H_o$ i.e. this sample does not belong to this cluster
else accept $H_o$ i.e. this sample does belong to the cluster
Is this the correct way to perform this test? And if so, how do I calculate the $p$-value?
EDIT:(Adding more information and idea for solution)
It is my understanding that the $p-value$ represents the probability of obtaining a Mahalanobis distance ($d$) as extreme or worse than $d(x_i)$.
This is calculated as $P(X{\geq}x_i)$, which is $1-P(X{\leq}x_i)$ which is $1 - $ the $cdf$ of the Beta function $\beta\left(\frac{p}{2}, \frac{(n-p-1)}{2}\right)$
So the $p-value = 1 - I_{x_i}\left(\frac{p}{2}, \frac{(n-p-1)}{2}\right)$ where $I_{x_i}\left(\frac{p}{2}, \frac{(n-p-1)}{2}\right)$ regularized incomplete beta function.
Given that this is a two-tailed hypothesis test, with confidence level of $95%$ My test should be:
$p-value = 2 {\times} \left(1 - I_{x_i}\left(\frac{p}{2}, \frac{(n-p-1)}{2}\right)\right)$
if $p-value {\leq} 0.05$
then: reject the null hypothesis (i.e. declare the sample as an outlier)
else: accept the null hypothesis (i.e. sample is not an outlier)
I think this is correct, but could someone more knowledgeable please confirm?