This paper discusses an innovative adaptive heterogeneous fusion algorithm based on estimation of the mean square error of all variables used in real time processing. The algorithm is designed for a fusion between derivative and absolute sensors and is explained by the fusion of the 3-axial gyroscope, 3-axial accelerometer and 3-axial magnetometer into attitude and heading estimation. Our algorithm has similar error performance in the steady state but much faster dynamic response compared to the fixed-gain fusion algorithm. In comparison with the extended Kalman filter the proposed algorithm converges faster and takes less computational time. On the other hand, Kalman filter has smaller mean square output error in a steady state but becomes unstable if the estimated state changes too rapidly. Additionally, the noisy fusion deviation can be used in the process of calibration. The paper proposes and explains a real-time calibration method based on machine learning working in the online mode during run-time. This allows compensation of sensor thermal drift right in the sensor's working environment without need of re-calibration in the laboratory.