How to Smooth out a derivative of a function?

eln05

I have a dataset consisting of x and y arrays plotted as f(x)=y When I calculate the derivative f(x), a get a noisy derivative as shown in the attached image. How can I smooth it out using python?!

Noisy derivative

Jawand S.

It seems like they're different ways to smooth out data in general. This post looks like it has a similar question: Gradient in noisy data, python

One of the answer uses the function splev and splerp from scipy to smooth the curve. Here's that response: https://stackoverflow.com/a/19796063/13297560 Here are the lines of code that looks relevant:

from scipy.interpolate import splrep, splev
f = splrep(x, noisy_data, k=5, s=3)
plt.plot(x, splev(x,f), label="fitted")

it seems x is the range of the domain, noisy_data the output (y) and k and s are optional arguments that affect the smooth. Here's the documentation on that: https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.splrep.html

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to create a derivative function?

How to get a numeric derivative function in python?

How to implement a derivative of a symbolic function by a 'symfun' in Matlab?

How can I calculate the analytical derivative of a function?

C++ -- How write a function, that return the derivative of a real valued function, not the value of the derivative

How to smooth a curve as function of distance

Animation out of sync, how to achieve smooth animation?

How to correctly have a smooth preloader fade out

How to write a function in python, given a list of terms and a value x of a derivative, that returns the value of the derivative at that point

uniroot() of derivative D() in variable (or how to write an object as a function)

How to write a (first-order) derivative as a function in R?

How to plot a function and its gradient/derivative using Flux.jl

How to implement the Softmax derivative independently from any loss function?

How to change printed representation of function's derivative in sympy

How to integrate a function of r that contains the first derivative of r in python?

How does the derivative of cost function gives direction of fastest decrease in cost?

How to make monotonic (increasing) smooth spline with smooth.spline() function?

Sympy: Specify derivative for function

Derivative function in swift?

Derivative of a softmax function explanation

Matlab - derivative of a function expression

Computing the nth derivative of a function

Derivative in loss function in Keras

Plot the derivative of a function with PyTorch?

Derivative function python

How to implement a smooth clamp function in python?

Is there a function calculating derivative of digamma function?

How do I find out which version and derivative of Ubuntu is right for my hardware in terms of minimal system requirements?

How do I smooth out a 3D transform rotation?