-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaliasing.html
156 lines (144 loc) · 8.05 KB
/
aliasing.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html>
<html lang="en">
<head>
<!-- 2019-10-11 Fri 15:58 -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Aliasing</title>
<meta name="generator" content="Org mode">
<meta name="author" content="George Kontsevich">
<meta name="description" content="Notes on aliasing"
>
<link rel="stylesheet" type="text/css" href="../web/worg.css" />
<link rel="shortcut icon" href="../web/panda.svg" type="image/x-icon">
</head>
<body>
<div id="org-div-home-and-up">
<a accesskey="h" href="./index.html"> UP </a>
|
<a accesskey="H" href=".."> HOME </a>
</div><div id="content">
<h1 class="title">Aliasing</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#orgf8a3668">Frequency replication</a></li>
<li><a href="#orgb1ebe10">Aliasing</a></li>
<li><a href="#org9943feb">Sampling translation</a></li>
</ul>
</div>
</div>
<div id="outline-container-orgf8a3668" class="outline-2">
<h2 id="orgf8a3668">Frequency replication</h2>
<div class="outline-text-2" id="text-orgf8a3668">
<p>
If you have a sinewave of frequency <i>f<sub>0</sub></i> which is sampled at a frequency <i>f<sub>s</sub></i>, you can always find other sine waves that will pass through the same samples. So if you are given a set of sample points you can not know for certain which sine wave creates them (unless you have some additional information)
</p>
<p>
For instance if we start with a continuous input signal:
</p>
<ul class="org-ul">
<li>x(t) = sin(2π f<sub>0</sub>t)</li>
</ul>
<p>
When sampling this waves at <i>f<sub>s</sub></i> samples per second the time between samples will be <i>1/f<sub>s</sub></i> (ie. seconds per sample). So the first sample will be at <i>t=0</i> the second at <i>t=1/f<sub>s</sub></i> the third at <i>t=2/f<sub>s</sub></i> .. etc. and the sample values will be described by the following equation with <i>n</i> equal to <i>0..(n-1)</i>
</p>
<ul class="org-ul">
<li>x(n) = sin(2π f<sub>0</sub>n/f<sub>s</sub>)</li>
</ul>
<p>
We now need to describe what other sine waves go through the same points. Because of periodicity of the <i>sin</i> function <i>sin(x) = sin(x+k2π)</i> for all integer values of <i>k</i> - so we can extension the previous equation
</p>
<ul class="org-ul">
<li>x(n) = sin(2π f<sub>0</sub>n/f<sub>s</sub>) = sin(2π f<sub>0</sub>n/f<sub>s</sub>+ k2π))</li>
<li>x(n) = sin(2π f<sub>0</sub>n/f<sub>s</sub>) = sin(2π (f<sub>0</sub>+ kf<sub>s</sub>)n/f<sub>s</sub>)</li>
</ul>
<p>
Given a large negative <i>k</i> value the resulting frequency-value <i>f<sub>0</sub>+ kf<sub>s</sub></i> will also be negative. A negative frequency at face value doesn't make much sense, but b/c of the identity <i>sin(x) = -sin(-x)</i> we can just think of it as flipped sine wave (or a sine way that's π out of phase). So a -5Hz wave is just a shifted 5Hz wave. These too are sine waves that pass through our sample points. (and no other phase-shifted sinusoids will go through the points)
</p>
<p>
The end result is that if we're sampling some input at frequency <i>f<sub>s</sub></i> then every input sine wave of frequency <i>f<sub>0</sub></i> will look identical to all sine waves of frequency <i>± f<sub>0</sub> ± kf<sub>s</sub></i> (for all integer values of <i>k</i>). After sampling we literally have no way to tell them apart. They look identical
</p>
</div>
</div>
<div id="outline-container-orgb1ebe10" class="outline-2">
<h2 id="orgb1ebe10">Aliasing</h2>
<div class="outline-text-2" id="text-orgb1ebe10">
<p>
In the case of one sine wave coming in to your sampler you may be able to infer from your system or some context which frequency orginally came in, which frequency is "real" and which is a replication. However once you start to have multiple frequencies if the sample rate is set too low then you will have replicated frequencies intermixing with real signals and you will not be able to disentangle what it real and what isn't. When you have these ambiguities we call it <i>aliasing</i>. To avoid aliasing we need to take our frequency range of interest, called the <i>bandwidth</i>, and select for it to an appropriate sampling rate so that frequencies in the bandwidth don't ever replicate onto the bandwidth itself.
</p>
<p>
If the sample rate is lower than the signal then the problem is obvious:
</p>
<ul class="org-ul">
<li>If we are looking at frequencies 0-11Hz then a 11Hz input sampled at 10Hz will show up at a 1Hz signal</li>
</ul>
<p>
However this is not a sufficient criteria b/c of the issue of the flipped sinewaves that also fit the points
</p>
<ul class="org-ul">
<li>If we look at the 0-7Hz range and sampled at 10Hz a 7Hz signal will look the same as a -3Hz signal (a 3Hz signal π out of phase)</li>
</ul>
<p>
So even if we are interested in some bandwidth <i>B</i> (ie. <i>0</i> to <i>B</i> Hertz) we need to still concern ourselves with the <i>0</i> to <i>-B</i> Hertz. To have no ambigiuity within the bandwidth you are looking at the sampling frequency needs to be twice the bandwidth, .ie <i>2B</i>. That way both <i>f<sub>0</sub> ± kf<sub>s</sub></i> and <i>-f<sub>0</sub> ± kf<sub>s</sub></i> lie outside the bandwidth
</p>
<p>
Inputs and noise outside the range should be filtered out b/c it will alias onto the range we are looking at.
</p>
</div>
</div>
<div id="outline-container-org9943feb" class="outline-2">
<h2 id="org9943feb">Sampling translation</h2>
<div class="outline-text-2" id="text-org9943feb">
<p>
While we now know how to choose a sampling rate to mitigate the effects of frequency replication, you can also use replication to your advantage by using it to observe very high frequencies. If we limit ourselves to looking at a band of frequencies <i>B</i> around some value <i>f<sub>c</sub></i> (known as the <i>carrier frequency</i>) we can carefully select a sampling frequency <i>f<sub>s</sub></i> which will make signals around <i>f<sub>c</sub></i> come out looking identical to lower frequencies around 0Hz
</p>
<p>
We start again with our original equation for frequency replication:
</p>
<ul class="org-ul">
<li>x(n) = sin(2π f<sub>0</sub>n/f<sub>s</sub>) = sin(2π (f<sub>0</sub>+ kf<sub>s</sub>)n/f<sub>s</sub>)</li>
</ul>
<p>
Now we need to select an appropriate <i>f<sub>0</sub></i> and make it look identical to <i>0Hz</i>
</p>
<ul class="org-ul">
<li>f<sub>0</sub>+kf<sub>s</sub> = 0</li>
</ul>
<p>
Our frequency range of interest goes from <i>f<sub>c</sub>-(B/2)</i> to <i>f<sub>c</sub>+(B/2)</i> and we can either move the lowest frequency <i>f<sub>c</sub>-(B/2)</i> to <i>0Hz</i>
</p>
<ul class="org-ul">
<li>f<sub>c</sub>-(B/2) + kf<sub>s</sub> = 0</li>
<li>f<sub>s</sub> = [2f<sub>c</sub>-B]/k</li>
</ul>
<p>
Or move the highest frequency <i>f<sub>c</sub>+(B/2)</i> to <i>0Hz</i>
</p>
<ul class="org-ul">
<li>f<sub>c</sub>+(B/2) + kf<sub>s</sub> = 0</li>
<li>f<sub>s</sub> = [2f<sub>c</sub>+B]/k</li>
</ul>
<p>
(<i>k</i> is a freely selected integer at this point, hence it can be scaled and incremented freely)
This second case is a bit peculiar b/c the bottom on the frequency range is now looking like <i>-B Hz</i>. This will have a negative equivalent at <i>B Hz</i> and so the original frequency will look inverted in the <i>0 to B Hz</i> range
</p>
<p>
The only additional requirement is that <i>f<sub>s</sub>>2B</i> as before to prevent aliasing. So as long as <i>k</i> is not too large the following give you possible sampling rates
</p>
<ul class="org-ul">
<li>f<sub>s</sub> = [2f<sub>c</sub>-B]/k<sub>0</sub> > 2B</li>
<li>f<sub>s</sub> = [2f<sub>c</sub>+B]/k<sub>1</sub> > 2B</li>
</ul>
<p>
Note that these are not the only possible sampling rates, nor actually the smallest, but these are the ones that bring the band down to around 0Hz. The above equations will necessarily have some largest possible value for <i>k</i> that keeps the sample rate below the Nyquist criterion (<i>2B</i>) and this will be the typically chosen sampling rate
</p>
<p>
Any noise between <i>0Hz</i> and the carrier frequency <i>f<sub>c</sub></i> will be aliased onto this range so filtering on the band of interest is crucial
</p>
</div>
</div>
</div>
</body>
</html>