Skip to main content
align inequality
Source Link
Silverfish
  • 23.9k
  • 28
  • 105
  • 206

The triangle inequality on your $d_1$ would yield: $\newcommand{\Cov}{\mathrm{Cov}}$ $\newcommand{\Cor}{\mathrm{Cor}}$ $\newcommand{\Var}{\mathrm{Var}}$ $$d_1(X,Z) \leq d_1(X,Y) + d_1(Y,Z)$$ $$1 - |\Cor(X,Z)| \leq 1 - |\Cor(X,Y)| + 1 - |\Cor(Y,Z)|$$

We can rewrite this as:

$$|\Cor(X,Y)| + |\Cor(Y,Z)| \leq 1 + |\Cor(X,Z)| $$\begin{align*} d_1(X,Z) &\leq d_1(X,Y) + d_1(Y,Z) \\ 1 - |\Cor(X,Z)| &\leq 1 - |\Cor(X,Y)| + 1 - |\Cor(Y,Z)| \\ \implies |\Cor(X,Y)| + |\Cor(Y,Z)| &\leq 1 + |\Cor(X,Z)| \end{align*}

The triangle inequality on your $d_1$ would yield: $\newcommand{\Cov}{\mathrm{Cov}}$ $\newcommand{\Cor}{\mathrm{Cor}}$ $\newcommand{\Var}{\mathrm{Var}}$ $$d_1(X,Z) \leq d_1(X,Y) + d_1(Y,Z)$$ $$1 - |\Cor(X,Z)| \leq 1 - |\Cor(X,Y)| + 1 - |\Cor(Y,Z)|$$

We can rewrite this as:

$$|\Cor(X,Y)| + |\Cor(Y,Z)| \leq 1 + |\Cor(X,Z)| $$

The triangle inequality on your $d_1$ would yield: $\newcommand{\Cov}{\mathrm{Cov}}$ $\newcommand{\Cor}{\mathrm{Cor}}$ $\newcommand{\Var}{\mathrm{Var}}$

\begin{align*} d_1(X,Z) &\leq d_1(X,Y) + d_1(Y,Z) \\ 1 - |\Cor(X,Z)| &\leq 1 - |\Cor(X,Y)| + 1 - |\Cor(Y,Z)| \\ \implies |\Cor(X,Y)| + |\Cor(Y,Z)| &\leq 1 + |\Cor(X,Z)| \end{align*}

tweaked formatting for easier readability
Source Link
gung - Reinstate Monica
  • 147.5k
  • 89
  • 406
  • 717

The triangle inequality on your $d_1$ would yield:

  $\newcommand{\Cov}{\mathrm{Cov}}$ $\newcommand{\Cor}{\mathrm{Cor}}$ $\newcommand{\Var}{\mathrm{Var}}$ $$d_1(X,Z) \leq d_1(X,Y) + d_1(Y,Z)$$ $$1 - |Cor(X,Z)| \leq 1 - |Cor(X,Y)| + 1 - |Cor(Y,Z)|$$$$1 - |\Cor(X,Z)| \leq 1 - |\Cor(X,Y)| + 1 - |\Cor(Y,Z)|$$

$$|Cor(X,Y)| + |Cor(Y,Z)| \leq 1 + |Cor(X,Z)| $$$$|\Cor(X,Y)| + |\Cor(Y,Z)| \leq 1 + |\Cor(X,Z)| $$

If $Y=X+Z$ and $X$ and $Z$ have identical variance, then $Cor(X,Y) = \frac{\sqrt{2}}{2} \approx 0.707$$\Cor(X,Y) = \frac{\sqrt{2}}{2} \approx 0.707$ and similarly for $Cor(Y,Z)$$\Cor(Y,Z)$, so the left-hand side is well above one and the inequality is violated. Example of this violation in R, where $X$ and $Z$ are components of a multivariate normal:

library(MASS)
set.seed(123)
d1 <- function(a,b) {1 - abs(cor(a,b))}

