# What is the best way to determine the process noise matrix $\mathbf Q$ of a Kalman filter?

It seems like most of the resources online suggest to determine the values of the process noise matrix $\mathbf Q$ through trial and error. However sometimes trial and error doesn't work, so I would like to know whether there is a way to approximate it e.g. via maths or whatever.

To clarify, I am talking about the matrix $\mathbf Q$ which can be found in the following formula:

$$\mathbf M_k = \mathbf \Phi_k + \mathbf P_{k-1} \mathbf\Phi^T_{k} + \mathbf Q_k$$ Where $\mathbf M_k$ represents the covariance matrix (before an update in this case). I know that $$\mathbf Q = E\left[\mathbf w \mathbf w^T\right]$$

where $\mathbf w$ is a white-noise process. Which is part of this classical formula:

$$\dot{\mathbf x} = F\mathbf x + G\mathbf u +\mathbf w$$

But I don't know how to determine $\mathbf w$ neither... To the people who are familiar with this very nice book (Fundamentals of Kalman Filtering, Zarchan et al.) you can find the former equation on page 131 and the second one on page 129.