**2. Neutron and X-ray scattering measurements**

The main outcome of neutron and X-ray scattering measurements is the rate *N*\_ of neutrons or photons scattered at an angle 2Θ with energy changed by an amount ℏ*ω*, and ultimately captured by an array of detectors intercepting a finite solid angle. Aside of instrumental factors such as flux, detector efficiency, or detector sensitive area, the intensities recorded by the detectors depend on the physicochemical properties of the sample *via* its spectrum of density fluctuation, *S Q*ð Þ , *E* [12], which conveys insights on the structure (positions) and the dynamics (movements) of the atoms in the sample.

Obviously, the longer the detector counting, the more accurate the spectral shape determination. In fact, the number of neutron (x-ray) counted within an integration

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

time *t*, *Nt* \_ , obeys to a Poisson distribution, its standard deviation thus being ffiffiffiffi *N* <sup>p</sup> . As the integration time *t* increases, the counting statistics improves as the relative experimental errors (� <sup>1</sup>*<sup>=</sup>* ffiffiffiffi *N* <sup>p</sup> � <sup>1</sup>*<sup>=</sup>* ffiffiffiffiffiffi *Nt* \_ <sup>p</sup> ) decreases. Hence, the chance to detect interesting details of the spectral shape ultimately depends, of course, on the sample properties, but also on the accuracy of the intensity measurement. A difficulty to be faced in typical INS spectral acquisitions is that the measurement might be terminated prematurely, that is, before providing the information sought for. This possibility appears especially penalizing if the counting statistics achieved is not accurate enough, the spectral features not well-defined, or the signal sought for very weak. Conversely, data can also be integrated longer than strictly needed to capture the effect under scrutiny. In this case, further prolonging the counting would not complement the insight of the measurement significantly, and, beyond some time lapse, would not even improve its quality. Even worse, it could jeopardize the ultimate success of the experiment due to the time waste, which could prevent the accomplishment of the full experimental plan.

Without digging into computational details, here we outline a strategy to support experiments with a Bayesian protocol providing useful assistance in the measurement's planning and decision making. This will help investigators to determine when the integration time of a spectral acquisition can be safely stopped, either because all useful information was gathered, or because the predetermined target established for relative uncertainties was reached. For the sake of simplicity, we will focus on an exemplary inelastic neutrons scattering (INS) case, with the implicit assumption that the method can be safely extended to X-rays scattering (IXS), in fact being generally valid for any spectroscopy measurement. We stress that the case we are considering is very likely also the most demanding in terms of computational effort for reasons that will be briefly illustrated later in this chapter.