Sigma <- matrix(c(1,0,0,1), nrow=2) # covariance matrix of X and Z
matrixXZ <- mvrnorm(n=1e3, mu=c(0,0), Sigma=Sigma, empirical=TRUE)
X <- matrixXZ[,1] # mean 0, variance 1
Z <- matrixXZ[,2] # mean 0, variance 1
cor(X,Z) # nearly zero
Y <- X + Z

d1(X,Y) 
# 0.2928932
d1(Y,Z)
# 0.2928932
d1(X,Z)
# 1
d1(X,Z) <= d1(X,Y) + d1(Y,Z)
# FALSE
library(MASS)
set.seed(123)
d1 <- function(a,b) {1 - abs(cor(a,b))}

Sigma    <- matrix(c(1,0,0,1), nrow=2) # covariance matrix of X and Z
matrixXZ <- mvrnorm(n=1e3, mu=c(0,0), Sigma=Sigma, empirical=TRUE)
X <- matrixXZ[,1] # mean 0, variance 1
Z <- matrixXZ[,2] # mean 0, variance 1
cor(X,Z) # nearly zero
Y <- X + Z

d1(X,Y) 
# 0.2928932
d1(Y,Z)
# 0.2928932
d1(X,Z)
# 1
d1(X,Z) <= d1(X,Y) + d1(Y,Z)
# FALSE
d2 <- function(a,b) {1 - cor(a,b)^2}
d2(X,Y) 
# 0.5
d2(Y,Z)
# 0.5
d2(X,Z)
# 1
d2(X,Z) <= d2(X,Y) + d2(Y,Z)
# TRUE
d2 <- function(a,b) {1 - cor(a,b)^2}
d2(X,Y) 
# 0.5
d2(Y,Z)
# 0.5
d2(X,Z)
# 1
d2(X,Z) <= d2(X,Y) + d2(Y,Z)
# TRUE

Rather than launch a theoretical attack on $d_2$, at this stage I just found it easier to play around with the covariance matrix Sigma in R until a nice counterexample popped out. Allowing $Var(X)=2$$\Var(X)=2$, $Var(Z)=1$$\Var(Z)=1$ and $Cov(X,Z)=1$$\Cov(X,Z)=1$ gives:

$$Var(Y)=Var(X+Y)=Var(X)+Var(Z)+2Cov(X,Z)=2+1+2=5$$$$\Var(Y)=\Var(X+Y)=\Var(X)+\Var(Z)+2\Cov(X,Z)=2+1+2=5$$

$$Cov(X,Y)=Cov(X,X+Z)=Cov(X,X)+Cov(X,Z)=2+1=3$$$$\Cov(X,Y)=\Cov(X,X+Z)=\Cov(X,X)+\Cov(X,Z)=2+1=3$$ $$Cov(Y,Z)=Cov(X+Z,Z)=Cov(X,Z)+Cov(Z,Z)=1+1=2$$$$\Cov(Y,Z)=\Cov(X+Z,Z)=\Cov(X,Z)+\Cov(Z,Z)=1+1=2$$

The squared correlations are then: $$Cor(X,Z)^2 = \frac{Cov(X,Z)^2}{Var(X)Var(Z)}=\frac{1^2}{2\times1}=0.5$$$$\Cor(X,Z)^2 = \frac{\Cov(X,Z)^2}{\Var(X)\Var(Z)}=\frac{1^2}{2\times1}=0.5$$ $$Cor(X,Y)^2 = \frac{Cov(X,Y)^2}{Var(X)Var(Y)}=\frac{3^2}{2\times5}=0.9$$$$\Cor(X,Y)^2 = \frac{\Cov(X,Y)^2}{\Var(X)\Var(Y)}=\frac{3^2}{2\times5}=0.9$$ $$Cor(Y,Z)^2 = \frac{Cov(Y,Z)^2}{Var(Y)Var(Z)}=\frac{2^2}{5\times1}=0.8$$$$\Cor(Y,Z)^2 = \frac{\Cov(Y,Z)^2}{\Var(Y)\Var(Z)}=\frac{2^2}{5\times1}=0.8$$

