COMS21202: Symbols, Patterns and Signals Signals and ......Reminder: Linear Systems ... Sometimes...

Preview:

Citation preview

COMS21202 - SPS

COMS21202: Symbols, Patterns and Signals

Signals and Fourier Analysis

1Animation from https://giphy.com

2-7 -6 -5 -4 -3 -2 -1 1 5 730 4 6 8

7

123456

8

-2-3-4-5-6-7

So a function is even when

Reminder: Even Functions have y-axis Symmetry

COMS21202 - SPS

y = f(x) = f(โˆ’x)

2

x

y

2-7 -6 -5 -4 -3 -2 -1 1 5 730 4 6 8

7

123456

8

-2-3-4-5-6-7

So a function is odd when

Reminder: Odd Functions have origin Symmetry

COMS21202 - SPS

y = f(x) = โˆ’f(โˆ’x)

3

x

y

Examples: odd or even?

COMS21202 - SPS

๐‘“ ๐‘ฅ = 3๐‘ฅ! โˆ’ 7๐‘ฅ" + 1๐‘“ โˆ’๐‘ฅ = 3(โˆ’๐‘ฅ)! โˆ’ 7(โˆ’๐‘ฅ)" + 1 = 3๐‘ฅ! โˆ’ 7๐‘ฅ" + 1

Even

๐‘“ ๐‘ฅ = 4๐‘ฅ# โˆ’ ๐‘ฅ๐‘“ โˆ’๐‘ฅ = 4(โˆ’๐‘ฅ)# โˆ’ (โˆ’๐‘ฅ) = โˆ’4๐‘ฅ# + ๐‘ฅ

Odd

4

๐‘“ ๐‘ฅ = 5๐‘ฅ! + 3๐‘ฅ" + 1๐‘“ โˆ’๐‘ฅ = 5(โˆ’๐‘ฅ)! + 3(โˆ’๐‘ฅ)" + 1 = 5๐‘ฅ! + 3๐‘ฅ" + 1

๐‘“ ๐‘ฅ = โˆ’3๐‘ฅ! โˆ’ ๐‘ฅ๐‘“ โˆ’๐‘ฅ = โˆ’3(โˆ’๐‘ฅ)$ โˆ’ (โˆ’๐‘ฅ) = 3๐‘ฅ$ + ๐‘ฅ

Odd

Even

Function Decomposition

COMS21202 - SPS

Even Part

Odd Part

Any function f(x)โ‰ 0 can be expressed as the sum of an even function fe(x) and an odd function fo(x).

๐‘“(๐‘ฅ) = ๐‘“%(๐‘ฅ) + ๐‘“&(๐‘ฅ)

๐‘“%(๐‘ฅ) =12 [๐‘“(๐‘ฅ) + ๐‘“(โˆ’๐‘ฅ)]

๐‘“&(๐‘ฅ) =12 [๐‘“(๐‘ฅ) โˆ’ ๐‘“(โˆ’๐‘ฅ)]

6

Example

COMS21202 - SPS

Even Part

Odd Part

๐‘“(๐‘ฅ) = 0๐‘’'( ๐‘ฅ > 00 ๐‘ฅ < 0

๐‘“%(๐‘ฅ) =

12 ๐‘’

'( ๐‘ฅ > 012 ๐‘’

