Need suggestion for using highly precise IMUs or Inclinometers to measure Angles dynamically

my system is dynamic I can't make it static, ain't making that dynamic movement more smooth help me a bit

I am taking average of several readings before calculating the tilt angle currently

float getAngleY_mean(int n)
{
  float sum = 0;
  for (int i = 0; i < n; i++)
  {
    mpu.update();
    sum += mpu.getAngleY();
  }
  return sum / n;
}