{"id":17720737,"url":"https://github.com/freed-wu/dsp-homework","last_synced_at":"2026-02-06T03:31:30.447Z","repository":{"id":135881108,"uuid":"430741048","full_name":"Freed-Wu/dsp-homework","owner":"Freed-Wu","description":"A backup of my homework. 现代数字信号处理 DSP II","archived":false,"fork":false,"pushed_at":"2023-02-26T04:34:52.000Z","size":1720,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-20T17:46:26.589Z","etag":null,"topics":["homework","ustc"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Freed-Wu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-22T14:31:23.000Z","updated_at":"2024-06-20T10:13:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"7029a47c-a1ed-42e4-8637-eaa9a683ba16","html_url":"https://github.com/Freed-Wu/dsp-homework","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Freed-Wu/dsp-homework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freed-Wu%2Fdsp-homework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freed-Wu%2Fdsp-homework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freed-Wu%2Fdsp-homework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freed-Wu%2Fdsp-homework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Freed-Wu","download_url":"https://codeload.github.com/Freed-Wu/dsp-homework/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freed-Wu%2Fdsp-homework/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29148128,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T02:39:25.012Z","status":"ssl_error","status_checked_at":"2026-02-06T02:37:22.784Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["homework","ustc"],"created_at":"2024-10-25T15:29:00.504Z","updated_at":"2026-02-06T03:31:30.432Z","avatar_url":"https://github.com/Freed-Wu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\nCJKmainfont: WenQuanYi Micro Hei\ntitle: LMS 计算机练习\nauthor: Wu Zhenyu (SA21006096)\ninstitute: USTC\ndocumentclass: ctexart\n---\n\n# LMS 计算机练习\n\n传统的宽带信号中抑制正弦干扰的方法是采用陷波器(notch filter),为此我们需要精确知\n道干扰正弦的频率.然而当干扰正弦频率是缓慢变化时,且选频率特性要求十分尖锐时,则最\n好采用自适应噪声抵消的方法.下图是用一个二阶FIR的LMS自适应滤波器消除正弦干扰的一\n个方案。\n\n![filter](images/filter.png \"filter\")\n\n## 1\n\n借助MATLAB画出误差性能曲面和误差性能曲面的等值曲线；\n\n---\n\n![误差性能曲面](images/surface.png \"surface\")\n\n等值曲线见题[4](#4)\n\n## 2\n\n写出最陡下降法， LMS算法的计算公式($\\delta = 0.4$)；\n\n---\n\n$$\\begin{aligned}\ny \u0026 = \\mathbf{h}^\\mathsf{T}\\mathbf{x} + e\\\\\nJ(\\mathbf{h}) \u0026 = \\mathrm{E}e^2\\\\\n\u0026 = \\mathrm{E}y^2 - 2\\mathbf{r}_{y\\mathbf{x}}^\\mathsf{T}\\mathbf{h} +\n\\mathbf{h}^\\mathsf{T}\\mathbf{R}_\\mathbf{xx}\\mathbf{h}\\\\\n\\frac{\\partial{J}}{\\partial\\mathbf{h}}\\Big(\\mathbf{h}\\Big) \u0026 =\n-2\\mathrm{E}e\\mathbf{x}\\\\\n\u0026 = (\\mathbf{R}_\\mathbf{xx} + \\mathbf{R}_\\mathbf{xx}^\\mathsf{T})\\mathbf{h}\n- 2\\mathbf{r}_{y\\mathbf{x}}\\\\\n\u0026 = 2\\mathbf{R}_\\mathbf{xx}\\mathbf{h}\n- 2\\mathbf{r}_{y\\mathbf{x}}\n\\end{aligned}$$\n\nBecause $\\mathbf{R}_\\mathbf{xx}$ is a `Toplitz` matrix, We only need to solve\n$(\\mathbf{R}_\\mathbf{xx})_{k0}$.\n\nwhere,\n\n$$\\begin{aligned}\n(\\mathbf{R}_\\mathbf{xx})_{k0} \u0026 =\n\\mathrm{E}_i\\sqrt2\\Big(\\sin2\\pi\\frac{i + k}{16}\\Big)\n\\sqrt2\\sin2\\pi\\frac{i}{16}\\\\\n\u0026 = \\cos2\\pi\\frac{k}{16}\\\\\n\\mathbf{R}_\\mathbf{xx} \u0026 = \\begin{bmatrix}\n1 \u0026 0.9239\\\\\n0.9239 \u0026 1\n\\end{bmatrix}\\\\\n(\\mathbf{r}_{y\\mathbf{x}})_k \u0026 =\n\\mathrm{E}_i\\sqrt2\\Big(\\sin2\\pi\\frac{i + k}{16}\\Big)\n\\sin(2\\pi\\frac{i}{16} + \\frac{\\pi}{10})\\\\\n\u0026 = \\frac1{\\sqrt2}\\cos(\\frac{2\\pi k}{16} + \\frac{\\pi}{10})\\\\\n\\mathbf{r}_{y\\mathbf{x}} \u0026 = \\begin{bmatrix}\n0.6725\\\\\n0.5377\n\\end{bmatrix}\\\\\n\\mathrm{E}y^2 \u0026 = 0.5 + 0.05\\\\\n\u0026 = 0.55\n\\end{aligned}$$\n\nSo, 最陡下降法：\n\n$$\\begin{aligned}\n\\mathbf{h}(n + 1) \u0026 = \\mathbf{h}(n) -\n\\frac\\delta2 \\frac{\\partial{J}}{\\partial\\mathbf{h}}\\Big(\\mathbf{h}(n)\\Big)\\\\\n\u0026 = \\mathbf{h}(n) + \\delta\\mathrm{E}e(n)\\mathbf{x}(n)\\\\\n\u0026 = \\mathbf{h}(n) + \\delta(\\mathbf{r}_{y\\mathbf{x}} -\n\\mathbf{R}_\\mathbf{xx}\\mathbf{h}(n))\n\\end{aligned}$$\n\nLMS：\n\n$$\\begin{aligned}\n\\mathbf{h}(n + 1) \u0026 = \\mathbf{h}(n) + \\delta e(n)\\mathbf{x}(n)\\\\\n\\end{aligned}$$\n\n## 3\n\n用MATLAB产生方差为0.05,均值为0白噪音$S(n)$，并画出其中一次实现的波形图；\n\n---\n\n![noise](images/noise.png \"noise\")\n\n## 4\n\n根据2）中的公式，并利用3）中产生的$S(n)$，在1）中的误差性能曲面的等值曲线上叠加画出采用最陡下降法， LMS法时$H(n)$的在叠代过程中的轨迹曲线。\n\n---\n\n![error](images/error.png \"error\")\n\n![轨迹曲线](images/lms.png \"lms\")\n\n注意，在起点处，LMS先向左移动是正确现象，因为 `python` 数组从 0 开始，正弦信号\n在 $n = 0$ 处为 0, 所以第 1 次迭代会有使 1 个方向的下降为 0 。\n而 `matlab` 数组从 1 开始，不会有这种现象。\n\n## 5\n\n用MATLAB计算并画出LMS法时$J(n) = e^2(n)$随时间$n$的变化曲线（对 应$S(n)$的某一次的一次实现）和$e(n)$波形；某一次实现的结果并不能从统计的角度反映实验的结果的正确性，为得到具有统计特性的实验结果，可用足够多次的实验结果的平均值作为实验的结果。用MATLAB计算并画出LMS法时$J(n)$的100次实验结果的平均值随时间$n$的变化曲线。\n\n---\n\n![loss](images/loss.png \"loss\"){#loss}\n\n## 6\n\n用MATLAB计算并在1）中的误差性能曲面的等值曲线上叠加画出LMS法时100次实验中的$H(n)$的平均值的轨迹曲线；\n\n---\n\n见题[4](#4)\n\n## 7\n\n对以上实验结果给出一些你认为有价值的讨论。\n\n（在实验中$n = 1, \\ldots, N$，$N$的取值根据实验情况确定，一般选取足够大以使算法达到基本收敛，本题作业以电子文档PDF格式提供）\n\n---\n\nLMS 算法收敛速度比最陡下降法慢，在极值点会有严重抖动，可以通过平均缓解抖动。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreed-wu%2Fdsp-homework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreed-wu%2Fdsp-homework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreed-wu%2Fdsp-homework/lists"}