Skip to content

Commit

Permalink
signal eigendecomposition
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdiolfat committed Mar 5, 2024
1 parent f8c59c4 commit bef9f0c
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/process_arma.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.0"
"version": "3.12.1"
}
},
"nbformat": 4,
Expand Down
71 changes: 65 additions & 6 deletions examples/signal_eigendecomposition.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
"import os, sys\n",
"dir = os.path.abspath('../ssp')\n",
"dir = os.path.dirname(dir)\n",
"sys.path.append(dir)\n",
"\n",
"import numpy as np\n",
"\n",
"from ssp import spectrum"
]
},
{
Expand Down Expand Up @@ -83,7 +90,7 @@
"Let $ e_i $ be a column vector:\n",
"\n",
"$$\n",
"e_i = [1, e^{j \\omega_i}, e^{j \\omega_i}, ..., e^{j (M-1) \\omega_i}] ^T\n",
"e_i = [1, e^{j \\omega_i}, e^{j 2 \\omega_i}, ..., e^{j (M-1) \\omega_i}] ^T\n",
"$$\n",
"\n",
"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",
Expand Down Expand Up @@ -114,15 +121,67 @@
"source": [
"# Example of four sinusoids\n",
"\n",
"$ \\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",
"$ \\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",
"\n",
"M = 64"
"$$\n",
"x(n) = \\sum_{k = 1}^{4} e^{j(n \\omega_k + \\phi_k)} + w(n)\n",
"$$"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"R = 10\n",
"N = 64\n",
"nvar = 0.5\n",
"wk = [0.2, 0.3, 0.8, 1.2]\n",
"\n",
"rng1 = np.random.default_rng()\n",
"signoise = rng1.normal(0, np.sqrt(nvar), (R, N))\n",
"\n",
"rng2 = np.random.default_rng()\n",
"phasek = rng2.uniform(0, 2 * np.pi, (R, N))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Simulation\n",
"\n",
"For the Pisarenko method, a 5x5 autocorrelation matrix is estimated from the ten simulated 64-sample realizations.\n",
"\n",
"The other methods all use the samples as the 64x64 sampled matrix over 10 realizations."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": ".env.py.312",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.1"
}
},
"nbformat": 4,
Expand Down

0 comments on commit bef9f0c

Please sign in to comment.