I have looked through all other posts I can find on using the MPU6050 with the filter on yet most code is outdated. I was looking for the current accepted solution. When I tap even the other side of the table my mpu6050 is sitting on, I get high frequency sudden readings on my sensor. I was told to use a low pass filter.
The company that designed the MPU6050 stopped making it years ago. What you can buy today are counterfeits, rejects and clones. Some work, some don't at all.
No, that is why I included the normal math in the comment line above it. You can also use different coefficients, e.g.
sum = (oldVal * 7 + newVal) / 8;
The general pattern is (oldVal * (n-1) ) + newVal / n
I chose an 'n' that is power of 2, so that the shifts would be possible. But with floating point, you don't need that.
I'm only assuming your data is float, if you can obtain raw integer data from the sensor, it is better to filter that because then you can use the faster integer math with shifts.
Notice that the integer version is unsigned. You can't safely shift a signed integer, to perform fast multiplication or division.
The usual advice is to use a Kalman filter. It's more complicated, but you can find a Kalman library too. My post is a "quick and dirty get the job done" but I've tested and used it in real applications.