-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guide fft #1559
base: main
Are you sure you want to change the base?
Guide fft #1559
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going in a great direction. We might want to separate the DFT part onto an NxSignal livebook instead, but let's keep working on this as a whole here before we decide!
@@ -258,7 +258,7 @@ The picture below will help to understand the aggregations. | |||
|
|||
<!-- livebook:{"break_markdown":true} --> | |||
|
|||
$$ | |||
```math |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't rendering properly inside livebook anymore unfortunately. Please undo the ```math
changes
{:nx, "~> 0.9.1"}, | ||
{:kino, "~> 0.14.2"}, | ||
{:kino_vega_lite, "~> 0.1.11"}, | ||
{:exla, "~> 0.9.1"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not use EXLA here since it's a simpler example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was an excuse to put the correct way to use EXLA as a backend. Up to you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove it
|
||
Let's visualize our incoming signal over 400ms. This correspond to 2 periods of our 5Hz signal. | ||
|
||
We compute 200 points to have a smooth curve, thus every (400/200=) 2ms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We compute 200 points to have a smooth curve, thus every (400/200=) 2ms. | |
We'll sample 200 equidistant points to so we can see a smooth curve (i.e. every 400ms/200 = 2ms, or a sampling frequency of 500Hz). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll sample 200 equidistant points to have a smooth curve, every 400ms/200 = 2ms, or equivalently with a sampling frequency of 500Hz.
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
Co-authored-by: Paulo Valente <[email protected]>
I wonder why FFT and conv are in Nx and not in NxSignal ?? Now that this aperitif is almost done, I feel it is more interesting to play with the |
Co-authored-by: Paulo Valente <[email protected]>
Awesome. I will ping you regarding convolutional filters, as I've just given a talk on that! This is the repo if you want to take a look already: https://github.com/polvalente/code-beam-lite-nyc-2024 Regarding fft and conv being in Nx, ultimately the reason is that they are present in the XLA API, really. And NxSignal is a library that currently only implements things through calling Nx itself. Think of Nx as being analogous to NumPy, while NxSignal is a subsection of SciPy. Finally, conv is an operation in itself and can be implemented in the time domain. Nx doesn't build it on top of FFT. |
Ah! I recall I had a little home work on cyclotomic polynomials and FFT for polynomial products (a convolution in fact) but was a long time ago. So if you already did it, I can only will bring in a kinda noob POV! Thanks for the link, I will run it. |
The talk wasn't recorded, and putting it in a livebook format would be great! To be clear, FFT can execute the convolution (with some restrictions) but it's important to keep in mind that each is its own primitive in Nx |
In Scipy, I just had a look, there make some quick calculations to predict which method, direct or via FFT, is faster. and conv = IFFT( FFT x FFT(conjugate). But for later! |
First commit