*Bayesian Inference as a Tool to Optimize Spectral Acquisition in Scattering Experiments DOI: http://dx.doi.org/10.5772/intechopen.103850*

posterior distribution of the model parameters vector is thus obtained. Once the corresponding marginal distribution *P k*ð Þ j*y* has been computed, the best-fit model conditional to the first experiment run can be determined. After a second run of data *y*<sup>0</sup> is available, this is added to the previous one and the MCMC algorithm is used on the complete data to obtain a new joint posterior *P* Θj*y*, *y*<sup>0</sup> ð Þ. Parameter estimates from the first run can be used as starting values to speed up convergence. The process repeats itself as new runs become available.

Here below (**Figures 4**–**6**) we show the posterior distribution for some of the model parameters when the data are analyzed considering 5, 10, 20, 40 and finally 60 runs. We emphasize again that at each step we are applying the Bayes theorem, feeding back the posterior we obtained at a previous step as a prior (new knowledge about the data) for the following step. The likelihood is enriching itself more and more as long as we acquire new data. In the present example, the algorithm finds as best model the one with two inelastic modes as it should be desirable since the generation model is the one in Eq. (7). In fact because of the random error added to simulate a *real* experimental dataset, especially if the inelastic modes are chosen to have frequencies close to each other and/or large damping, it is not straightforward to find the number of modes predicted by the model whatever is the amount of data considered.

**Figure 4** clearly demonstrates that the posterior distribution for the inelastic shifts Ω<sup>1</sup> and Ω<sup>2</sup> of the spectrum get sharper upon increasing the number of runs considered in the analysis. The distribution becomes better shaped, peaked, and symmetric providing, of course, a better estimate of the model parameters. Still, if we take the mean of the posterior distribution for Ω<sup>1</sup> (or for Ω2) after 40 runs and we compare it with the one obtained after 60 runs, the difference between these two means is about 1%; when comparing instead the mean after 5 runs with the mean after 60 runs, the difference amounts to less than 3% which very likely is already smaller than experimental uncertainties typically reported in dispersion curves displayed by scientific papers. Similar considerations hold for the other two parameters defining the damped harmonic oscillators, namely the peak amplitudes *A*<sup>1</sup> and *A*<sup>2</sup> and the dampings Γ<sup>1</sup> and Γ<sup>2</sup> (**Figures 5** and **6**) [24].

In **Figures 7** and **8**, the best fit after 5 runs and 60 runs sum spectra is shown along with the estimated DHO components and the central elastic contribution.

In **Figure 9**, we report the posterior distribution function for the number of the detected inelastic modes as a function of the number of runs considered in the

#### **Figure 4.**

*Posterior distribution of the two excitation frequencies as estimated from the Bayesian analysis after 5 (green), 10 (purple), 20 (yellow), 40 (brown), and 60 (blue) experimental runs.*

#### **Figure 5.**

*Posterior distribution of the dampings of the two excitations as estimated from the Bayesian analysis after 5, 10, 20, 40, and 60 experimental runs.*

#### **Figure 6.**

*Posterior distribution of the amplitudes of the two excitations estimated from the Bayesian analysis after 5, 10, 20, 40, and 60 experimental runs.*

analysis. It is evident that as the experimental evidence becomes more precise, the probabilities associated with a higher number of modes progressively vanish.

To conclude we briefly draw the reader's attention on the necessity to assess convergence of the MCMC algorithm before using its output for inferential purposes. In literature, a great deal of effort has been spent in developing convergence diagnostic tools for MCMC. Some of these tools are specifically intended to check convergence of the Markov chain to the stationary distribution, or to check for convergence of summary statistics, such as sample means, to the corresponding theoretical quantities. For a recent review of the subject, see Ref. [25]. Although many convergence criteria and stopping rules with sound theoretical foundation have been proposed, in practice MCMC users often decide convergence by applying empirical diagnostic tools, in particular graphical methods. The most common graphical convergence diagnostic method is the trace plot, which is a time series plot showing the values of the model parameters at each sweep against the sweep numbers. The trace plot enables to visualize the capability of the Markov chain in exploring the parameter space. For example, the presence of flat bits reveals that the MCMC algorithm gets stuck in some part of the parameter space and is a symptom of slow convergence. This *Bayesian Inference as a Tool to Optimize Spectral Acquisition in Scattering Experiments DOI: http://dx.doi.org/10.5772/intechopen.103850*

#### **Figure 7.**

*Simulated spectra (blue dots) at a Q value of 5 nm*<sup>1</sup> *as obtained summing 5 runs drawn by the model in Eq. (7). The best-fit model (red curve) to the drawn data and the estimated DHO components (black and green line) are also shown. The dash dot magenta line is the estimated elastic central component.*

#### **Figure 8.**

*Simulated spectra (blue dots) at a Q value of 5 nm*<sup>1</sup> *as obtained summing 60 runs drawn by the model in Eq. (7). The best-fit model (red curve) to the drawn data and the estimated DHO components (black and green line) are also shown. The dash dot magenta line is the estimated elastic central component.*

happens when too many proposals are rejected consecutively. On the other hand, when proposals are too easily accepted, the algorithm may move slowly not exploring the parameter space in an efficient way. In this case, the trace plots would show visible trends or changes in spread, implying that stationarity has not been reached yet. Often Bayesian statisticians refer to a "hairy caterpillar" when describing trace plots and what they should look like. In **Figure 10**, we report trace plots for the excitation frequencies and for the number of inelastic modes in the spectrum. Another helpful graphical method is the running mean plot, which shows parameters' time-average estimates against the iterations. This line plot should stabilize to a fixed value as iteration increases (**Figure 11**).

#### **Figure 9.**

*Top panel: Posterior distribution function for the number k of inelastic modes detected in the simulated Brillouin spectrum as a function of acquisition time. From top to bottom, the results after 5, 10, 20, 40, and 60 experimental runs. Bottom panel: As in the top panel but at the very top of the figure the posterior of k after only 1 run also is shown. In the insets, two different priors P k*ð Þ *are shown. In the top panel a uniform prior for k is plotted. In the bottom panel, a modified (see text) binomial prior distribution has been chosen for comparison.*

#### **Figure 10.**

*Left panel: Trace plot for the excitation frequencies in the spectrum obtained summing 20 experimental runs. Right panel: Trace plot for the number k of DHOs for the same data.*

*Bayesian Inference as a Tool to Optimize Spectral Acquisition in Scattering Experiments DOI: http://dx.doi.org/10.5772/intechopen.103850*

**Figure 11.**

*Left panel:* Ω1,2 *time-average estimates as a function of algorithm sweep. Right panel: Cumulative occupancy fraction for the most visited models.*
