# Angle Between Vectors

The angle between two nonzero vectors $$a$$, $$b$$ is defined as $\theta = \text{arccos} \bigg( \frac{a^Tb}{||a|| \ ||b||} \bigg)$ where arccos denotes the inverse cosine, normalized to lie in the interval $$[0, \pi]$$. In other words, we define $$\theta$$ as the unique number between 0 and $$\pi$$ that satisfies $a^Tb = ||a|| \ ||b|| \ \text{cos} \ \theta$ The angle between $$a$$ and $$b$$ is written as $$\angle(a, b)$$, and is sometimes expressed in degrees (the default unit is radians). …

Posted on

# Cauchy-Schwarz Inequality

The Cauchy-Schwarz inequality states for all vectors $$u$$ and $$v$$, $|\langle \mathbf{u}, \mathbf{v} \rangle| \leq ||\mathbf{u}|| \ ||\mathbf{v}||$ This means that the dot product of the two vectors is less than the product of the norms of the vectors. import numpy as np u = np.array([3, 5, 5]) v = np.array([5, 2, 6]) np.dot(u, v) <= np.linalg.norm(u) * np.linalg.norm(v) ## True

Posted on

# Standardization

For any vector $$x$$, we refer to $$\tilde{x} = x - \mathbf{avg}(x)\mathbf{1}$$ as the de-meaned version of $$x$$, since it has average or mean value zero. If we then divide by the RMS value of $$\tilde{x}$$ (which is the standard deviation of $$x$$), we obtain the vector $z = \frac{1}{\mathbf{std}(x)} (x - \mathbf{avg}(x)\mathbf{1})$ This vector is called the standardized version of $$x$$. It has mean zero, and standard deviation one. …

Posted on

# Chebyshev Inequality For Standard Deviation

The Chebyshev inequality goes like this. Suppose that $$x$$ is an $$n$$-vector, and that $$k$$ of its entries satisfy $$|x_i| \geq a$$, where $$a > 0$$. Then $$k$$ of its entries satisfy $$x_i^2 \geq a^2$$. It follows that $||x||^2 = x_1^2 + \cdots + x_n^2 \geq ka^2$ since $$k$$ of the numbers in the sum are at least $$a^2$$, and the other $$n - k$$ numbers are nonnegative. We conclude that $$k \leq ||x||^2 / a^2$$, which is the Chebyshev inequality. …

Posted on

# Average, RMS, And Standard Deviation

The average, RMS value, and standard deviation of a vector are related by the formula $\mathbf{rms}(x)^2 = \mathbf{avg}(x)^2 + \mathbf{std}(x)^2$ $$\mathbf{rms}(x)^2$$ is the mean square value of the entries of $$x$$, which can be expressed as the square of the mean value, plus the mean square fluctuation of the entries of $$x$$ around their mean value. Examples Mean return and risk. Suppose that an $$n$$-vector represents a time seris of retun on an investment, expressed as the percentage, in $$n$$ time periods over some interval of time. …

Posted on