( ๐‘ฅ < 0

๐‘“&(๐‘ฅ) =

12 ๐‘’

'( ๐‘ฅ > 0

โˆ’12 ๐‘’

( ๐‘ฅ < 0

๐‘“(๐‘ฅ) = ๐‘“%(๐‘ฅ) + ๐‘“&(๐‘ฅ)

7

x

x

x

One period2ฯ€

0 3ฯ€2ฯ€ฯ€โˆ’2ฯ€

โˆ’ฯ€โˆ’3ฯ€

sin ฮธ

ฮธ

sin ฮธ is an odd function as it is symmetric wrt the origin. sin(ฮธ) = โˆ’sin(โˆ’ฮธ)

sine function

8

cos ฮธ is an even function as it is symmetric wrt to the y-axis. cos(ฮธ) = cos(โˆ’ฮธ)

cos function

ฮธฯ€ 3ฯ€โˆ’2ฯ€ 2ฯ€โˆ’ฯ€โˆ’3ฯ€ 0

cos ฮธ

One period2ฯ€

9

Signals as Functions

Wavelength or period

amplitude a

๐‘ก

๐‘ข =1๐‘‡

Example: sine function

From giphy.com

COMS21202 - SPS

Reminder: Linear Systemsโ— For a linear system, output of the linear combination of many inputsignals is the same linear combination of the outputs ร superposition

10

COMS21202 - SPS

Characteristics of sound in audio signals:โ— High pitch - rapidly varying signalโ— Low pitch - slowly varying signal

How do you interpret these musical instrument signals?

11

COMS21202 - SPS

Frequency AnalysisTrigonometric Fourier Series: Any periodic function can be expressed

as the sum of sines and/or cosines of different frequencies, each multiplied by a different coefficient. ร  Jean Baptiste Joseph Fourier (1822).

โ— A function with period T is represented by two infinite sequences of coefficients. n is the no. of cycles/period.

โ— The sines and cosines are the Basis Functions of this representation. an and bn are the Fourier Coefficients.

โ— The sinusoids are harmonically related: each oneโ€™s frequency is an integer multiple of the fundamental frequency of the input signal.

๐‘“ ๐‘ฅ = $!"#

$

๐‘Ž! cos2๐œ‹๐‘›๐‘ฅ๐‘‡ + ๐‘! sin

2๐œ‹๐‘›๐‘ฅ๐‘‡

12

COMS21202 - SPS

Expressing a periodic function as a sum of sinusoids

13

COMS21202 - SPS

The Trigonometric Fourier Series once moreโ€ฆ

A trigonometric Fourier series is an expansion of a periodic function f(x). This expansion is in terms of an infinite sum of sines and cosines.

The Fourier series allows any arbitrary periodic function to be broken into a set of simple terms that can be solved individually, and then combined to obtain the solution to the original problem or an approximation to it.

a0 is often referred to as the DC term or the average of the signal.

๐‘“ ๐‘ฅ = ๐‘Ž# +$!"%

$

๐‘Ž! cos2๐œ‹๐‘›๐‘ฅ๐‘‡ + ๐‘! sin

2๐œ‹๐‘›๐‘ฅ๐‘‡

cf. with slide 12 โ€“ when n=0 the sin term disappears and the cos term is 1, so we can rewrite the equation as above.

14

COMS21202 - SPS

Fourier Series solutionA Fourier series provides an equivalent representation of the function:

The coefficients are:

One period

Example periodic function on -T/2, +T/2

x

f(x)

๐‘) =2๐‘‡

8'*/"

,*/"

๐‘“(๐‘ฅ) sin(2๐œ‹๐‘›๐‘ฅ๐‘‡ )๐‘‘๐‘ฅ

๐‘Ž) =2๐‘‡

8'*/"

,*/"

๐‘“(๐‘ฅ) cos(2๐œ‹๐‘›๐‘ฅ๐‘‡

)๐‘‘๐‘ฅ

๐‘“ ๐‘ฅ = ๐‘Ž" +&#$%

&

๐‘Ž# cos2๐œ‹๐‘›๐‘ฅ๐‘‡

+ ๐‘# sin2๐œ‹๐‘›๐‘ฅ๐‘‡

โ€“T/2 +T/2

15

0

COMS21202 - SPS

Fourier Series Example: Square Waveโ— f(x) is a square wave

f(x)

x

f(x)

x

f(x)

x

f(x)

x

f(x)

x

n = 1n = 1,3n = 1,3,5n = 1,3,5,7,โ€ฆ

๐‘“ ๐‘ฅ =4๐œ‹โ‹… sin

2๐œ‹๐‘ฅ๐‘‡

+43๐œ‹

โ‹… sin 3 โ‹…2๐œ‹๐‘ฅ๐‘‡

+45๐œ‹

โ‹… sin 5 โ‹…2๐œ‹๐‘ฅ๐‘‡

+ ...

๐‘“(๐‘ฅ) =+1