Sigma <- matrix(c(2,1,1,1), nrow=2) # covariance matrix of X and Z
matrixXZ <- mvrnorm(n=1e3, mu=c(0,0), Sigma=Sigma, empirical=TRUE)
X <- matrixXZ[,1] # mean 0, variance 2
Z <- matrixXZ[,2] # mean 0, variance 1
cor(X,Z) # 0.707
Y <- X + Z
d2 <- function(a,b) {1 - cor(a,b)^2}
d2(X,Y) 
# 0.1
d2(Y,Z)
# 0.2
d2(X,Z)
# 0.5
d2(X,Z) <= d2(X,Y) + d2(Y,Z)
# FALSE
Sigma    <- matrix(c(2,1,1,1), nrow=2) # covariance matrix of X and Z
matrixXZ <- mvrnorm(n=1e3, mu=c(0,0), Sigma=Sigma, empirical=TRUE)
X <- matrixXZ[,1] # mean 0, variance 2
Z <- matrixXZ[,2] # mean 0, variance 1
cor(X,Z) # 0.707
Y  <- X + Z
d2 <- function(a,b) {1 - cor(a,b)^2}
d2(X,Y) 
# 0.1
d2(Y,Z)
# 0.2
d2(X,Z)
# 0.5
d2(X,Z) <= d2(X,Y) + d2(Y,Z)
# FALSE

The triangle inequality on your $d_1$ would yield:

 $$d_1(X,Z) \leq d_1(X,Y) + d_1(Y,Z)$$ $$1 - |Cor(X,Z)| \leq 1 - |Cor(X,Y)| + 1 - |Cor(Y,Z)|$$

$$|Cor(X,Y)| + |Cor(Y,Z)| \leq 1 + |Cor(X,Z)| $$

If $Y=X+Z$ and $X$ and $Z$ have identical variance, then $Cor(X,Y) = \frac{\sqrt{2}}{2} \approx 0.707$ and similarly for $Cor(Y,Z)$, so the left-hand side is well above one and the inequality is violated. Example of this violation in R, where $X$ and $Z$ are components of a multivariate normal:

library(MASS)
set.seed(123)
d1 <- function(a,b) {1 - abs(cor(a,b))}

Sigma <- matrix(c(1,0,0,1), nrow=2) # covariance matrix of X and Z
matrixXZ <- mvrnorm(n=1e3, mu=c(0,0), Sigma=Sigma, empirical=TRUE)
X <- matrixXZ[,1] # mean 0, variance 1
Z <- matrixXZ[,2] # mean 0, variance 1
cor(X,Z) # nearly zero
Y <- X + Z

d1(X,Y) 
# 0.2928932
d1(Y,Z)
# 0.2928932
d1(X,Z)
# 1
d1(X,Z) <= d1(X,Y) + d1(Y,Z)
# FALSE
d2 <- function(a,b) {1 - cor(a,b)^2}
d2(X,Y) 
# 0.5
d2(Y,Z)
# 0.5
d2(X,Z)
# 1
d2(X,Z) <= d2(X,Y) + d2(Y,Z)
# TRUE

Rather than launch a theoretical attack on $d_2$, at this stage I just found it easier to play around with the covariance matrix Sigma in R until a nice counterexample popped out. Allowing $Var(X)=2$, $Var(Z)=1$ and $Cov(X,Z)=1$ gives:

$$Var(Y)=Var(X+Y)=Var(X)+Var(Z)+2Cov(X,Z)=2+1+2=5$$

$$Cov(X,Y)=Cov(X,X+Z)=Cov(X,X)+Cov(X,Z)=2+1=3$$ $$Cov(Y,Z)=Cov(X+Z,Z)=Cov(X,Z)+Cov(Z,Z)=1+1=2$$

The squared correlations are then: $$Cor(X,Z)^2 = \frac{Cov(X,Z)^2}{Var(X)Var(Z)}=\frac{1^2}{2\times1}=0.5$$ $$Cor(X,Y)^2 = \frac{Cov(X,Y)^2}{Var(X)Var(Y)}=\frac{3^2}{2\times5}=0.9$$ $$Cor(Y,Z)^2 = \frac{Cov(Y,Z)^2}{Var(Y)Var(Z)}=\frac{2^2}{5\times1}=0.8$$

