|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "code",
|
5 |
| - "execution_count": null, |
| 5 | + "execution_count": 10, |
6 | 6 | "metadata": {},
|
7 | 7 | "outputs": [],
|
8 | 8 | "source": [
|
9 |
| - "import numpy as np" |
| 9 | + "import os, sys\n", |
| 10 | + "dir = os.path.abspath('../ssp')\n", |
| 11 | + "dir = os.path.dirname(dir)\n", |
| 12 | + "sys.path.append(dir)\n", |
| 13 | + "\n", |
| 14 | + "import numpy as np\n", |
| 15 | + "\n", |
| 16 | + "from ssp import spectrum" |
10 | 17 | ]
|
11 | 18 | },
|
12 | 19 | {
|
|
83 | 90 | "Let $ e_i $ be a column vector:\n",
|
84 | 91 | "\n",
|
85 | 92 | "$$\n",
|
86 |
| - "e_i = [1, e^{j \\omega_i}, e^{j \\omega_i}, ..., e^{j (M-1) \\omega_i}] ^T\n", |
| 93 | + "e_i = [1, e^{j \\omega_i}, e^{j 2 \\omega_i}, ..., e^{j (M-1) \\omega_i}] ^T\n", |
87 | 94 | "$$\n",
|
88 | 95 | "\n",
|
89 | 96 | "If we layout a new matrix with $ p $ many of $ e_i $ column vectors the result is a $ M $ x $ p $ matrix which we represent as:\n",
|
|
114 | 121 | "source": [
|
115 | 122 | "# Example of four sinusoids\n",
|
116 | 123 | "\n",
|
117 |
| - "$ \\omega_k $ are $ 0.2\\pi, 0.3\\pi, 0.8\\pi, 1.2\\pi $ and the variance of white noise variance is $ \\sigma_w^2 = 0.5 $.\n", |
| 124 | + "$ \\omega_k $ are $ 0.2\\pi, 0.3\\pi, 0.8\\pi, 1.2\\pi $ and the variance of white noise variance is $ \\sigma_w^2 = 0.5 $. Number of samples is M = 64 $\n", |
118 | 125 | "\n",
|
119 |
| - "M = 64" |
| 126 | + "$$\n", |
| 127 | + "x(n) = \\sum_{k = 1}^{4} e^{j(n \\omega_k + \\phi_k)} + w(n)\n", |
| 128 | + "$$" |
120 | 129 | ]
|
| 130 | + }, |
| 131 | + { |
| 132 | + "cell_type": "code", |
| 133 | + "execution_count": 13, |
| 134 | + "metadata": {}, |
| 135 | + "outputs": [], |
| 136 | + "source": [ |
| 137 | + "R = 10\n", |
| 138 | + "N = 64\n", |
| 139 | + "nvar = 0.5\n", |
| 140 | + "wk = [0.2, 0.3, 0.8, 1.2]\n", |
| 141 | + "\n", |
| 142 | + "rng1 = np.random.default_rng()\n", |
| 143 | + "signoise = rng1.normal(0, np.sqrt(nvar), (R, N))\n", |
| 144 | + "\n", |
| 145 | + "rng2 = np.random.default_rng()\n", |
| 146 | + "phasek = rng2.uniform(0, 2 * np.pi, (R, N))" |
| 147 | + ] |
| 148 | + }, |
| 149 | + { |
| 150 | + "cell_type": "markdown", |
| 151 | + "metadata": {}, |
| 152 | + "source": [ |
| 153 | + "## Simulation\n", |
| 154 | + "\n", |
| 155 | + "For the Pisarenko method, a 5x5 autocorrelation matrix is estimated from the ten simulated 64-sample realizations.\n", |
| 156 | + "\n", |
| 157 | + "The other methods all use the samples as the 64x64 sampled matrix over 10 realizations." |
| 158 | + ] |
| 159 | + }, |
| 160 | + { |
| 161 | + "cell_type": "code", |
| 162 | + "execution_count": null, |
| 163 | + "metadata": {}, |
| 164 | + "outputs": [], |
| 165 | + "source": [] |
121 | 166 | }
|
122 | 167 | ],
|
123 | 168 | "metadata": {
|
| 169 | + "kernelspec": { |
| 170 | + "display_name": ".env.py.312", |
| 171 | + "language": "python", |
| 172 | + "name": "python3" |
| 173 | + }, |
124 | 174 | "language_info": {
|
125 |
| - "name": "python" |
| 175 | + "codemirror_mode": { |
| 176 | + "name": "ipython", |
| 177 | + "version": 3 |
| 178 | + }, |
| 179 | + "file_extension": ".py", |
| 180 | + "mimetype": "text/x-python", |
| 181 | + "name": "python", |
| 182 | + "nbconvert_exporter": "python", |
| 183 | + "pygments_lexer": "ipython3", |
| 184 | + "version": "3.12.1" |
126 | 185 | }
|
127 | 186 | },
|
128 | 187 | "nbformat": 4,
|
|
0 commit comments