Skip to content

Commit bd233be

Browse files
committed
Revised examples: PEP8, docstring, minor edits
1 parent 76184b5 commit bd233be

File tree

8 files changed

+1111
-992
lines changed

8 files changed

+1111
-992
lines changed

nonrecursive_filters/introduction.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"name": "python",
112112
"nbconvert_exporter": "python",
113113
"pygments_lexer": "ipython3",
114-
"version": "3.7.1"
114+
"version": "3.7.9"
115115
}
116116
},
117117
"nbformat": 4,

quantization/introduction.ipynb

Lines changed: 129 additions & 118 deletions
Large diffs are not rendered by default.

quantization/linear_uniform_characteristic.ipynb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,14 +1429,14 @@
14291429
"source": [
14301430
"import numpy as np\n",
14311431
"import matplotlib.pyplot as plt\n",
1432-
"%matplotlib inline\n",
14331432
"\n",
14341433
"A = 1.2 # amplitude of signal\n",
14351434
"Q = 1/10 # quantization stepsize\n",
14361435
"N = 2000 # number of samples\n",
14371436
"\n",
14381437
"\n",
14391438
"def uniform_midtread_quantizer(x, Q):\n",
1439+
" '''Uniform mid-tread quantizer with limiter.'''\n",
14401440
" # limiter\n",
14411441
" x = np.copy(x)\n",
14421442
" idx = np.where(np.abs(x) >= 1)\n",
@@ -1448,6 +1448,7 @@
14481448
"\n",
14491449
"\n",
14501450
"def plot_signals(x, xQ):\n",
1451+
" '''Plot continuous, quantized and error signal.'''\n",
14511452
" e = xQ - x\n",
14521453
" plt.figure(figsize=(10, 6))\n",
14531454
" plt.plot(x, label=r'signal $x[k]$')\n",
@@ -2883,6 +2884,7 @@
28832884
"\n",
28842885
"\n",
28852886
"def uniform_midrise_quantizer(x, Q):\n",
2887+
" '''Uniform mid-rise quantizer with limiter.'''\n",
28862888
" # limiter\n",
28872889
" x = np.copy(x)\n",
28882890
" idx = np.where(np.abs(x) >= 1)\n",
@@ -2941,7 +2943,7 @@
29412943
"name": "python",
29422944
"nbconvert_exporter": "python",
29432945
"pygments_lexer": "ipython3",
2944-
"version": "3.7.5"
2946+
"version": "3.7.9"
29452947
}
29462948
},
29472949
"nbformat": 4,

quantization/linear_uniform_quantization_error.ipynb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3662,6 +3662,7 @@
36623662
"\n",
36633663
"\n",
36643664
"def uniform_midtread_quantizer(x, Q):\n",
3665+
" '''Uniform mid-tread quantizer with limiter.'''\n",
36653666
" # limiter\n",
36663667
" x = np.copy(x)\n",
36673668
" idx = np.where(x <= -1)\n",
@@ -3675,6 +3676,7 @@
36753676
"\n",
36763677
"\n",
36773678
"def analyze_quantizer(x, e):\n",
3679+
" '''Compute and plot PDF, CCF and PSD of quantizer.'''\n",
36783680
" # estimated PDF of error signal\n",
36793681
" pe, bins = np.histogram(e, bins=20, density=True, range=(-Q, Q))\n",
36803682
" # estimate cross-correlation between input and error\n",
@@ -4910,6 +4912,7 @@
49104912
"\n",
49114913
"\n",
49124914
"def compute_SNR(a):\n",
4915+
" '''Numerically evaluate SNR of a quantized normally distributed signal.'''\n",
49134916
" # compute input signal\n",
49144917
" x = np.random.normal(size=N, scale=a)\n",
49154918
" # quantize signal\n",
@@ -4922,6 +4925,7 @@
49224925
"\n",
49234926
"\n",
49244927
"def plot_SNR(A, SNR):\n",
4928+
" '''Plot SNR.'''\n",
49254929
" # plot results\n",
49264930
" plt.figure(figsize=(8, 4))\n",
49274931
" plt.plot(20*np.log10(A), SNR)\n",
@@ -6202,6 +6206,7 @@
62026206
"\n",
62036207
"\n",
62046208
"def compute_SNR(a):\n",
6209+
" '''Numerically evaluate SNR of a quantized Laplace distributed signal.'''\n",
62056210
" # compute input signal\n",
62066211
" x = np.random.laplace(size=N, scale=a/np.sqrt(2))\n",
62076212
" # quantize signal\n",

quantization/noise_shaping.ipynb

Lines changed: 145 additions & 133 deletions
Large diffs are not rendered by default.

quantization/nonlinear_quantization_speech_signal.ipynb

Lines changed: 254 additions & 227 deletions
Large diffs are not rendered by default.

quantization/oversampling.ipynb

Lines changed: 112 additions & 99 deletions
Large diffs are not rendered by default.

quantization/requantization_speech_signal.ipynb

Lines changed: 461 additions & 412 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)