derivative

Filtering out specific terms

我只是一个虾纸丫 提交于 2019-12-13 03:39:55
问题 I have written a function that uses derivative product rule to find derivative of a term: def find_term_derivative(term): x , y = term new_term = (y*x, y-1) return new_term def find_derivative(function_terms): new_function = [] for term in function_terms: new_term = find_term_derivative(term) new_function.append(new_term) filtered_terms = filter(zero_filter, new_term) find_derivative[(4, 3), (-3, 1)] Ouputs [(12, 2), (-3, 0)] However I want to use the filter function to remove any terms which

“Approximating” the derivative of date points in R

元气小坏坏 提交于 2019-12-12 18:32:57
问题 So I have a time series of MODIS NDVI values (vegetation values from 0-1 for the non-geographic geeks), and I'm trying to approximate the derivative by using a for loop. This is a sample of my data: > m2001 date value valnorm 1 1 0.4834 0.03460912 2 17 0.4844 0.03664495 3 33 0.5006 0.06962541 4 49 0.4796 0.02687296 5 65 0.5128 0.09446254 6 81 0.4915 0.05109935 7 97 0.4664 0.00000000 8 113 0.5345 0.13864007 9 129 0.8771 0.83611564 10 145 0.9529 0.99043160 11 161 0.9250 0.93363192 12 177 0.9450

How to apply a partial derivative Gaussian kernel to an image with OpenCV?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 17:15:22
问题 I'm trying reproduce results from a paper, in which they convolve the image with an horizontal partial derivative of a Gaussian kernel. I haven't found any way to achieve that with OpenCV. Is that possible ? Do I have to get Gaussian filter and then compute the partial derivatives by hand ? 回答1: OpenCV doesn't have built-in function to calculate Gaussian partial derivatives. But you may use cv::getGaussianKernel and cv::filter2D to do so. For example: cv::Mat kernel = cv::getGaussianKernel(3,

BSpline derivativeAt() method does not return correct value

会有一股神秘感。 提交于 2019-12-12 01:38:12
问题 I am having problems with the derivativeAt() method when using the BSpline path because it is not returning the correct values, however the derivativeAt() method works find for the CatmullRomSpline path so this is something specific to SPline. The wiki and API do not mention that the SPline needs to be treated differently from other paths...is there something that I’m missing with SPline, or is this a bug with LibGDX? I made a simple program to show the problem. It draws the control points

Finding first derivative using DFT in Python

走远了吗. 提交于 2019-12-12 01:37:30
问题 I want to find the first derivative of exp(sin(x)) on the interval [0, 2/pi] using a discrete Fourier transform. The basic idea is to first evaluate the DFT of exp(sin(x)) on the given interval, giving you say v_k , followed by computing the inverse DFT of ikv_k giving you the desired answer. In reality, due to the implementations of Fourier transforms in programming languages, you might need to reorder the output somewhere and/or multiply by different factors here and there. I first did it

How to input a polynomial in standard algebraic notation and get its derivative? (Python)

浪子不回头ぞ 提交于 2019-12-11 18:15:19
问题 I don't have a problem computing the derivative..it's just that I don't know to handle an entire polynomial in standard algebraic notation :p 回答1: For computer algebra in Python, sympy is the way to go. Computing the derivative of a polynomial in sympy is straightforward: >>> import sympy as sp >>> x = sp.symbols('x') >>> sp.diff(3*x**4 + 8*x**2 - 3*x + 1) 12*x**3 + 16*x - 3 回答2: The code is not concise, because I want to clearly show each step how it calculates. import re def FirstDerivative

Java estimate a derivative at a point

被刻印的时光 ゝ 提交于 2019-12-11 07:44:29
问题 I am currently writing a calculator application. I am trying to write a derivative estimator into it. The formula below is a simple way to do it. Normally on paper you would use the smallest h possible to get the most accurate estimate. The problem is doubles can't handle adding really small numbers to comparatively huge numbers. Such as 4+1E-200 will just result in 4.0. Even if h was just 1E-16, 4+1E16 will in fact give you the right value but doing math it it is inaccurate because anything

Derivative of Kernel Density

拈花ヽ惹草 提交于 2019-12-10 20:37:29
问题 I am using density {stats} to construct a kernel "gaussian' density of a vector of variables. If I use the following example dataset: x <- rlogis(1475, location=0, scale=1) # x is a vector of values - taken from a rlogis just for the purpose of explanation d<- density(x=x, kernel="gaussian") Is there some way to get the first derivative of this density d at each of the n=1475 points 回答1: The curve of a density estimator is just the sum of all the kernels, in your case a gaussian (divided by

Mathematica clear a function's derivative definition

匆匆过客 提交于 2019-12-10 16:27:29
问题 I defined the derivative of a function in Mathematica without defining the function itself, i.e. I have a function definition that looks like this: y'[x_] := constant * f'[x]. I can't figure out how to clear it out. If I use Clear[y'] or `ClearAll[y'], I get an error message: ClearAll::ssym: y' is not a symbol or a string. Clear[y] and ClearAll[y] do nothing to remove the definition of y' . Any ideas on how I can remove the definition of y' ? 回答1: This should do what you want: y'[x_] =. See

Numerically compute derivative of complex-valued function in MATLAB

核能气质少年 提交于 2019-12-10 16:14:50
问题 I would like to compute the derivative of a complex-valued function (Holomorphic function) numerically in MATLAB. I have computed the function in a grid on the complex plane, and I've tried to compute the derivative using the Cauchy–Riemann relations. Given: u = real(f), v = imag(f), x = real(point), y = imag(point) The derivative should be given by: f' = du/dx + i dv/dx = dv/dy - i du/dy where 'd' is the derivative operator. I've tried the following code: stepx = 0.01; stepy = 0.01; Nx = 2