Highest voted questions tagged derivative - Signal Processing Stack Exchange most recent 30 from dsp.stackexchange.com 2019-11-18T16:05:36Z https://dsp.stackexchange.com/feeds/tag?tagnames=derivative&sort=votes https://creativecommons.org/licenses/by-sa/4.0/rdf https://dsp.stackexchange.com/q/51617 8 Bounds of the derivative of a bounded band-limited function Olli Niemitalo https://dsp.stackexchange.com/users/15347 2018-08-30T07:22:04Z 2019-01-15T20:55:14Z <p>Let $f(t)$ be a function with properties:</p> <p>$$\begin{array}{ll} t\in\mathbf{R}&amp;t\text{ is in reals}\\ f(t)\in\mathbf{R}\text{ for all } t&amp;f(t)\text{ is in reals}\\ |f(t)|&lt;A\text{ for all }t&amp;\text{absolute value of }f(t)\text{ is bounded above by }A\\ \int_{-\infty}^{\infty} f(t) \ e^{- i \omega t} \ {\rm d}t = 0\text{ for all }|\omega|\ge B&amp;f(t)\text{ is band-limited by frequency B in radians} \end{array}$$</p> <p>Given $A$ and $B,$ what is the tight upper bound for $|f'(t)|,$ the absolute value of the derivative of the function?</p> <p>Nothing else shall be assumed about $f(t)$ than what has been stated above. The bound should accommodate for this uncertainty.</p> <p>For a sinusoid of amplitude $A$ and frequency $B,$ the maximum absolute value of the derivative is $AB.$ I wonder if this is an upper bound, and in that case also the tight upper bound. Or maybe a non-sinusoidal function has a steeper slope.</p> https://dsp.stackexchange.com/q/52953 5 Bounds of the difference of a bounded band-limited function alwaystudent https://dsp.stackexchange.com/users/38528 2018-10-29T17:24:36Z 2018-10-31T17:50:23Z <p>For a continuous signal (function), we have Bernstein inequality : <span class="math-container">$$|{df(t)}/dt| \le 2AB\pi$$</span> where <span class="math-container">$A=\sup|f(t)|$</span> and <span class="math-container">$B$</span> is the bandwidth of <span class="math-container">$f(t)$</span>. The question is: is there a relationship for a discrete function <span class="math-container">$x[n]$</span> like this? <span class="math-container">$$|x[n] -x[n-1] | \le\ \mu\ W$$</span> where <span class="math-container">$$X[k] = \sum\limits_{n = 0}^{N - 1} {x[n]{e^{ - j\frac{{2\pi }}{N}nk}}}$$</span> is the DFT for <span class="math-container">$x[n]$</span>, <span class="math-container">$X[k]=0$</span> for <span class="math-container">$k&gt; W$</span>.</p> https://dsp.stackexchange.com/q/14267 4 Ways to compute the n-the derivative of a discrete signal JustGoscha https://dsp.stackexchange.com/users/3352 2014-02-08T15:38:20Z 2014-02-09T01:26:56Z <p>This is a pretty general question about how to compute derivatives of a digital signal $x[n]$.</p> <p>I would like to know what are the different approaches (from naive to complex) and how are they compared to one another? Is it possible with FIR/IIR filters? What are the pro's and contra's. Which are better for real-time applications?</p> https://dsp.stackexchange.com/q/54539 4 What exactly is Savitzky-Golay differentiation filter? user8059 https://dsp.stackexchange.com/users/39764 2019-01-01T10:59:13Z 2019-01-16T14:16:16Z <p>I could understand Savitzky-Golay filter as being smoothing filter, but then there also seems to be Savitzky-Golay differentiation filter, though for some reason, details do not seem to be clear.</p> <p>So is Savitzky-Golay differentiation just about inferring first-order derivative from a local polynomial used for each data point? (This local polynomial least square method is another way of thinking about Savitzky-Golay, so by local polynomial I mean exactly that.)</p> <p>If so, would frequency response of such a differentiation filter be simply multiplying <span class="math-container">$i\omega$</span> to frequency response of an original Savitzky-Golay filter?</p> https://dsp.stackexchange.com/q/24468 4 derivative filter transfer function James Corner https://dsp.stackexchange.com/users/16466 2015-07-01T19:05:07Z 2017-12-15T10:45:17Z <p>In many of the papers it is said that the derivative filter transfer function is given by: $$H(z) = \dfrac{1}{8T}\left(-z^{-2} - 2z^{-1} + 2z + z^{2}\right)$$ But no one gave the detailed information about it. Anyone has an idea about this?</p> https://dsp.stackexchange.com/q/35027 3 Differentiation of sine in Fourier domain CMDoolittle https://dsp.stackexchange.com/users/16238 2016-10-24T17:39:06Z 2016-10-24T18:09:18Z <p>The derivative of $\sin(\omega_o t)$ is $\cos(\omega_o t)$.</p> <p>The Fourier transform of $\sin(\omega_o t)$ is $\frac{\pi}{j}[\delta(\omega-\omega_o) - \delta(\omega+\omega_o)]$.</p> <p>Differentiation in the time domain is equivalent to multiplying the transform by $j\omega$.</p> <p>The transform of $\cos(\omega_o t)$ is $\pi[\delta(\omega-\omega_o) + \delta(\omega+\omega_o)]$.</p> <p>What I don't understand is how multiplying the transform of $\sin(\omega_o t)$ by $j\omega$ gives you the transform of $\cos(\omega_o t)$. I see how the $j$'s will cancel out, but how does the sign of that impulse get flipped?</p> https://dsp.stackexchange.com/q/16540 3 Derivative of noisy signal BaluRaman https://dsp.stackexchange.com/users/6940 2014-05-27T10:33:22Z 2015-10-16T03:45:07Z <p>My input signal is phase vector. I want to differentiate it to get frequency vector. My input signal is somewhat noisy. Here is the input signal. <img src="https://i.stack.imgur.com/5nqBj.png" alt="Input signal"></p> <p>This is the derivative of the input signal as calculated using </p> <pre><code>diff(inputSig) </code></pre> <p><img src="https://i.stack.imgur.com/rsObi.png" alt="Derrivative of input signal"></p> <p>When i differentiate this signal, I am not getting a smooth curve. The output looks 'spikey'. I am guessing it is because of the noise in the input signal (is this 'derivative kick'?). How to avoid this and get a smooth derivative curve?</p> https://dsp.stackexchange.com/q/51248 3 Derivative with respect to complex conjugate Sal https://dsp.stackexchange.com/users/30997 2018-08-15T13:00:40Z 2018-08-21T08:46:48Z <p>I have a real function $C$ of a complex vector $x$. While taking the gradient of the function $C$ for minimising the same, why do we take the derivatives with respect to the complex conjugate of $x$, i.e. $\bar{x}$ and not the actual vector $x$?</p> <p>I have tried looking up for help but I am directed again and again to Cauchy–Riemann equations, which I know is not pertinent here.</p> https://dsp.stackexchange.com/q/28824 3 Is there a difference between filtering a signal before or after differentiating it? Clément F https://dsp.stackexchange.com/users/19527 2016-02-12T10:10:22Z 2016-03-01T20:29:33Z <p>I have a time series and I want to apply:</p> <ul> <li>a differentiation</li> <li>a Butterworth filter</li> </ul> <p>Does the order theoretically (mathematically) make any difference? Does it make any difference in real life when I use numpy?</p> <p>Thanks in advance!</p> https://dsp.stackexchange.com/q/52150 3 Estimating a Signal Given a Noisy Measurement of the Signal and Its Derivative (Denoising) Maverick https://dsp.stackexchange.com/users/15592 2018-09-23T15:53:12Z 2019-04-23T13:43:31Z <p>I have a signal and its derivative simultaneously measured, both including additive noise. The measurement is completed before the analysis, so it can be looked ahead. Now I want to reconstruct a less noisy version of the signal. I'm looking for pointers to algorithms I should look into.</p> <p>Kalman filter seems to be on the right track, but the implementations I see so far are trying to estimate based on previous measurements only, while I probably should use both previous and coming measurements for optimal results at each point.</p> <p>Ideas?</p> https://dsp.stackexchange.com/q/38005 3 How to differentiate the product signal $f(t)\theta(t)$, where $\theta(t)$ is Heaviside's unit step function? symplectomorphic https://dsp.stackexchange.com/users/26888 2017-02-28T22:56:00Z 2017-03-01T09:12:37Z <p>What is the derivative (in the engineer's sense) of the causal function $f(t)\theta(t)$, where $\theta$ is the Heaviside unit step function? </p> <p>I've seen the formula $f'(t)\theta(t)+f(0)\delta(t)$, where $\delta$ is Dirac's delta. This looks like a kind of "product rule": differentiating the product gives $f'\theta+f\theta'$, but $\theta'$ is $\delta$, and $\color{blue}{f(t)\delta(t)=f(0)\delta(t)}$.</p> <p>If this is right, I don't understand the following argument, from the solutions manual to Oppenheim and Wilsky's <em>Signals and Systems</em>. The solutions manual says the derivative of the function $2e^{-3t}\theta(t-1)$ is </p> <p>$$-6e^{-3t}\theta(t-1)+\color{red}{2}\delta(t-1)$$</p> <p>It's the second term I don't understand. Using the "product rule" heuristic, the second term should be $2e^{-3t}\delta(t-1)$, which using the blue formula above gives $\color{red}{2e^{-3}}$ times the delayed delta function, not just twice the delayed delta function.</p> <p>Is the solutions manual wrong?</p> <p>(Cross-posted on <a href="https://math.stackexchange.com/questions/2165666/how-to-differentiate-ft-thetat-the-product-of-a-function-with-the-heavisi">MSE</a>.)</p> https://dsp.stackexchange.com/q/24847 3 Wrong estimation of derivatives with an extended Kalman filter Janis https://dsp.stackexchange.com/users/16742 2015-07-23T17:14:42Z 2016-09-22T17:17:09Z <p>I am trying to implement an extended Kalman filter (EKF) in MATLAB for the estimation of joint trajectories (angular position, angular velocity and angular acceleration) from noisy motion capture measurements using a constant angular jerk process model. This is my process model:</p> <p>$x_{prior}^k = \begin{bmatrix} 1 &amp; \Delta t &amp; \frac{\Delta t^2}{2} &amp; \frac{\Delta t^3}{6} \\ 0 &amp; 1 &amp; \Delta t &amp; \frac{\Delta t^2}{2} \\ 0 &amp; 0 &amp; 1 &amp; \Delta t \\ 0 &amp; 0 &amp; 0 &amp; 1 \end{bmatrix} \cdot x_{postiror}^{k-1}$</p> <p>and process noise covariance:</p> <p>$Q = 2 \cdot \sigma_p^2 \cdot \begin{bmatrix} \frac{\Delta t^7}{252} &amp; \frac{\Delta t^6}{72} &amp; \frac{\Delta t^5}{30} &amp; \frac{\Delta t^4}{24} \\ \frac{\Delta t^6}{72} &amp; \frac{\Delta t^5}{20} &amp; \frac{\Delta t^4}{8} &amp; \frac{\Delta t^3}{6} \\ \frac{\Delta t^5}{30} &amp; \frac{\Delta t^4}{8} &amp; \frac{\Delta t^3}{3} &amp; \frac{\Delta t^2}{2} \\ \frac{\Delta t^4}{24} &amp; \frac{\Delta t^3}{6} &amp; \frac{\Delta t^2}{2} &amp; \Delta t \end{bmatrix}$</p> <p>My estimates for the angular positions look ok, but my estiamtes for the derivatives are quite wrong. Here is a graph from a simple example application with a comparisson between the angular velocity estimated by my implementation (EKF) and a quite noisy central difference (CD).</p> <p><a href="https://i.stack.imgur.com/ZmPAq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZmPAq.png" alt="Difference between filter estimate (EKF) and central difference estimate (CD) of the first derivative."></a></p> <p>Somehow, I cannot improve the estimation of the derivatives by tuning the covariances, initial values or (almost) anything else. So I think there must be something wrong with my implementation. But I cannot find anything, maybe I suffer from tunnel vision...</p> <p>I adopted the EKF equations from the paper by Yu et al. <a href="http://users.ece.cmu.edu/~byronyu/papers/derive_eks.pdf" rel="nofollow noreferrer">2</a>.</p> <pre><code>% Apply extended Kalman filter equations for k = 1:T % Apply time update if k == 1 % Equation (15) in [Yu2004] X_prior(k, :) = f(x0); A = dfdx(x0); W = dfdw(x0); % Equation (12) in [Yu2004] P_prior(:, :, k) = A * P0 * A' + W * Q * W'; else % Equation (15) in [Yu2004] X_prior(k, :) = f(X_posterior((k - 1), :)'); A = dfdx(X_posterior((k - 1), :)'); W = dfdw(X_posterior((k - 1), :)'); % Equation (12) in [Yu2004] P_prior(:, :, k) = A * P_prior(:, :, (k - 1)) * A' + W * Q * W'; end % Apply measurement update H = dhdx(X_prior(k, :)'); V = dhdv(X_prior(k, :)'); % Equation (11) in [Yu2004] using the pseudo inverse to handle % badly scaled matrices K = P_prior(:, :, k) * H' / (V * R * V' + H * P_prior(:, :, k) * H'); % Equation (14) in [Yu2004] X_posterior(k, :) = X_prior(k, :) + (K * (Z(k, :)' - h(X_prior(k, :)')))'; % Equation (10) in [Yu2004] P_posterior(:, :, k) = P_prior(:, :, k) - K * H * P_prior(:, :, k); end </code></pre> <p>There seems to be one difference in the computation of the prior error covariance compared to the equations given in the paper by Welch and Bishop <a href="http://www.cs.unc.edu/~welch/media/pdf/kalman_intro.pdf" rel="nofollow noreferrer">3</a>.</p> <p>Yu et al.:</p> <p>$P_{prior}^k = A \cdot P_{prior}^{k - 1} \cdot A^T + W \cdot Q \cdot W^T$</p> <p>Welch and Bishop:</p> <p>$P_{prior}^k = A \cdot P_{posterior}^{k - 1} \cdot A^T + W \cdot Q \cdot W^T$</p> <p>The equation by Yu et al. produces the wrong derivatives and the equation by Welch and Bishop seems to result in instable estimations.</p> <p>I compiled a simple example application with my implementation <a href="https://www.dropbox.com/s/ehdgtwnay6f248b/EKF.zip?dl=0" rel="nofollow noreferrer">4</a>. It should work out of the box, if you run "TestKalmanFilter.m" in MATLAB and you should see the given graph and a small animation of a double pendulum.</p> <p>Any help is greatly appreciated. Janis</p> https://dsp.stackexchange.com/q/60815 2 Understanding the resulting image matrix when differentiating image caesar https://dsp.stackexchange.com/users/45248 2019-09-20T14:29:04Z 2019-09-20T17:49:48Z <p>Let <span class="math-container">$A$</span> be a image matrix and let <span class="math-container">$P(i,j)$</span> be the gray level of pixel <span class="math-container">$i,j$</span>. Let <span class="math-container">$0$</span> be black and <span class="math-container">$255$</span> be white Assume I want to differentiate this image with respect to the columns <span class="math-container">$(x)$</span> as in I want <span class="math-container">$P(i,j)=P(i,j+1)-P(i,j)$</span> in the new image. </p> <p>I get that I can achieve this with convolution of <span class="math-container">$A$</span> with the filter <span class="math-container">$f = [1 \ -1]$</span> since you flip the filter in the <span class="math-container">$x-$</span>direction (so pixel <span class="math-container">$i,j$</span> would be multiplied by <span class="math-container">$-1$</span> and <span class="math-container">$i,j+1$</span> with <span class="math-container">$1$</span> which gives me what I want. </p> <p>My understanding is that this process is supposed to highlight differences in the <span class="math-container">$x-$</span>direction. </p> <p>Two questions: </p> <ol> <li><p>How does the gray-level scale in the resulting image work? If one pixel had gray level <span class="math-container">$240$</span> and the next pixel had gray level <span class="math-container">$5$</span>, this would result in the new pixel having the gray level <span class="math-container">$-235$</span>, what does that mean in the scale of <span class="math-container">$0$</span> to <span class="math-container">$255$</span>? Does my scale change from <span class="math-container">$0...255$</span> to <span class="math-container">$-255...255$</span>?</p></li> <li><p>Does it matter if I convolve <span class="math-container">$A$</span> with the filter <span class="math-container">$[-1 \ 1]$</span> instead of <span class="math-container">$[1 \ -1]$</span>?. What would be the result? </p></li> </ol> https://dsp.stackexchange.com/q/59334 2 Why is a first/second derivative useful in spectroscopy? Lukeception https://dsp.stackexchange.com/users/44042 2019-07-08T13:04:31Z 2019-07-09T01:39:02Z <p>I'm currently working on Raman spectroscopy and while reading some literature I came across the first and second derivative of a spectrum. It's not clear to me why they are useful to look at since they look very noisy to me.</p> <p>I tried graphing the first and second derivative of a spectrum I attained from liquid whey (see the following pictures, 1. accquired raman spectrum (smoothed), 2. first derivative, 3. second derivative):</p> <p><a href="https://i.stack.imgur.com/r2V4L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r2V4L.png" alt="first derivative"></a> <a href="https://i.stack.imgur.com/QXnYR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QXnYR.png" alt="Smoothed raman spectrum of whey"></a> <a href="https://i.stack.imgur.com/u1wAj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u1wAj.png" alt="second derivative"></a></p> <p>What information can I read from the first/second derivative in this specific example and in general?</p> https://dsp.stackexchange.com/q/57975 2 Correct way of derivating in frequency domain with FFT Harry Svensson https://dsp.stackexchange.com/users/34115 2019-04-27T20:51:48Z 2019-04-27T21:19:47Z <p>I believe I am very close to the answer and only need a small nudge to get to the answer.</p> <p><strong>What I want:</strong><br> I want to take a signal, use FFT to transform it to the frequency domain (FD), multiply it by <span class="math-container">$jw$</span>, and then transform it back to the time domain (TD). </p> <p><strong>Why do I want it:</strong><br> Because it's something that I should be able to solve in my position, I want to know how to do it properly. And because it would be fun to make a <strong>very low-end</strong> spectrum analyzer with an Arduino and instead of sending a pulse I can send a step instead, derive the output to get an impulse response. I know that I also can send square waves and use a Goertzel filter and look for the fundamental sine in the square wave, but... as I said earlier. I want to know how to do this properly. </p> <p><strong>What I've tried:</strong><br> I thought I'd go for the simplest case first, a square wave and a triangle wave. </p> <p>The fourier series for a square wave is: <span class="math-container">$$\text{square_wave}(x) = \sum_{n=0}^\infty\frac{\sin\biggl(x(2n+1)\biggr)}{2n+1}$$</span></p> <p>The fourier series for a triangle wave is:</p> <p><span class="math-container">$$\text{triangle_wave}(x) = \sum_{n=0}^\infty\frac{\sin\biggl(x(2n+1)-\frac{\pi}{2}\biggr)}{(2n+1)^2}$$</span></p> <p>The derivative of a triangle wave is a square wave, from the equation above it's clear that multiplying by <span class="math-container">$jw$</span> phase shifts each sine and amplifies each sine correctly to get rid of one <span class="math-container">$(2n+1)$</span> factor.</p> <p>I know that the derivative of the 0 Hz component is 0, so in the FD I know all values that I need to multiply my signal with, except for the highest frequency component, but I'll set that one to 0 too because I don't know what it should be.</p> <p>I also know that the frequency spectrum is mirrored around the middle for real valued inputs, and that the second half of the spectrum is just the conjugate of the first half. </p> <p>This means that the vector I need to multiply the signal with in the FD for a 32 bin FFT looks something like this in matlab/octave code:</p> <pre><code>derivative = [0,i*1:15,0,-i*15:-1:1] %comments: %0 = 0 %1:15 = 1,2...14,15 %15:-1:1 = 15,14...2,1 derived_signal = ifft(fft(signal).*derivative) </code></pre> <p>My make-a-sense-o-meter says that it makes sense, yet when I multiply my signal with it I get something that is very close to the derivative, but not 100% correct. I get a better result if I multiply by the FFT of <code>[0,-1,zeros(1,29),1]</code> which is a first order derivative approximation. See figures below for octave plots.</p> <p><a href="https://i.stack.imgur.com/ZyMIl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZyMIl.png" alt="enter image description here"></a></p> <p>Here is the code I used in case anyone else wants to mess around:</p> <pre><code>triangle=[linspace(-1,1,16),linspace(1,-1,16)]; subplot(1,2,1) plot(0:31,triangle) xticks([0 7 15 23 31]) axis([-1 32 -1.1 1.1]) title("32 point triangle wave") grid subplot(1,2,2) hold on dt_jw=real(ifft(fft(triangle).*[0,i*(1:15),0,-i*(15:-1:1)])); plot(0:31,dt_jw) dt_convolution=real(ifft(fft(triangle).*fft([0,-1,zeros(1,29),1]))); plot(0:31,dt_convolution) axis([-1 32 -1.1 1.1]) xticks([0 7 15 23 31]) yticks([1 dt_jw(floor(length(dt_jw)/4)) dt_convolution(floor(length(dt_jw)/4)) 0 -1]) title("d/dt(triangle)") legend("fft(tri)*jw","convolution with [-1,0,1]") grid hold off </code></pre> <hr> <p>I feel like I'm very close to the answer and that I'm missing something very obvious.</p> <p>So why does multiplying by <span class="math-container">$jw$</span> not derive my triangle wave into a <strong>nice</strong> square wave? Because so far it makes more sense to convolve my triangle wave by a 1st order derivative approximation.</p> https://dsp.stackexchange.com/q/41344 2 Helmholtz decomposition implementation Victor Pira https://dsp.stackexchange.com/users/18651 2017-05-30T15:47:49Z 2017-06-01T21:34:05Z <p>I need to perform the <a href="http://en.wikipedia.org/wiki/Helmholtz_decomposition" rel="nofollow noreferrer">Helmholtz decomposition</a> of a 2D flow. An old and obvious problem is the numerical differentiation (largely amplifying the noise). </p> <p>I do understand the procedure I am just looking for useful tips and tricks or a literature reference -- surely I am not the first one to perform the task.</p> <p>I am aware that there was a matlab package where the decomposition was implemented. But it worked only for square input matrices.</p> <p><strong>Do you know any algorithm other than straightforward discretization of integrals and derivatives?</strong></p> https://dsp.stackexchange.com/q/47593 1 Why taking derivative amplifies noise huangzonghao https://dsp.stackexchange.com/users/33902 2018-03-05T19:31:27Z 2018-03-06T00:21:14Z <p>In image processing we may use derivatives to help us detect the edges. While at mean time, this operation would also make the data noisier. But why do we have this effect?</p> <p>My intuition is that if we denote the image data as</p> <p>$I_{actual}(x, y) = I_{ideal}(x, y) + I_{noise}(x, y)$.</p> <p>Then apparently when we do $I_{actual}(x_2, y) - I_{actual}(x_1, y)$, the noises will cancel out with each other? But how come they end up adding up to each other?</p> https://dsp.stackexchange.com/q/58432 1 Bilinear Transform (Tustin's Method) applied to the Derivative oliver https://dsp.stackexchange.com/users/41209 2019-05-20T09:50:54Z 2019-05-20T13:15:43Z <p>I hope that I have not misunderstood something terribly wrong, but the continuous derivative <span class="math-container">$D=d/dt$</span> can be considered a transfer function in Laplace space <span class="math-container">$D(s) = s$</span>, right?</p> <p>So when I try to discretize it using the bilinear transform (Tustin's method) I trivially get</p> <p><span class="math-container">$D(z) = \frac{2}{T} \frac{1-z^{-1}}{1+z^{-1}}$</span></p> <p>When I apply this to a series containing one discrete impulse, the response oscillates at the Nyquist frequency. Even worse, the spectrum around <span class="math-container">$\omega=0$</span> is quadratic and not <span class="math-container">$\sim i\omega$</span> like it would be expected from the derivative. (<strong>Edit: the latter was just due to roundoff error, because the low-freq amplitude got swamped by the Nyquist-peak</strong>)</p> <p>Although I know of course how well the bilinear transform works for discretizing all kinds of filters, it is hard for me to understand, why it is considered superior if it seems to fail so miserably for something as simple as the derivative, which can otherwise be easily represented by first order finite differences:</p> <p><span class="math-container">$D(z)=\frac{1-z^{-1}}{T}$</span></p> <p>or even second order (symmetric) finite differences</p> <p><span class="math-container">$D(z)=\frac{1-z^{-2}}{2Tz^{-1}}$</span></p> <p>I am sure it all has a very simple explanation, but I can't see it.</p> <p><strong>PS:</strong> What is all the more confusing: when I apply the bilinear D(z) to a step function, the result is (correctly) a single peak. Consequently the inverse of the bilinear D(z) applied to an impulse yields the step function, like it has to be. What is going on there?</p> https://dsp.stackexchange.com/q/48482 1 should I apply low-pass filter when calculating central derivative? John Smith https://dsp.stackexchange.com/users/15439 2018-04-12T09:05:45Z 2019-01-17T01:11:34Z <p>Let us say that we have a discrete signal $I_n$, $n=0, 1, 2, ...$. According to Nyquist theorem the maximum frequency for such discretization is $f_{max} = 0.5$.</p> <p>Now imagine that I want to calculate the derivative $D_n$ for this signal. The simplest approximation is the right hand side derivative</p> <p>$$D_n = I_{n+1} - I_n$$</p> <p>But what if I want to use a central derivative instead?</p> <p>$$D_n = \frac{1}{2}(I_{n+1} - I_{n-1})$$</p> <p>Just looking at this relation, it seems like I am increasing the sampling time from $1$ to $2$. Does this mean that before calculating central derivative I should apply low-pass filter to kill all the frequencies $f &gt; 0.25$? Or am I being wrong and the simple fact that I am using the spacing = 2 for calculating derivative does not mean that I increase the sampling distance, because I can still calculate this derivative for each value of $n$?</p> <p>No matter what the correct answer is (yes or no), can you please explain in more detail why? If the low-pass filter should be applied, can you explain if there is a method, how given discrete time relation I can infer to what degree I should smoothen the signal before using such relation?</p> https://dsp.stackexchange.com/q/35433 1 Why level of noise can be magnified twice through each numerical differentiation? Remy https://dsp.stackexchange.com/users/24752 2016-11-10T14:50:13Z 2016-11-10T23:07:43Z <p>I was reading a paper and saw this is mentioned there, but I cannot figure out how this can analytically be proven?</p> https://dsp.stackexchange.com/q/36880 1 Different approaches for partial image derivation arash javan https://dsp.stackexchange.com/users/23840 2017-01-12T08:44:28Z 2017-01-15T13:16:57Z <p>I know there are different ways for partial derivation of an image, among others: Sobel kernel, LoG, Prewitt and so on.</p> <p>But the simplest one is the central difference:</p> <p>$$\frac{d}{dx} f(x) \approx \frac{f(x+1) - f(x-1)}{2} \longrightarrow 0.5[1\ 0\ -1]$$</p> <p>Which means convolving the image with above matrix.</p> <p>Assume the image looks like this:</p> <p>$$I(x,y) = \left( \begin{matrix} 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 1 &amp; 1 &amp; 1 &amp; 1 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 1 &amp; 1 &amp; 1 &amp; 1 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 1 &amp; 1 &amp; 1 &amp; 1 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 1 &amp; 1 &amp; 1 &amp; 1 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\ \end{matrix} \right) \in \mathbb R^{8\times8}$$</p> <p>Convolving this image with matrix $$G_x = 0.5\ [1\ 0\ -1] \in \mathbb R^{1 \times 3}$$ results in:</p> <p>$$\lvert I \ast G \rvert = \left( \begin{matrix} 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\ 0 &amp; 0.5 &amp; 0.5 &amp; 0 &amp; 0 &amp; 0.5 &amp; 0.5 &amp; 0 \\ 0 &amp; 0.5 &amp; 0.5 &amp; 0 &amp; 0 &amp; 0.5 &amp; 0.5 &amp; 0 \\ 0 &amp; 0.5 &amp; 0.5 &amp; 0 &amp; 0 &amp; 0.5 &amp; 0.5 &amp; 0 \\ 0 &amp; 0.5 &amp; 0.5 &amp; 0 &amp; 0 &amp; 0.5 &amp; 0.5 &amp; 0 \\ 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\ \end{matrix} \right)$$</p> <p>The cells containing $0.5$ are the edges of the image in $x$ direction. </p> <p>Know assume we would extend our filter $G_x$:</p> <p>$$G_x = 0.5 \left( \begin{matrix} 1 &amp; 0 &amp; -1 \\ 1 &amp; 0 &amp; -1 \\ 1 &amp; 0 &amp; -1 \\ \end{matrix} \right) \in \mathbb R^{3 \times 3}$$</p> <p>Now convolving this filter with our image results to:</p> <p>$$\lvert I \ast G \rvert = \left( \begin{matrix} 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\ 0 &amp; 1 &amp; 1 &amp; 0 &amp; 0 &amp; 1 &amp; 1 &amp; 0 \\ 0 &amp; 2 &amp; 2 &amp; 0 &amp; 0 &amp; 2 &amp; 2 &amp; 0 \\ 0 &amp; 3 &amp; 3 &amp; 0 &amp; 0 &amp; 3 &amp; 3 &amp; 0 \\ 0 &amp; 3 &amp; 3 &amp; 0 &amp; 0 &amp; 3 &amp; 3 &amp; 0 \\ 0 &amp; 1 &amp; 1 &amp; 0 &amp; 0 &amp; 1 &amp; 1 &amp; 0 \\ 0 &amp; 2 &amp; 2 &amp; 0 &amp; 0 &amp; 2 &amp; 2 &amp; 0 \\ 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\ \end{matrix} \right)$$</p> <p>Now instead of one unique number for edge like we had before with $0.5$ we get a gradient in $x$ direction $[1, 1, 2, 2, 3, 3, 2, 2, 1, 1]$. </p> <p><strong>Now my Questions:</strong></p> <p>1) Which approach is better, convolving the image with a $\mathbb R^{1 \times 3}$ -Filter or with a $\mathbb R^{3 \times 3}$-Filter?</p> <p>2) And why is one better than the other?</p> <p>Thanks</p> https://dsp.stackexchange.com/q/35557 1 How do derivative masks work for finding edges in image? user137927 https://dsp.stackexchange.com/users/24164 2016-11-15T10:36:58Z 2016-11-15T11:15:41Z <p>As I know, masks like follow are derivative mask, <a href="https://i.stack.imgur.com/4VCKn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4VCKn.png" alt="enter image description here"></a></p> <p>but I don't get it why they can detect edges and which one of them can find vertical edges and which one can find harizontal edges? </p> https://dsp.stackexchange.com/q/19304 1 Derivative of signal with missing samples matt https://dsp.stackexchange.com/users/11796 2014-11-25T00:47:52Z 2014-11-26T16:18:52Z <p>I have software that tracks an object moving (in the x-dimension only) across a video shot from a stationary camera. I need to find the velocity and acceleration of the object as functions of time. This calculation can be done offline, so there are no real-time constraints. The motion of the object is also pretty regular, decelerating approximately constantly throughout the duration of motion.</p> <p>Normally I would design an FIR differentiator to do the job, however the object in the video becomes occluded for up to a few frames at a time on a regular basis throughout it's motion, so I don't have a point for it for several frames. In other words, my data looks like this:</p> <pre><code>frame_index = [1 2 3 6 7 8 9 13 14 15 16 17 18 21 22 ... ] x_position = [0 0.2 0.39 1.14 1.22 ... ] </code></pre> <p>I've thought about interpolating and then using an FIR differentiator but am unsure what a good scheme for interpolating irregular data like this would be. I've also thought about using a formulation based on Lagrange interpolating polynomials to calculate derivatives directly, but do not know enough about them to understand trade-offs. My goal is accuracy.</p> <p>So, what would be the best way to go about calculating approximations of the first and second derivatives of the data?</p> https://dsp.stackexchange.com/q/60970 0 Frequency response of numerical derivative Roman Vas https://dsp.stackexchange.com/users/39092 2019-09-29T21:40:12Z 2019-10-01T05:52:00Z <p>Analytical derivative of a function is equivalent to convolution of that function with <span class="math-container">$s$</span> in Laplace domain. Numerical derivatives are limited in bandwidth due to finite sampling rate, so they are not synonymous with convolving the signal with with <span class="math-container">$s$</span> term. At higher frequencies one would expect attenuation of the numerically differentiated signal from one that was computed analytically. Recently, I found that there are some differences at the low frequency limit as well which I cannot explain.</p> <p>Attached is a plot of a signal sampled from a normal distribution (blue) and it's first derivative in time (red). As expected, at high frequencies the derivative signal begins to attenuate. But why does it not cross <span class="math-container">$\omega$</span> = 1 rad/s or 0.16 Hz as would be the case if the solution was obtained analytically? <a href="https://i.stack.imgur.com/uWabF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uWabF.png" alt="enter image description here"></a></p> <p>Here's the code I am running in MATLAB</p> <pre> sr = 100000; y = randn(1,sr); dydt = y; for i = 2:length(y)-1 dydt(i) = (y(i+1)-y(i-1))*sr*2; end hold on, plot(abs(fft(y))); plot(abs(fft(dydt))); set(gca, 'YScale', 'log') set(gca, 'XScale', 'log') </pre> https://dsp.stackexchange.com/q/47933 0 MLE parameter estimation -- confusion regarding some terms in the pdf of complex normal r.v (Part 2) Ria George https://dsp.stackexchange.com/users/780 2018-03-18T18:29:44Z 2018-03-20T18:40:55Z <p>This question is based on the application of the pdf which was an earlier question of mine asked here <a href="https://dsp.stackexchange.com/questions/40320/confusion-regarding-pdf-of-circularly-symmetric-complex-gaussian-rv?rq=1">Confusion regarding pdf of circularly symmetric complex gaussian rv</a></p> <p>If $v \sim CN(0,2\sigma^2_v)$ is a circularly complex Gaussian random variable which acts as the measurement noise in this model $$y_n = A + v_n \tag{1}$$ where $y$ is the observation and $A$ is a scalar unknown value which needs to be estimated. I am having a slight confusion whether there will be a 2 in the denominator of Eq(3) and Eq(4) with the $\exp(.)$ term. Based on the answer in the link, there should be no sqrt term with $\pi$ in the denominator, if $v \sim CN(0,2\sigma^2_v)$. If $v \sim N(0,\sigma^2_v)$ then there is a sqrt term. </p> <p>Can somebody please check if I have correctly written out the log-likelihood? I think I am missing a 2 in the denominator of $\exp[.]$ term in Eq(3) but I am not quite sure.</p> <p>Thank you for your time and help.</p> <p>$$P_y(y_1,y_2,...,y_N) = \prod_{n=1}^N\frac{1}{2\pi \sigma^2_v} \exp \bigg(\frac{-{({y_n-A})}^H ({y_n-A})}{2\sigma^2_v} \bigg) \tag{2}$$</p> <p>taking log $$\ell = -N\ln(2\pi\sigma^2_v) - \frac{1}{\sigma^2_v} {\bigg[{[\sum_{n=1}^{N} {(y_n - A)}{(y_n - A)}^{\mathsf{H}} ]}\bigg]}. \tag{3}$$ $$= -N\ln(2\pi\sigma^2_v)- \frac{1}{2 \sigma^2_v}{\bigg[ \sum_{n=1}^{N}y_n y_n^\mathsf{H} - 2 \sum_{n=1}^N y_n A\bigg]} - \frac{1}{2 \sigma^2_v}{\bigg[ \sum_{n=1}^N {AA}^\mathsf{H} ] \bigg]} \tag{4}$$</p> https://dsp.stackexchange.com/q/44007 0 Derivative filter in Python Pouteri https://dsp.stackexchange.com/users/31003 2017-09-28T08:42:12Z 2019-08-13T10:38:03Z <p>In Alaa Kharbouch, Ali Shoeb, John Guttag, Sydney S. Cash, <strong><a href="https://doi.org/10.1016/j.yebeh.2011.08.031" rel="nofollow noreferrer">An algorithm for seizure onset detection using intracranial EEG</a></strong>, <em>Epilepsy &amp; Behavior,</em> Volume 22, Supplement 1, 2011 (section 2.1, 3rd paragraph) about EEG, the authors note that the spectral amplitude profile of a signal is inversely proportional to frequency. To correct for this trend, they propose to apply a <em>derivative filter</em> to the signal. </p> <p>My question is: Is there a Python function which implements such a derivative filter ? Is the <a href="https://docs.scipy.org/doc/scipy-0.16.1/reference/generated/scipy.signal.savgol_filter.html" rel="nofollow noreferrer">savgol_filter</a> function from the Scipy module suited to this task ? If not, how could I design such a filter in Python ?</p> https://dsp.stackexchange.com/q/41109 0 First derivative analog filter woky https://dsp.stackexchange.com/users/28620 2017-05-19T19:34:11Z 2017-05-19T21:30:46Z <p>I'm reading about fault detection via signal processing in time domain. One possibility is to check that first derivative of the signal is in some predefined bounds. The text says that to obtain the first derivative of the output signal $y(t)$, I can use this analog filter: $$F(p)=\frac{p}{\frac{1}{\tau}p+1}$$ for some sufficiently large $\tau$. Why is that? I don't know much about analog filters. I only know that Laplace transform of the first derivative of a function $f(t)$ with zero initial conditions is $pF(p)$. I also understand that $X(p)=\frac{1}{\frac{1}{\tau}p+1}$ is Laplace transform of exponential decay function $e^{-\tau t}$. Could you please explain to me why the filter needs to be designed like that and how does it work physically?</p> <p>Thank you.</p> <p><strong>My wrong reasoning</strong>: If $u(t)$ is the input signal and $y(t)$ is the rate of that signal, then $$y(t) = u(t)'. \\$$ The transfer function would then be \begin{align} Y &amp;= pU \\ F &amp;= \frac{Y}{U} = p. \end{align}</p> https://dsp.stackexchange.com/q/27420 0 Compute the time derivative of a noisy digital signal? Courier https://dsp.stackexchange.com/users/10309 2015-12-01T15:02:43Z 2015-12-08T22:28:06Z <p>The issue is that my signal is very noisy. I need extract its time derivative as accurate as possible. P.S. I do not have any prior knowledge on the signal (black box).</p> <p>On forums some suggested Savitzky-Golay filter. </p> <p>Any idea please? If so, is there any c++ library for the purpose?</p> <p>In fact, for my application I need to compute optical-flow like information for control purpose. I compute an estimate using image information. Then I need to compute the time derivative of this estimate.</p> <p>4th order Savitzky Golay filter introduces delay, yet I need the output in real-time (real time control). For info:</p> <ul> <li>The signal is regularly sampled;</li> <li>The noise is not defined but bounded;</li> <li>The output needs to be real-time: delay-minimal;</li> <li>The signal is black box: I only get a measure each iteration.</li> </ul> <p><a href="https://i.stack.imgur.com/XzCaf.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XzCaf.jpg" alt="enter image description here"></a></p> https://dsp.stackexchange.com/q/30550 0 Derivative of equation containing Gaussian filtered image jakeoung https://dsp.stackexchange.com/users/4367 2016-05-04T04:12:42Z 2016-05-04T17:53:04Z <p>Let $w$ be our image. For example, consider the following with the vectorized $w$: $$E(w) = \frac 12 \|Aw+b\|_2^2$$ I know the optimal condition of the above equation: $$\nabla_wE = A^TA\hat w + b = 0$$</p> <p>Now, we consider the filtered image by Gaussian such that $$E(w) = \frac 12 \|A (G * w)+b\|_2^2$$</p> <p>In this case, how to get the optimal condition? (i.e., how to derivative w.r.t $w$?)</p> https://dsp.stackexchange.com/q/61286 0 Numerical higher order derivatives and time axis M. Farooq https://dsp.stackexchange.com/users/41674 2019-10-16T03:00:26Z 2019-10-16T15:02:43Z <p>I have a rather elementary question. Suppose we wish to study even-derivatives of an instrumental signal say second fourth and sixth derivatives and plot it as a function of time. With each successive differentiation we lose the data points. If the initial number of data points were 1000, the second derivative will have 9998 points, the fourth derivative will have 9996 points and so on. This can be seen with the <em>diff</em> command in Matlab. </p> <p>How should we align these derivatives with the time axis which has 1000 points for plotting purposes? The typical way is to leave the first two points of the time axis for the second derivative and first four points for the fourth derivative. Is there a mathematical justification for this way of alignment since a true derivative is defined at a point rather than this numerical approximation? In some chemistry texts, authors suggest to average the values of the x-axis and plot the derivatives with respect to that. </p> <p>Thanks.</p>