Rinatum
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Lab 5: Discrete Fourier Transform DFT is a tool that is widely used in many areas. Yet, it is often taken for granted without proper understanding. In this assignment, we are going to develop a deeper understanding of DFT. # Ринат, привет! ## Content [TOC] ## Fourier Transform ### DTFT The spectrum of the discrete signal is evaluated with the help of a discrete-time Fourier transform (DTFT). Unfortunately, DTFT is not a practical transformation. First, the signal is fully specified only when DTFT is computed for all frequencies in the range , which includes an infinite number of points. ### DFT Discrete Fourier Transform allows overcoming some practical problems that arise from using DTFT. The core idea of DFT is to take a signal of finite length and introduce a periodic extension of this signal. ![](https://i.imgur.com/t5gGoNx.png) DTFT of a time-limited signal results in the signal with an unbounded spectrum. Periodic extension of the signal that takes place in DFT allows reducing the number of non-zero components in the spectrum. ![](https://i.imgur.com/1klD8Pd.png) ### FFT Suppose, we separated the Fourier Transform into even and odd indexed sub-sequences. ![](https://i.imgur.com/4V4yhW5.png) After performing a bit of algebra, we end up with the summation of two terms. The advantage of this approach lies in the fact that the even and odd indexed sub-sequences can be computed concurrently. ![](https://i.imgur.com/v63VI1x.png) | Column 1 | Column 2 | Column 3 | | -------- | -------- | -------- | | Text | Text | Text | Suppose, `N = 8` , to visualize the flow of data with time, we can make use of a butterfly diagram. We compute the Discrete Fourier Transform for the even and odd terms simultaneously. Then, we calculate `x[k]` using the formula from above. ![](https://i.imgur.com/7hHhoY8.png) Notice how we were able to cut the time taken to compute the Fourier Transform by a factor of 2. We can further improve the algorithm by applying the divide-and-conquer approach, halving the computational cost each time. We can express the gains in terms of Big O Notation ![](https://i.imgur.com/1qYfh7j.png) ## Exploring DFT ### Spectral leakage If we build a simple single-frequency wave, as shown in the figure below, the transformation will result in non-zero magnitude values at the correct frequencies. We get such a good result because the sampling frequency matches peaks and valleys. The signal has a single frequency spectrum under the condition that the ratio of the number of samples in the sequence $N$ by the number of samples in a single period of the signal $N_T$ is an integer: $$\frac{N}{N_T} = k; k \in 0..N-1$$ This comes from the fact that when these conditions are met, the periodic extension of the signal results in an uninterrupted sinusoidal function. If we change the frequency of the cosine wave such that this number is rational, spectral leakage is observed. The result of the transformation will show the presence of other frequencies ![](https://i.imgur.com/G2NvRBx.png) Here we can see 4 signals in time domain`(first column)` and frequency domain `(second column)` and all of them are sampled in the same $N = 40$ timestamps and $\Delta t = 0.01$. We can compute $N_T = (1 / freq) / \Delta t$ - sin with $freq = 5$. $N / N_T = \frac{40}{(\frac{0.2}{0.01})} = 2$ - is integer - sin with $freq = 21$. $N / N_T = \frac{40}{\frac{(\frac{1}{21})}{0.01}}$ - is not integer - sin with $freq = 37$. $N / N_T = \frac{40}{\frac{(\frac{1}{37})}{0.01}}$ - is not integer So we understand that only first signal has no a leakage. Also , it is correct in the frequency domain of last signal (sum of all) Increasing/decreasing of amplitude can change only magnitude of frequency in frequency domain but not the frequency itself. ### Zero Padding and Spectral Interpolation In the example above, we have observed that the DFT spectrum is not always what we think. Remember that DFT approaches DTFT when $N \rightarrow \infty$ . This is equivalent to padding our signal with an infinite number of zeros. Let's try to apply this trick to our signals. ![](https://i.imgur.com/DvRugkJ.png) We can see that for our signals (and for time-limited signals), taking the DFT of the entire non-zero portion of extended by zeros yields exact interpolation [not an approximation] of the complex spectrum. Spectrums are not the same. Peaks smoothed out and microwaves appeared ## Aliasing ### Nyquist sampling theorem The Nyquist sampling theorem (Kotelnikov theorem) provides a prescription for the nominal sampling interval required to avoid aliasing. It may be stated simply as follows: The sampling frequency should be at least twice the highest frequency contained in the signal. $$f_s \geq 2f_c$$ ### Aliasing Effect Let's consider aliasing effect on real example. We will plot 2 signals in time range 0.5 sec. First one is cosine with frequency 190 Hz and amplitude 0.5 Second one is cosine with frequency 10 Hz and amplitude 2 Let's check it with two different sampling rates - 200 - 500 ![](https://i.imgur.com/O5WXSA4.png) For first row two signals with `different frequencies` share `one` peak and it is not good. ($f_s = 200 < 2f_c = 2 * 190 = 380$) The person receiving these samples, without any previous knowledge of the original signals, may well be misled into thinking that the signals has quite a different form For second row two signals with `different frequencies` have `different peaks` and it is what we want. ($f_s = 500 > 2f_c = 2 * 190 = 380$) ## DFT basis orthogonality The vectors ![](https://i.imgur.com/eMCAF8x.png) form an orthogonal basis over the set of N-dimensional complex vectors. Proof ![](https://i.imgur.com/isMVpqu.png) Where $\delta_{kk'}$ is the Kronecker delta. (In the last step, the summation is trivial if $k=k'$, where it is $1+1+⋅⋅⋅=N$, and otherwise is a geometric series that can be explicitly summed to obtain zero.) (Also showed in the code) ## Self-check questions 1. What is the difference between DFT and FFT algorithms? FFT (Fast Fourier Transform) is particular implementation of DFT (Discrete Fourier Transform) and has computational complexity of `O(N log(N))`, which is so far the best of all proposed Fourier transformations for discrete data. Most algorithms for DFT are`O(N^2)`. Also FFT can applied only to signal with length which is not the power of 2. 2. What is the cause of spectral leakage? $$\frac{N}{N_T} = k; k \notin 0..N-1$$ 3. How to make an ideal interpolation in the frequency domain? Padding our signal with an infinite number of zeros. 4. How can ideal interpolation clarify the frequency value in the case of spectral leakage? Increasing number of samples increases coverage in frequency domain too. It allows to highlight the peak and clerify correct frequency 5. What may occur if the sampling rate is incorrectly selected? `Different frequencies` will share `one` peak. The person receiving these samples, without any previous knowledge of the original signals, may well be misled into thinking that the signals has quite a different form We are not only losing information, but we are getting the wrong information about the signal

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully