Hot answers tagged

5

You can, but... you'll need to keep symmetry if your original time-domain signal is real-valued. If a signal $x$ is real-valued, then its DFT $X$ will exhibit complex-conjugate symmetry: $$ X[k] = X^*[N-k]. $$ So you can generate $N$ Gaussian pseudo-random noise samples, $g[n]$, and place them in the frequency domain noise vector, $\epsilon$ as: $$ \...


3

maybe you can do it from bottom to top or top to bottom using something like the following. a notation about notation: $x[n]$ is the input sample for the $n$-th sample. this originally comes from an A/D converter, but may have come from a sound file. $x_1[n]$ and $x_2[n]$ are two separate inputs. $y[n]$ is the output sample at the $n$-th time. it will ...


3

To provide a more quantitative approach, I have made a jupyter notebook (which can be seen as a web page here. The results can be summarized in the following plot: In practice, I have found that numpy was always faster by a significant amount. However, it seems new alternatives are emerging and I have to include (not exhaustive): architecture specific ...


2

In fact Welch was a good idea. End of post. Problem solved. # Loop for FFT data for dataset in [fft1]: dataset = np.asarray(dataset) freqs, psd = welch(dataset, fs=266336/300, window='hamming', nperseg=8192) plt.semilogy(freqs, psd/dataset.size**2, color='r') for dataset2 in [fft2]: dataset2 = np.asarray(dataset2) freqs2, psd2 = welch(...


2

It depends on the sizes of the images and the filters. Sometimes it also depends on the filters themselves and the quality required. Assuming all arbitrary (Namely the filters have no special property but their size, some of them are HPF, some LPF, some neither, they are not separable, no approximation is allowed, etc...) one could follow this: If the ...


2

First of all, thanks for sharing this problem. I hope it can foster some good discussions here at stack-exchange. I guess this problem is commonly called Multi-Focus Multi-Image Fusion (MF-MIF). Let's look at all the images together with their grayscale histograms and the gradient magnitude (information content in each image): As the original question ...


1

First of all, sampling frequency and sampling rate are synonymous. You mean sampling frequency of 44.1 kHz with a data length of 20 ms. Second of all, 20 ms of data at 44.1 kHz will give you 882 points. Not enough for a 1024-point FFT. You will either need to upsample to 51.2 kHz, that way 20 ms will give you 1024 points. Or you could append 142 zeroes to ...


1

You can use the Fourier transform for a lot of things – it can be part of a particular step in a scaling algorithm. Still, what you're looking for are scaling algorithms. In this particular case, your original data size is (74 × 128) – what that means in wavelengths or any physical unit doesn't matter to algorithms – and you want to scale it to (512 × 512). ...


1

As this page https://ccrma.stanford.edu/~jos/ReviewFourier/FFT_Convolution.html mentions, when you perform cyclic convolution (FFT convolution) you have to add zeros to your signal $A$ to the length $$N_Y = N_A + N_A -1,$$ where $N_Y$ is the length of the output convolution and $N_A$ is length of your signal. In your case you are performing the FFT ...


1

Answers to Your Questions You are right that your time instants are spaced at an interval of $T$. Hence, the sampling rate is $1/T$. ($T$ is defined in line 3 of your code.) You are also right that the second parameter of np.fft.fftfreq() is the sampling interval $T$. I am, however, not sure why you get wrong results when setting $T=100\,\text{Hz}$. This ...


1

This boils down to computing the sum of a geometric series. Given $$x[n]=e^{-\alpha n},\qquad n=0,1,\ldots,N-1\tag{1}$$ the DFT is $$\begin{align}X[k]&=\sum_{n=0}^{N-1}x[n]e^{-j2\pi nk/N}\\&=\sum_{n=0}^{N-1}e^{-\alpha n}e^{-j2\pi nk/N}\\&=\frac{1-e^{-\alpha N}}{1-e^{-\alpha}e^{-j2\pi k/N}},\qquad\alpha\neq 0,\quad k=0,1,\ldots N-1\tag{2}\end{...


1

You seem to know how to handle the DFT/FFT scaling so that its output matches the sampled signal's power/amplitude levels. Yet there is a discrepancy between your expectation and the obsevred DFT result? There are a few reasons. Your assumptions on the sampling rate or the signal frequency could be wrong. Indeed as it seems from your figures, the signal is ...


1

These questions will probably seem silly to you, sorry for that. No question is "silly". My perception is that the questions are trivial and can be answered by looking things up in a textbook but if this is to get you out of a "difficult corner", here it goes: ...I was expecting that the real part will represent amplitudes of two sinusoidal signals and ...


1

2 comments: First, scipy signal decimate already low-pass filters the signal. It first filters the signal and then subsamples. So there is no need to pre-filter your signal before decimation. In your case, the signal is filtered at 125 Hz, which is half the resulting sampling frequency. (decimate doc here) Second, a Butterworth filter is not an ideal ...


1

First off, you have a "bug" in your code. Look at line 45: combined_fft = np.fft.fft(signal) You are taking the FFT of your signal and calling it, and labeling it, the combined signal. Fix this, and you will see two peaks on each end. If you use the "rfft" (real FFT) call instead, you will get back the first half and the Nyquist bin for even N. ...


1

To answer the question in your title: Because it is defined to do exactly that. Think about it: the DFT is a revertible linear operation on all vectors of the $\mathbb C^N$. In other words, for every vector that you apply the DFT to, there is exactly one vector that is the result, and for every result vector, there is exactly one vector that maps to it. ...


1

When you construct re_field, ditch the np.abs. It turns all negative values of the sine wave positive. Instead, do a np.realon the result of the ifft2 to get rid of the imaginary parts caused by rounding errors. Then you will get a result perfectly matching the original. In the magnitude spectrum you cannot see the sine wave you inserted, because its ...


1

I believe the short answer is no. The paper is behind a paywall so I didn't look at it. In the abstract is the following blurb: " use interpolation techniques to resample the signal at constant angular increments, followed by a common discrete Fourier transform to shift from the angular domain to the order domain." In which they are describing other ...


1

If you have a filter in the time/space domain, the location that is associated with zero linear phase in the frequency domain is the top left pixel of the filter. If the filter is centered in time/space, then you need to ifftshift prior to taking the FFT in order to remove the linear phase that centers it in the time domain. The following example Octave code ...


Only top voted, non community-wiki answers of a minimum length are eligible