โˆ’๐‘‡2โ‰ค ๐‘ฅ < 0

โˆ’1 0 โ‰ค ๐‘ฅ <๐‘‡2

0

x

dxTnxT

dxTnxT

dxTnxxfT

a

T

T

T

Tn

)/2cos(1)/2cos(1

)/2cos()(1

2/

0

0

2/

2/

2/

pp

p

รฒรฒ

รฒ+

-

+

-

-=

=

รฏรฎ

รฏรญ

รฌ=

= รฒ+

-

even 0

odd 4

)/2sin()(1 2/

2/

n

nn

dxTnxxfT

bT

Tn

p

p

โ€“T/2 +T/2

f(x)

= 0

16

2

2

2

COMS21202 - SPS

1.2

1.0

0.8

0.6

0.4

0.2

bn

403020100n

Fourier Series Example: Square Wave

โ— The set of Fourier-space coefficients bn contain complete information about the function

โ— Although f(x) is periodic to infinity, bn is negligible beyond a finite range

โ— Sometimes the Fourier representation is more convenient to use, or just view

bn

n

17

COMS21202 - SPS

Frequency Analysisโ— The aim of processing a signal using Fourier analysis is to

manipulate the spectrum of a signal rather than manipulating the signal itself.

โ— Example: simple compression

โ— Functions that are not periodic can also be expressed as the integral of sines and/or cosines weighted by a coefficient. In this case we have the Fourier transform.

โ— The Fourier transform provides a way of representing a signal in a different space - i.e., in the frequency domain.

18

COMS21202 - SPS

Fourier Transform Applicationsโ— Applications wide ranging and ever present in modern life:

โ— Telecomms/Electronics/IT - cellular phones, digital cameras, satellites, etc.

โ— Entertainment - music, audio, multimedia devices

โ— Industry - X-ray spectrometry, Car ABS, chemical analysis, radar design

โ— Medical - PET, CAT, & MRI machines

โ— Image and Speech analysis (voice activated โ€œdevicesโ€, biometry, โ€ฆ)

โ— and many other fields...

19

COMS21202 - SPS

1D Fourier Transformโ— The Fourier Transform of a single variable continuous

function f(x) is:

โ— Conversely, given F(u), we can obtain f(x) by means of the inverse Fourier Transform:

๐‘“(๐‘ฅ) = )89

9

๐น(๐‘ข) ๐‘’:;<=>๐‘‘๐‘ข

These two equations are also known as the Fourier Transform Pair.Note, they constitute a lossless representation of data.

๐น(๐‘ข) = )89

9

๐‘“(๐‘ฅ) ๐‘’8:;<=>๐‘‘๐‘ฅ

20

COMS21202 - SPS

1D Fourier Transform: Discrete Formโ— The Fourier Transform of a discrete function of one

variable, f(x), x=0,1,2โ€ฆ,N-1 is:

โ— Conversely, given F(u) , we can obtain f(x) by means of the inverse Fourier Transform:

These two equations are also known as the Fourier Transform Pair.Note, they constitute a lossless representation of data.

