05: Implement DFT(yk) with an example

This commit is contained in:
2022-02-15 11:46:13 +01:00
parent 4d3d0c2f4b
commit e71744358e

View File

@ -39,7 +39,7 @@
"cell_type": "raw",
"metadata": {},
"source": [
"team_members = \"\""
"team_members = \"Koen Vendrig, Kees van Kempen\""
]
},
{
@ -66,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"deletable": false,
"nbgrader": {
@ -83,10 +83,7 @@
},
"outputs": [],
"source": [
"# Import packages here ...\n",
"\n",
"# YOUR CODE HERE\n",
"raise NotImplementedError()"
"import numpy as np"
]
},
{
@ -121,7 +118,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 22,
"metadata": {
"deletable": false,
"nbgrader": {
@ -139,8 +136,31 @@
"outputs": [],
"source": [
"def DFT(yk):\n",
" # YOUR CODE HERE\n",
" raise NotImplementedError()"
" N = len(yk)\n",
" x = 2*np.pi*np.arange(N)/N\n",
" beta = yk.T * np.exp(-np.dot(np.arange(N), x)*1j)\n",
" return beta"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([-1.-8.57252759e-16j, -2.-1.71450552e-15j, -7.-6.00076932e-15j,\n",
" -6.-5.14351656e-15j])"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"DFT(np.array([1,2,7,6]))"
]
},
{
@ -419,7 +439,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},