Sigma <- matrix(c(2,1,1,1), nrow=2) # covariance matrix of X and Z
matrixXZ <- mvrnorm(n=1e3, mu=c(0,0), Sigma=Sigma, empirical=TRUE)
X <- matrixXZ[,1] # mean 0, variance 2
Z <- matrixXZ[,2] # mean 0, variance 1
cor(X,Z) # 0.707
Y <- X + Z
d2 <- function(a,b) {1 - cor(a,b)^2}
d2(X,Y) 
# 0.1
d2(Y,Z)
# 0.2
d2(X,Z)
# 0.5
d2(X,Z) <= d2(X,Y) + d2(Y,Z)
# FALSE

The triangle inequality on your $d_1$ would yield: $\newcommand{\Cov}{\mathrm{Cov}}$ $\newcommand{\Cor}{\mathrm{Cor}}$ $\newcommand{\Var}{\mathrm{Var}}$ $$d_1(X,Z) \leq d_1(X,Y) + d_1(Y,Z)$$ $$1 - |\Cor(X,Z)| \leq 1 - |\Cor(X,Y)| + 1 - |\Cor(Y,Z)|$$

$$|\Cor(X,Y)| + |\Cor(Y,Z)| \leq 1 + |\Cor(X,Z)| $$

If $Y=X+Z$ and $X$ and $Z$ have identical variance, then $\Cor(X,Y) = \frac{\sqrt{2}}{2} \approx 0.707$ and similarly for $\Cor(Y,Z)$, so the left-hand side is well above one and the inequality is violated. Example of this violation in R, where $X$ and $Z$ are components of a multivariate normal:

library(MASS)
set.seed(123)
d1 <- function(a,b) {1 - abs(cor(a,b))}

Sigma    <- matrix(c(1,0,0,1), nrow=2) # covariance matrix of X and Z
matrixXZ <- mvrnorm(n=1e3, mu=c(0,0), Sigma=Sigma, empirical=TRUE)
X <- matrixXZ[,1] # mean 0, variance 1
Z <- matrixXZ[,2] # mean 0, variance 1
cor(X,Z) # nearly zero
Y <- X + Z

d1(X,Y) 
# 0.2928932
d1(Y,Z)
# 0.2928932
d1(X,Z)
# 1
d1(X,Z) <= d1(X,Y) + d1(Y,Z)
# FALSE
d2 <- function(a,b) {1 - cor(a,b)^2}
d2(X,Y) 
# 0.5
d2(Y,Z)
# 0.5
d2(X,Z)
# 1
d2(X,Z) <= d2(X,Y) + d2(Y,Z)
# TRUE

Rather than launch a theoretical attack on $d_2$, at this stage I just found it easier to play around with the covariance matrix Sigma in R until a nice counterexample popped out. Allowing $\Var(X)=2$, $\Var(Z)=1$ and $\Cov(X,Z)=1$ gives:

$$\Var(Y)=\Var(X+Y)=\Var(X)+\Var(Z)+2\Cov(X,Z)=2+1+2=5$$

$$\Cov(X,Y)=\Cov(X,X+Z)=\Cov(X,X)+\Cov(X,Z)=2+1=3$$ $$\Cov(Y,Z)=\Cov(X+Z,Z)=\Cov(X,Z)+\Cov(Z,Z)=1+1=2$$

The squared correlations are then: $$\Cor(X,Z)^2 = \frac{\Cov(X,Z)^2}{\Var(X)\Var(Z)}=\frac{1^2}{2\times1}=0.5$$ $$\Cor(X,Y)^2 = \frac{\Cov(X,Y)^2}{\Var(X)\Var(Y)}=\frac{3^2}{2\times5}=0.9$$ $$\Cor(Y,Z)^2 = \frac{\Cov(Y,Z)^2}{\Var(Y)\Var(Z)}=\frac{2^2}{5\times1}=0.8$$