( ) .1,...,2,1,0for 1)(21

0-==

--

=รฅ Nuexf

NuF N

uxjN

x

p

( ) .1,...,2,1,0for )(21

0-==รฅ

-

=

NxeuFxf NuxjN

u

p

21

COMS21202 - SPS

1D Fourier Domainโ— The concept of the frequency domain follows from Eulerโ€™s

Formula:

โ— Thus each term of the Fourier Transform is composed of the sum of all values of the function f(x) multiplied by sines and cosines of various frequencies:

๐‘’./0 = cos ๐œƒ โˆ’ ๐‘— sin ๐œƒ

๐น ๐‘ข =1๐‘3>?@

A8B

๐‘“(๐‘ฅ) cos2๐œ‹๐‘ข๐‘ฅ๐‘

โˆ’ ๐‘— sin2๐œ‹๐‘ข๐‘ฅ๐‘

We have transformed from a time domain to a frequency domain representation.for ๐‘ข = 0,1,2, . . . , ๐‘ โˆ’ 1.

22

COMS21202 - SPS

Example: Low and High FrequencyCharacteristics of sound in audio signals.

23

Freq.

COMS21202 - SPS

Spectrogram

Example: Acoustic Data Analysis

24

COMS21202 - SPS

1D Fourier Transform

โ— F(u) is a complex number & has real and imaginary parts:

โ— Magnitude or spectrum of the FT:

โ— Phase angle or phase spectrum:

โ— Expressing F(u) in polar coordinates:

๐น(๐‘ข) = ๐‘…(๐‘ข) + ๐‘—๐ผ(๐‘ข)

๐น(๐‘ข) = ๐‘…"(๐‘ข) + ๐ผ"(๐‘ข)

๐œ‘(๐‘ข) = tan.=๐ผ(๐‘ข)๐‘…(๐‘ข)

๐น(๐‘ข) = ๐น(๐‘ข) ๐‘’/>(?)

25

COMS21202 - SPS

Simple 1D example

time domain frequency domain time domain frequency domain

time domain frequency domain

bc

d = a + b + ca

time domain frequency domain

26

COMS21202 - SPS

Frequency Spectrum

โ— Distribution of |F(u)| ร  frequency spectrum of signal.

โ— Slowly changing signals ร  spectrum concentrated

around low frequencies.

โ— Rapidly changing signals ร  spectrum concentrated around high frequencies.

โ— Hence low and high frequency signals.

โ— Also bandlimited signals ร  frequency content confined

within some frequency band.

27

COMS21202 - SPS

Very Simple Application exampleโ— Automatic speech recognition between two

speech utterances x(n) and y(n).โ— Naรฏve approach:

๐ธ =?โˆ€A

๐‘ฅ(๐‘›) โˆ’ ๐‘ฆ(๐‘›) "

Problems with this approach?x(n)=Ky(n),yet Eโ‰ 0

(K being a scaling parameter)

x(n)=y(n-m),yet Eโ‰ 0(m causing a delay shift)

28

One solution could be Dynamic Time Warping(recall from earlier lecture)

COMS21202 - SPS

Frequency domain features

โ— Take the Fourier transform of both utterances to get X(u)and Y(u).

โ— Then consider the Euclidean distance between their magnitude spectrums: |X(u)| and |Y(u)|:

๐‘‘N =?โˆ€?

|๐‘‹(๐‘ข)| โˆ’ |๐‘Œ(๐‘ข)| "

29

COMS21202 - SPS

Frequency domain analysis

โ— Still a difficult task even in the frequency domain.

a tot a dot otto30

COMS21202 - SPS

DNA sequence FT example

โ— The analysis of correlations in DNA sequences is used to identify protein coding genes in genomic DNA.

โ— Locating and characterizing repeats and periodic clusters provides certain information about the structural and functional characteristics of the molecule.

โ— DNA sequences are represented by letters, A, C, G or T, and - .

โ— e.g. ACAATG-GCCATAAT-ATGTGAAC--GCTCAโ€ฆ

31

COMS21202 - SPS

DNA sequence FT exampleโ— Consider the periodic sequence

A--A--A--A--..... where blanks can be filled randomly by A, C, G or T. This shows a periodicity of 3.

โ— The spectral density of such a sequence is significantly non-zero only at one frequency (0.33) which corresponds to the perfect periodicity of base A(1/0.333=3.0).

โ— Destroy the perfect repetition by randomly replacing the Aโ€™s with all lettersโ€ฆ

32

COMS21202 - SPS

Letโ€™s practice: DNA sequence analysisโ— The computation of Fourier and other linear transforms of symbolic data

is a big problem. โ— The simplest solution is to map each symbol to a number. The difficulty

with this approach is the dependence on the particular labeling adopted.

โ— This clearly shows that some of the relevant harmonic structure can be exposed by the symbolic-to-numeric labelling.

Consider, for example, the following symbolic periodic sequence:s = (ATAGACATAGAC . . .).

The mapping A ร  1, T ร  0, PeriodG ร  0, TwoC ร  0,

The mapping A ร  1, T ร  2, PeriodG ร  3, SixC ร  4,

33