From bef9f0c6eb4d75230896bcc050d531743e801d9f Mon Sep 17 00:00:00 2001 From: Mahdi Olfat Date: Tue, 5 Mar 2024 10:22:37 -0500 Subject: [PATCH] signal eigendecomposition --- examples/process_arma.ipynb | 2 +- examples/signal_eigendecomposition.ipynb | 71 ++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 7 deletions(-) diff --git a/examples/process_arma.ipynb b/examples/process_arma.ipynb index 866c4a2..07039bf 100644 --- a/examples/process_arma.ipynb +++ b/examples/process_arma.ipynb @@ -179,7 +179,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.0" + "version": "3.12.1" } }, "nbformat": 4, diff --git a/examples/signal_eigendecomposition.ipynb b/examples/signal_eigendecomposition.ipynb index 795753f..d1467a5 100644 --- a/examples/signal_eigendecomposition.ipynb +++ b/examples/signal_eigendecomposition.ipynb @@ -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" ] }, { @@ -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", @@ -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,