I currently have a series of points in $n$-dimensional space and a series of weights.
I wish to calculate the weighted distance between two points, using the following formula: $$d(a,b) = \sqrt{\sum_{i=0}^n w_i \left(X_i(a) - X_i(b)\right)^2}$$
where $w_i$ are my weights, and $X_i(x)$ is the $i$th coordinate of $x$
This works fine if my weights are all positive but it is possible for my weights to be negative, which means that sometimes the sum is negative and we cannot take the square root to get a real distance.
My first thought was to simply use $$d(a,b) = \sqrt{\left | \sum_{i=0}^n w_i \left(X_i(a)-X_i(b)\right)^2\right| }$$ but this intuitively feels wrong (but I can't work out why).
How can I fix this so I always find a real distance?
I couldn't find any relevant tags except radicals, feel free to add relevant ones!