Sigma    <- matrix(c(2,1,1,1), nrow=2) # covariance matrix of X and Z
matrixXZ <- mvrnorm(n=1e3, mu=c(0,0), Sigma=Sigma, empirical=TRUE)
X <- matrixXZ[,1] # mean 0, variance 2
Z <- matrixXZ[,2] # mean 0, variance 1
cor(X,Z) # 0.707
Y  <- X + Z
d2 <- function(a,b) {1 - cor(a,b)^2}
d2(X,Y) 
# 0.1
d2(Y,Z)
# 0.2
d2(X,Z)
# 0.5
d2(X,Z) <= d2(X,Y) + d2(Y,Z)
# FALSE
fuller working for d2
Source Link
Silverfish
  • 23.9k
  • 28
  • 105
  • 206

Rather than launch a theoretical attack on $d_2$, at this stage I just found it easier to play around with the covariance matrix Sigma in R until a nice counterexample popped out. Allowing $Var(X)=2$, $Var(Z)=1$ and $Cov(X,Z)=1$ gives:

We can also find $Cov(X,Y)=3$ and $Cov(Y,Z)=2$ which allows us to findinvestigate the appropriatecovariances:

$$Cov(X,Y)=Cov(X,X+Z)=Cov(X,X)+Cov(X,Z)=2+1=3$$ $$Cov(Y,Z)=Cov(X+Z,Z)=Cov(X,Z)+Cov(Z,Z)=1+1=2$$

The squared correlations are then: $$Cor(X,Z)^2 = \frac{Cov(X,Z)^2}{Var(X)Var(Z)}=\frac{1^2}{2\times1}=0.5$$ $$Cor(X,Y)^2 = \frac{Cov(X,Y)^2}{Var(X)Var(Y)}=\frac{3^2}{2\times5}=0.9$$ $$Cor(Y,Z)^2 = \frac{Cov(Y,Z)^2}{Var(Y)Var(Z)}=\frac{2^2}{5\times1}=0.8$$

Then $d_2(X,Z)=0.5$ while $d_2(X,Y)=0.1$ and hence evaluate $d_2$. The$d_2(Y,Z)=0.2$ so the triangle inequality is violated by a substantial margin:.

Rather than launch a theoretical attack on $d_2$, at this stage I just found it easier to play around with the covariance matrix Sigma in R until a nice counterexample popped out. Allowing $Var(X)=2$, $Var(Z)=1$ and $Cov(X,Z)=1$ gives

We also find $Cov(X,Y)=3$ and $Cov(Y,Z)=2$ which allows us to find the appropriate squared correlations and hence evaluate $d_2$. The inequality is violated by a substantial margin:

Rather than launch a theoretical attack on $d_2$, at this stage I just found it easier to play around with the covariance matrix Sigma in R until a nice counterexample popped out. Allowing $Var(X)=2$, $Var(Z)=1$ and $Cov(X,Z)=1$ gives:

We can also investigate the covariances:

$$Cov(X,Y)=Cov(X,X+Z)=Cov(X,X)+Cov(X,Z)=2+1=3$$ $$Cov(Y,Z)=Cov(X+Z,Z)=Cov(X,Z)+Cov(Z,Z)=1+1=2$$

The squared correlations are then: $$Cor(X,Z)^2 = \frac{Cov(X,Z)^2}{Var(X)Var(Z)}=\frac{1^2}{2\times1}=0.5$$ $$Cor(X,Y)^2 = \frac{Cov(X,Y)^2}{Var(X)Var(Y)}=\frac{3^2}{2\times5}=0.9$$ $$Cor(Y,Z)^2 = \frac{Cov(Y,Z)^2}{Var(Y)Var(Z)}=\frac{2^2}{5\times1}=0.8$$

Then $d_2(X,Z)=0.5$ while $d_2(X,Y)=0.1$ and $d_2(Y,Z)=0.2$ so the triangle inequality is violated by a substantial margin.

eg for d2
Source Link
Silverfish
  • 23.9k
  • 28
  • 105
  • 206
Loading
note about d2
Source Link
Silverfish
  • 23.9k
  • 28
  • 105
  • 206
Loading
Source Link
Silverfish
  • 23.9k
  • 28
  • 105
  • 206
Loading