Need help smoothening the red graph below to something that looks like blue graph.
I have tried moving average, problem with that is, it didn't remove the noise, further shifts the position of the curve. I would like to maintain the same position and area under the curve (here it is 100%). Is fitting multiple small curves the solution here? or is a way to fit a curve to this in python or excel?
You have several options available. For instance, you could either use a Gaussian or a Savitzky-Golay filter.
Considering a noisy signal (1D numpy array), like this one:
the following snippet allows you to denoise it. Change the parameters according to your particular use case:
from scipy.ndimage import gaussian_filter1d
from scipy.signal import savgol_filter
np.random.seed(42)
x = np.linspace(0.0, 100.0, 300)
y = f(x) # your signal
y_gaussian = gaussian_filter1d(y, 3)
y_savgol = savgol_filter(y, 8, 2)
plt.plot(x, y, label="Noisy Signal")
plt.plot(x, y_gaussian, label="Gaussian Filter")
plt.plot(x, y_savgol, label="Savgol Filter")
plt.legend()
plt.show()