[DSP] W02 - Vector Spaces
contents
discrete signal vectors
- a generic discrete signal:
- x[n]=…,1.23,−0.73,0.89,0.17,−1.15,−0.26,…
- set of ordered number sequence
- four classes of signals
- finite length
- infinite length
- periodic
- finite support
- digital signal processing:
- signal analysis
- signal synthesis
- number sets:
- N: natural numbers [1,∞)
- whole numbers [0,∞)
- Z: integers
- Q: rational numbers
- inclusive of recurring mantissa
- P: irrational numbers
- non-repeating and non-recurring mantissa
- π value, √2
- R: real numbers (everything on the number line)
- includes rational and irrational numbers
- C: complex numbers
- includes real and imaginary numbers
- N: natural numbers [1,∞)
fig: number sets
vector space framework:
- justification for dsp application:
- common framework for various signal classes
- inclusive of continuous-time signals
- easy explanation of Fourier Transform
- easy explanation of sampling and interpolation
- useful in approximation and compression
- fundamental to communication system design
- common framework for various signal classes
- paradigms for vector space application to discrete signals
- object oriented programming
- the instantiated object can have unique property values
- but for a given object class, the properties and methods are the same
- lego
- various unit blocks, same and different
- units assembled in different ways to build different complex structures
- similarly, a complex signal is broken down into a combination of basis vectors for analysis
- object oriented programming
- key takeaways
- vector spaces are general objects
- vector spaces are defined by their properties
- once signal properties satisfy vector space conditions
- vector space tools can be applied to signals
vector spaces
- some vector spaces
- R2: 2D space
- R3: 3D space
- RN: N real numbers
- CN: N complex numbers
- ℓ2(Z):
- square-summable infinite sequences
- L2([a,b]):
- square-integrable functions over interval [a,b]
- vector spaces can be diverse
- some vector spaces can be represented graphically
- helps visualize the signal for analysis insights
- R2: x=[x0,x1]T
- R3: x=[x0,x1,x2]T
- both can be visualized in a cartesian system fig: vector in 2D space
- L2([a,b]): x=x(t),t∈[−1,1]
- function vector space
- can be represented as sine wave along time fig: L2 function vector
- others cannot be represented graphically:
- RN for N>3
- CN for N>1
vector space axioms
- informally, a vector space:
- has vectors in it
- has scalars in it, like C
- scalers must be able to scale vectors
- vector summation must work
- formally, ∀ x,y,z∈V, and α,β∈C (V: vector space)
- x+y=y+x
- commutative addition
- (x+y)+z=x+(y+z)
- distributive addition
- α(x+y)=αy+αx
- distributive scalar multiplication over vectors
- (α+β)x=αx+βx
- distributive vector multiplication over scalers
- α(βx)=α(βx)
- associative scalar multiplication
- ∃ 0∈V | x+0=0+x=x
- null vector, 0, exists
- addition of 0 and another vector x returns x
- summation with null vector is commutative
- ∀ x∈V ∃ (−x) | x+(−x)=0
- an inverse vector exists in vector space such that adding the vector with it’s inverse yields the null vector
- x+y=y+x
- examples:
- RN: vector of N real numbers
- two vectors from this space look like:
- x=[x0,x1,x2,…xN]T
- y=[x0,x1,x2,…xN]T
- the above mentioned rules apply to these vectors and can be verified
- two vectors from this space look like:
- L2[−1,1]
- RN: vector of N real numbers
inner product
- aka dot product: measure of similarity of two vectors
- ⟨⋅,⋅⟩:V×V→C
- takes two vectors and outputs a scaler which indicates how similar the two vectors are
- inner product axioms
- ⟨x+y,z⟩=⟨x,z⟩+⟨y,z⟩
- distributive over vector addition
- ⟨x,y⟩=⟨y,x⟩∗
- commutative with conjugation
- ⟨x,αy⟩=α⟨x,y⟩
- distributive with scalar multiplication
- when scalar scales the second operand
- ⟨αx,y⟩=α∗⟨x,y⟩
- distributive with scalar multiplication
- conjugate scalar if it scaling the first operand
- ⟨x,x⟩≥0
- self inner product ( \in \mathbb{R})
- ⟨x,x⟩=0⇔x=0
- if self inner product is 0, then the vector is the null vector
- if ⟨x,y⟩=0 and x,y≠0,
- then x and y are orthogonal
- ⟨x+y,z⟩=⟨x,z⟩+⟨y,z⟩
- inner product is computed differently for different vector spaces
- in R2 vector space:
- ⟨x,y⟩=x0y0+x1y1=∥x∥∥y∥cosα
- where α: angle between x and y
- when two vectors are orthogonal to each other
- α=90∘, so cos90∘=0, so ⟨x,y⟩=0
- ⟨x,y⟩=x0y0+x1y1=∥x∥∥y∥cosα
- in L2[−1,1] vector space:
- ⟨x,y⟩=∫1−1x(t)y(t)dt
- norm: ⟨x,x⟩=∥x∥2=∫1−1sin2(πt)dt
- the inner product of a symmetric and an anti-symmetric function is 0
- i.e. they are orthogonal to each other and cannot be expressed as a factor of the other in any way
- example 1:
- x=sin(πt) - anti-symmetric
- y=1−|t| - symmetric
- ⟨x,y⟩=∫1−1(sin(πt))(1−|t|)dt=0
fig: inner product of a symmetric and an anti-symmetric function
- example 2:
- x=sin(4πt)
- y=sin(5πt)
- ⟨x,y⟩=∫1−1(sin(4πt))(sin(5πt))dt=0
- ⟨x,y⟩=∫1−1x(t)y(t)dt
norm and distance
- norm of a vector: - inner product of a vector with itself - square of the norm (length) of a vector - ⟨x,x⟩=x20+x21=∥x∥2
- distance between two vectors:
- the norm of the difference of the two vectors
- the distance between orthogonal vectors is not zero
- in R2, norm is the distance between the vector end points
- ∥x−y∥ is the difference vector
- ∥x−y∥=√(x0−y0)2+(x1−y1)2
- connects the end points of the vectors x and y
- see triangle rule of vector addition, and pythagorean theorem
- in L2[−1,1], the norm is the mean-squared error:
- ∫1−1|x(t)−y(t)|2dt
signal spaces
completeness
- consider an infinite sequence of vectors in a vector space
- if it converges to a limit within the vector space
- then said vector space is “complete”
- also called Hilbert Space
- limiting operation is ambiguous, definition varies from one space to the other
- so some limiting operation may fail and point outside the vector space
- such vector spaces are not said to be complete
common signal spaces
- while vectors spaces can be applied to signal processing
- not all vector spaces can be used for all signals
- different signal classes are managed in different spaces
- CN: vector space of N complex tuples
- valid signal space for finite length signals
- vector notation: x=[x0,x1,…xN]T
- where x0,x1…xN are complex tuples
- also valid for periodic signals
- vector notation: ~x
- all operations are well defined and intuitive
- inner product: ⟨x,y⟩=∑N−1n=0x∗[n]y[n]
- well defined for all finite-length vectors in ( \mathbb{C}^N)
- valid signal space for finite length signals
- the inner product for infinite length signals explode in CN - inappropriate for infinite length signal analysis
- ℓ2(Z): vector space of square-summable sequences - requirement for sequences to be square-summable: - ∑|x[n]|2<∞ - sum of squares of elements of the sequence is less than infinity - all sequences that live in this space must have finite energy - “well-behaved” infinite-length signals live in ℓ2(Z) - vector notation: x=[…,x−2,x−1,x0,x1,…]T
- lot of other interesting infinite length signals do not live in ℓ2
- examples:
- x[n]=1
- x[n]=cos(ωn)
- these have to be dealt with case-by-case
- examples:
basis
- a basis is a building block of a vector space
- a vector space usually has a few basis vectors called bases
- like the lego unit blocks
- any element in a vector space can be
- built with a combination of these bases
- decomposed into a linear combination of these bases
- the basis of a space is a family of vectors which are least like each other
- but they all belong to the same space
- as a linear combination, the basis vectors capture all the information within their vector space
- fourier transform is simply a change of basis
vector families
- w(k): family of vectors - k: index of the basis in the family
- canonical R2 basis: ek
- e(0)=[1 0]; e(1)=[0 1]
- this family of basis vectors is denoted by ek
- any vector can be expressed as a linear combination of ( \textbf{e}^k) in ( \mathbb{R}^2 )
- [x0 x1]=x0[1 0]+x1[0 1]
- x=x0e(0)+x1e(1)
- graphical example:
- [2 1]=2[1 0]+1[0 1]
- x=2e(0)+1e(1)
fig: linear combination of canonical ( \textbf{e}^k) in (\mathbb{R}^2)
- non-canonical R2 basis example: vk
- v(0)=[1 0]; v(1)=[1 1]
- any vector can be expressed as a linear combination of these vectors in R2
- the coefficients of the bases will be different compared to the canonical bases
- graphical example:
- [2 1]=αv(0)+βv(1)
- [2 1]=α[1 0]+β[1 1]
- by rule of parallelogram vector addition
- α=1; β=1
fig: linear combination of non-canonical vk in R2
- only vectors which are linearly independent can be the basis vectors of a space
- infinite dimensional spaces bases:
- some limitations have to be applied to obtain basis vectors of infinite dimension
- x=∑∞k=0αkw(k)
- a canonical basis of ℓ2(Z) - ek=⎡⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢⎣...001000...⎤⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥⎦, k -th position, k∈Z
- function vector spaces:
- basis vector for functions: f(t)=∑kαkh(k)(t)
- the fourier basis for functions over an interval [−1,1]: - 1√2,cosπt,sinπt,cos2πt,sin2πt,cos3πt,sin3πt,… - any square-integrable function in [−1,1] can be represented as a linear combination of fourier bases - a square wave can be expressed as a sum of sines
- formally, in a vector space H,
- a set of K vectors from H, W=w(k)k=0,1,…,K−1 is a basis for H if:
`
- ∀∈H: x=∑K−1k=0αkw(k), αk∈C
- the coefficients αk are unique
- this implies linear independence in the vector basis
- ∑K−1k=0αkw(k)=0⇔αk=0,k=0,1,…,K−1 `
orthonormal basis
- the orthogonal bases are the most important
- of all possible bases for a vector space
- orthogonal basis: ⟨w(k),w(n)⟩=0 for k≠n
- vectors of an orthogonal basis are mutually orthogonal
- their inner product with each other is zero
- in some spaces, the orthogonal bases are also orthonormal
- i.e. they are unit norm
- their length ∥w(k)∥=1
- the inner product of any two vectors in the orthonormal bases is the difference between their indices
- ⟨w(k),w(n)⟩=δ[n−k]
- gran-schmidt algorithm can be used to orthonormalize any orthogonal bases
- obtaining the bases coefficients αk for bases can be involved and challenging
- x=∑K−1k=0αkw(k)
- x: a vector as the linear combination of K basis vectors w(k),
- with corresponding coefficients αk
- however, they are easy to obtain with an orthonormal basis
- αk=⟨w(k),x⟩
- x=∑K−1k=0αkw(k)
change of basis
- x=∑K−1k=0αkw(k)=∑K−1k=0βkv(k)
- v(k) is the target basis, w(k) is the original basis
- if v(k) is orthonormal:
- βh=⟨v(h),x⟩
- =⟨v(h),∑K−1k=0αkw(k)⟩
- =∑K−1k=0αk⟨v(h),w(k)⟩
- =∑K−1k=0αkchk
- =⎡⎢ ⎢ ⎢⎣c00c01…c0(K−1)⋮c(K−1)0c(K−1)1…c(K−1)(K−1)⎤⎥ ⎥ ⎥⎦[α0 ⋮αK−1]
- this forms the core of the discrete fourier transform algorithm for finite length signals
- can be applied to elementary rotations of basis vectors in the euclidean plane
- the same vector has different coefficients in the original and the rotates bases
- the rotation matrix is obtained by the matrix multiplication of the original and the target bases
- the rotation matrix applied to a vector in the original bases yields the coefficients of the same vector in the rotated bases
- the matrix multiplication of the rotation matrix with its inverse yields the identity matrix
subspaces
- subspaces can be applied to signal approximation and compression
- with vector x∈V and subspace S⊆V
- approximate x with ^x∈S by
- take projection of the vector x in V on S
- due to the adaptation of vector space paradigm for signal processing
- this geometric intuition for approximation can be extended to arbitrarily complex vector spaces
vector subspace
- a subspace is a subset of vectors of a vector space closed under addition and scalar multiplication
- classic example:
- R2⊂R3
- in-plane vector addition and scalar multiplication operations do not result in vectors outside the plane
- R2 uses only 2 of the 3 orthonormal basis of R3
- the subspace concept can be extended to other vector spaces
- L2[−1,1]: function vector space
- subspace: set of symmetric functions in L2[−1,1]
- when two symmetric functions are added, they yield symmetric functions
- L2[−1,1]: function vector space
- subspaces have their own bases
- a subset of their parent space’s bases
least square approximations
- s(k)k=0,1,…,K−1 orthonormal basis for S
- orthogonal projection:
- ^x=∑K−1k=0⟨s(k),x⟩s(k)
- the orthogonal projection: the “best” approximation of x over S - because of two of its properties - it has minimum-norm error: - arg miny∈S∥x−y∥=^x - orthogonal projection minimizes the error between the original vector and the approximated vector - this error is orthogonal to the approximation: - ⟨x−^x,^x⟩=0 - the error and the basis vectors of the subspace are maximally different - they are uncorrelated - the basis vectors cannot capture any more information in the error
- example: polynomial approximation
- approximating from vector space L2[−1,1] to PN[−1,1]
- i.e. vector space of square-integrable functions to a subspace of polynomials of degree N−1
- generic element of subspace PN[−1,1] has form
- p=a0+a1t+…+aN−1tN−1
- a naive, self-evident basis for this subspace:
- s(k)=tk,k=0,1,…,N−1
- not orthonormal, however
approximation with Legendre polynomials
- example goal:
- approximate x=sint∈L2[−1,1] to P3[−1,1]
- P3[−1,1]: polynomials of the degree 2
- approximate x=sint∈L2[−1,1] to P3[−1,1]
- build orthonormal basis from naive basis
- use Gram-Schmidt orthonormalization procedure for naive bases:
- s(k)→u(k)
- s(k): original naive bases
- u(k): orthonormalized naive bases
- this algorithm takes one vector at a time from the original step and incrementally produces an orthonormal set
- p(k)=s(k)−∑k−1n=0⟨u(n),s(n)⟩u(n)
- for the first naive basis vector, normalize it with 1
- project the second naive basis vector on to the normalized first basis
- then subtract this projection from the second basis vector to get the second normalized basis
- this removes the the first normalized basis’s component from the second naive basis
- u(k)=p(k)∥p∥(k)
- normalize the extracted vector
- p(k)=s(k)−∑k−1n=0⟨u(n),s(n)⟩u(n)
- this process yields:
- u(1)=√12
- u(2)=√32t
- u(3)=√58(3t2−1)
- and so on
- these are known as Legendre polynomials
- they can be computed to the arbitrary degree,
- for this example, up to degree 2
- use Gram-Schmidt orthonormalization procedure for naive bases:
- project x over the orthonormal basis
- simply dot product the original vector x over all the legendre polynomials i.e. the orthogonal basis of the P3[−1,1] subspace
- αk=⟨u(k),x⟩=∫1−1uk(t)sintdt
- α0=⟨√12,sint⟩=0
- α1=⟨√32t,sint⟩≈0.7377
- α2=⟨√58(3t2−1),sint⟩=0
- compute approximation error
- so using the orthogonal projection
- sint→α1u(1)≈0.9035t
- this subspace has only one non-zero basis:
- √32t
- so using the orthogonal projection
- compare error to taylor’s expansion approximation
- well known expansion, easy to compute but not optimal over interval
- taylor’s approximation: sint≈t
- in both cases, the approximation is a straight line, but the slopes are slightly different (≈ 10% off)
- the taylor’s expansion is a local approximation around 0,
- the legendre polynomials method minimizes the global mean-squared-error between the approximation and the original vector
- the error of the legendre method has a higher error around 0
- however, the energy of the error compared to the error of the taylor’s expansion is lower in the interval
- error norm:
- legendre polynomial based approximation:
- ∥sint−α1u(1)∥≈0.0337
- taylor series based approximation:
- ∥sint−t∥≈0.0857
- legendre polynomial based approximation:
haar spaces
- haar spaces are matrix spaces
- note: matrices can be reshaped for vector operations
- encodes matrix information in a hierarchical way
- finds application in image compression and transmission
- it has two kinds of basis matrices
- the first one encodes the broad information
- the rest encode the details, which get finer by the basis index
- each basis matrix has positive and negative values in some symmetric pattern
- the basis matrix will implicitly compute the difference between image areas
- low-index basis matrices take differences between large areas
- high-index matrices take differences in smaller, localized areas
- this is a more robust way of encoding images for transmission methods prone to losses on the way
- if images are transmitted as simple matrices, they are prone to being chopped is loss in communication occurs during transmission
- haar encoding transmits coefficients not pixel by pixel but hierarchically in the level of detail
- so if communication loss occurs, the broad idea of the image is still conveyed
- while continued transmission will push up the detail level
- approximation of matrices to harr space is an example of progressive encoding