# Bayesian model comparison for randomly sampled sets of models

I have two models $M_1$ and $M_2$ that I am using to try and compare to observed data $D$. $M_1$ is an $n_1$-dimensional model, and $M_2$ is an $n_2$-dimensional problem. The Bayes factor $K$ to compare the models can be calculated using:

$K = P(D|M_1)/P(D|M_2)$

assuming no prior preference for either model. The numerator and denominator can be written as

$P(D|M_i) = \int P(D|\mathbf{w},M_i) P(\textbf{w}|M_i) d\mathbf{w}$

where $\mathbf{w}$ is the parameter vector, so the integral is over parameter space.

Now say that due to e.g. computational constraints, one can only compute $M_1$ and $M_2$ for a finite number of random samples of the parameter vector $\mathbf{w}$, where the number of samples is given by $s_1$ and $s_2$. Would it be acceptable to then say that the integral above becomes a summation over the random samples, and assuming the random samples are uniformly distributed through parameter space, $P(\textbf{w}|M_i)$ becomes $1/s_i$, so that:

$P(D|M_i) = \sum_{j=1}^{s_i} P(D|\mathbf{w_j},M_i) / s_i$

and so what is being compared in the Bayes factor $K$ is the ratio of the average probability over all the samples for each model?

If the model is determined by the parameters, than $P(D|M_i)=\int P(D|w,M_i)P(M_i|w)*P(w)dw$ should be more appropriate. Since I guess the model is determined by the parameters in a deterministic (instead of stochastic) way, the formula can be abbreviated to $P(D|M_i)=\int P(D|w,M_i)*P(w)dw$.
Model evidence $P(D|M_i)$ can be viewed as an expectation of $P(D|w, M_i)$ with respect to distribution $P(w|M_i)$. You can then use Monte-Carlo methods to estimate it with required precision.