27
EE 123 Discussion Section 1 Jan. 26, 2018 Li-Hao Yeh Based on notes by Jon Tamir, Giulia Fanti and Frank Ong

EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

EE123DiscussionSection1

Jan.26,2018Li-Hao Yeh

BasedonnotesbyJonTamir,GiuliaFantiandFrankOng

Page 2: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Announcements

• OfficeHours• Miki:Wednesdays4-5pm,Cory506• Nick:Mondays11-12pm,Cory504• Li-Hao:Wednesdays2-3pm,Cory557

• Lab0– dueMondayJan.29• HW1– dueWednesdayJan.31• Questions?

Page 3: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Abouttoday

• Propertiesofdiscrete-timesystems• PropertiesofLTIsystems• Reviewonlinearregression

Page 4: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Discrete-timesystems

1. Memoryless• 𝑦 𝑛 dependsonlyon𝑥[𝑛]

2. Linear• 𝑇 𝑎(𝑥( 𝑛 + 𝑎*𝑥* 𝑛 = 𝑎(𝑇 𝑥( 𝑛 + 𝑎*𝑇 𝑥* 𝑛

3. TimeInvariant• If𝑦( 𝑛 = 𝑇 𝑥 𝑛 and𝑦* 𝑛 = 𝑇 𝑥 𝑛 − 𝑛- = 𝑦( 𝑛 − 𝑛-

4. Causal• 𝑦 𝑛 dependsonlyoncurrentandpastvaluesof𝑥 𝑛

5. BIBOStable• If 𝑥 𝑛 ≤ 𝐵0∀𝑛 then 𝑦 𝑛 ≤ 𝐵3∀𝑛

𝑇{𝑥[𝑛]}𝑦[𝑛]𝑥[𝑛]

Page 5: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

WhataboutLTIsystems?

1. Memoryless• 𝑦 𝑛 dependsonlyon𝑥[𝑛]

2. Linear• 𝑇 𝑎(𝑥( 𝑛 + 𝑎*𝑥* 𝑛 = 𝑎(𝑇 𝑥( 𝑛 + 𝑎*𝑇 𝑥* 𝑛

3. TimeInvariant• If𝑦( 𝑛 = 𝑇 𝑥 𝑛 and𝑦* 𝑛 = 𝑇 𝑥 𝑛 − 𝑛- = 𝑦( 𝑛 − 𝑛-

4. Causal• 𝑦 𝑛 dependsonlyoncurrentandpastvaluesof𝑥 𝑛

5. BIBOStable• If 𝑥 𝑛 ≤ 𝐵0∀𝑛 then 𝑦 𝑛 ≤ 𝐵3∀𝑛

𝑇{𝑥[𝑛]}𝑦[𝑛]𝑥[𝑛]

Linear&Time-invariantsystem

Page 6: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

CausalityofLTIsystem

𝑇{𝑥[𝑛]}𝑦[𝑛]𝑥[𝑛]

ℎ[𝑛]

h[n]istheDNAofthesystem

Systemoutput y[n] =1X

k=�1h[k]x[n� k]

Causalsystem:yshouldonlydependsonxwithnonnegative delayk

h[n] = 0, n < 0

CausalLTIsystem:

Page 7: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

BIBOstabilityofLTIsystem

𝑇{𝑥[𝑛]}𝑦[𝑛]𝑥[𝑛]

ℎ[𝑛]

Systemoutput y[n] =1X

k=�1h[k]x[n� k]

LTIsystemisBIBO

h[n]What’stheconditionfor

Page 8: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

|y[n]| =

�����X

k

h[k]x[n� k]

����� By < 1

BIBOstabilityofLTIsystem

𝑇{𝑥[𝑛]}𝑦[𝑛]𝑥[𝑛]

ℎ[𝑛]

Systemoutput y[n] =1X

k=�1h[k]x[n� k]

x[n] B

x

< 1

Bx

X

k

|h[k]| IfX

k

|h[k]| < 1

LTIsystemisBIBO

X

k

|h[k]x[n� k]| =X

k

|h[k]| · |x[n� k]|

Page 9: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

BIBOstabilityofLTIsystem

𝑇{𝑥[𝑛]}𝑦[𝑛]𝑥[𝑛]

ℎ[𝑛]

Systemoutput y[n] =1X

k=�1h[k]x[n� k]

IfLTIsystemisBIBOX

k

|h[k]| < 1 ?

Page 10: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

BIBOstabilityofLTIsystem

𝑇{𝑥[𝑛]}𝑦[𝑛]𝑥[𝑛]

ℎ[𝑛]

Systemoutput y[n] =1X

k=�1h[k]x[n� k]

X

k

|h[k]| < 1systemBIBO =)

()

systemnotBIBO=)X

k

|h[k]| = 1

Page 11: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

BIBOstabilityofLTIsystem

𝑇{𝑥[𝑛]}𝑦[𝑛]𝑥[𝑛]

ℎ[𝑛]

Systemoutput y[n] =1X

k=�1h[k]x[n� k]

Wanttofindxsuchthatyisalwaysnotbounded!!

x[n] =h[�n]

|h[�n]|

y[0] =X

k

h[k]x[�k] =X

k

|h[k]|2

|h[k]| =X

k

|h[k]| = 1

IfLTIsystemisBIBOX

k

|h[k]| < 1

Page 12: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Question1

LetT1andT2betwoseparatesystemsandTbethecascadedsystem:

𝑇( 𝑦[𝑛]𝑥[𝑛] 𝑇*

𝑇

• IfT1isLTIandT2isnotLTI,thenTcannotbeLTIFalseConsiderthesystemT1=0.ThenT=0• IfT1isnotLTIandT2isnotLTI,thenTcannotbeLTIFalseConsiderthesystem𝑇({𝑥} = 𝑥7and𝑇*{𝑥} = 𝑥

89.Then

𝑇 𝑥 = 𝑥

TrueorFalse?

Page 13: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Question2(fromoldexam)

Adiscrete-timesystemHproducesanoutputsignalythatisthesymmetricpartoftheinput:

𝑦 𝑛 = 𝑥 𝑛 + 𝑥 −𝑛

2

Whichofthefollowingaretrue?• ThesystemmustbeLTI• ThesystemcannotbeLTI

Page 14: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Solution2(fromoldexam)

Adiscrete-timesystemHproducesanoutputsignalythatisthesymmetricpartoftheinput:

𝑦 𝑛 = 𝑥 𝑛 + 𝑥 −𝑛

2

Whichofthefollowingaretrue?• ThesystemmustbeLTI• ThesystemcannotbeLTI

Page 15: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Solution2(fromoldexam)

Nottimeinvariant:• For𝑥( 𝑛 = 𝛿 𝑛 ,then𝑦( 𝑛 = 𝛿 𝑛• For𝑥* 𝑛 = 𝛿 𝑛 − 1 ,then𝑦* 𝑛 = = >?( @=[>@(]

*• 𝑦( 0 = 1 but𝑦* 1 = (

*

àNottimeinvariant

(however,thesystemislinear)

Page 16: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Solution3a(fromoldexam)

Foreachofthefollowingsystems,determineifthesystemis(1)linear,(2)causal,(3)time-invariant,and(4)BIBOstable

IndicateYforYes,NforNo,orXforcannotbedetermined

𝑦 𝑛 = cos |𝑛|� 𝑥 𝑛• Linear?• Causal?• Time-invariant?• BIBOStable?

YY

YN

Page 17: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Question3b(fromoldexam)

Foreachofthefollowingsystems,determineifthesystemis(1)linear,(2)causal,(3)time-invariant,and(4)BIBOstable

IndicateYforYes,NforNo,orXforcannotbedetermined

Theresponsetoaninputof𝛿 𝑛 − 1 is (*

>𝑢 𝑛

• Linear?• Causal?• Time-invariant?• BIBOStable?

XX

XX

Page 18: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Solution3b(fromoldexam)

Theresponsetoaninputof𝛿 𝑛 − 1 is (*

>𝑢 𝑛

• Systemwithimpulseresponse:ℎ 𝑛 = (*

>@(𝑢 𝑛 + 1

à Linear.Notcausal.time-invariant.Stable

• Systemthatalwaysoutputs (*

>𝑢 𝑛 , regardlessofinput

à Notlinear.Causal.Nottime-invariant.Stable

• Systemthatoutputs (*

>𝑢 𝑛 whentheinputis𝛿 𝑛 − 1

and∞ otherwise.à Notlinear.Notcausal.Nottime-invariant.Notstable

Page 19: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Linearregressionprimer

Many signal processing problems can be formulatedas a least squares, where we try to find modelparameters that best fit the observed data. We willsee this many, many times

Page 20: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Linearregressionprimer

Example: Linearregression.Supposeweobservefivedatapoints𝑥 𝑘 ,where𝑘 = −2,−1, 0, 1, 2 .Wewanttofitaline𝑥 = 𝑚𝑘 + 𝑏 byminimizingthesquareddistancebetweenthelineandthedatapoints:

HomeworkProblems

Homework Problem 7

Example: Linear regression. We observe 5 data points x [k] fromk = �2,�1, . . . , 1, 2.We want to fit a line x = mk + b by minimizing the squareddistance between the line and the data points

-2 -1 0 1 2 k

x

Frank Ong EE123 Discussion Section 2

Page 21: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Linearregressionprimer

Foreachvalueof𝑘,wehavealinearequationforourmodel:Example,𝑘 = 2:𝑥[2] = 2𝑚 + 𝑏

Andwehaveasquarederrorwithourdata:Example,𝑘 = 2: 𝑥 2 – 𝑏 + 2𝑚 *

Sumofsquarederrors:∑ 𝑥 𝑘 − 𝑚𝑘 + 𝑏�[

*

à Inmatrixform,Error=(*𝐱 − 𝐊𝜷 *

* Error=(*

𝑥?*𝑥?(𝑥-𝑥(𝑥*

−2 1−1 1012

111

𝑚𝑏

*

*

Page 22: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Linearregressionprimer

Tofindthebestfitfromaleastsquaressense,minimizethesumofsquarederrors:

minimizea,b

12

𝑥?*𝑥?(𝑥-𝑥(𝑥*

−2 1−1 1012

111

𝑚𝑏

*

*

= minimize𝛃

12 𝐱 − 𝐊𝛃

*

*

Page 23: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Linearregressionprimer

Tosolveforbandm,takethederivative(gradient)withrespecttobandtom,andsettozero:

InPython,K = np.array( […] )x = np.array( […])beta = np.linalg.solve(K, x)

minimize𝛃

12 𝐱 − 𝐊𝛃

*

*

𝐊𝐓𝐊𝛃 − 𝐊𝐓𝐱 = 0 ⟹ 𝛃 = 𝐊𝐓𝐊 ?(𝐊𝐓𝐱

Page 24: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Discrete-timeFouriertransform

𝑋 𝑒hi = ∑ 𝑥 𝑛 𝑒?hi>j>k?j – Analysis

x n = (*m ∫ 𝑋 𝑒hi 𝑒hi>𝑑𝜔m

?m – Synthesis

Page 25: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Question4

WhatistheDiscrete-timeFouriertransformofthebelowsignal𝑥[𝑛]?

hint:convolutionoftwosignals,𝑥 𝑛 = 𝑟 𝑛 ∗ 𝑟[𝑛]

𝑥[𝑛]

Page 26: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Solution4

WhatistheDiscrete-timeFouriertransformofthebelowsignal𝑥[𝑛]?

hint:convolutionoftwosignals,𝑥 𝑛 = 𝑟 𝑛 ∗ 𝑟[𝑛]

𝑥[𝑛]

𝑟[𝑛] 𝑟[𝑛]

∗ =

R 𝑒hi ⋅ R 𝑒hi = X ehiFourierspace

Page 27: EE 123 Discussion Section 1 - University of California, Berkeleyinst.eecs.berkeley.edu/~ee123/sp18/Sections/sec1.pdf · 2018-01-27 · EE 123 Discussion Section 1 Jan. 26, 2018 Li-HaoYeh

Solution4

𝑋 𝑒hi = 𝑅 𝑒hi * =sin 𝜔 32sin 𝜔

2

*

Normalizedmagnituderesponse: