distinguish linear motion from rotation

Hello guys, recently i managed to filter most of the noise out of the mpu6050 data for roll and pitch
However when i move the sensor in a linear way back and forth it produces some unwanted angles like i was rotating it.

Do you know some algorithm or theory that it can help me solve this problem?

thanks

Sorry, I can't help much, but have to wonder how it is possible to move linearly without any vibration?

Paul

If you post the code you are currently using and links to where you found the libraries, we can help.

Do not double post.