{'fraction_non_alphanumeric': 0.02826107853503797, 'fraction_numerical': 0.006152071517831394, 'mean_word_length': 4.914724275156339, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Using Bayesian Analysis and Gaussian Processes to Infer Electron Temperature and Density Profiles on the MAST Experiment

A unified, Bayesian inference of midplane electron temperature and density profiles using both Thompson scattering (TS) and interferometric data is presented. Beyond the Bayesian nature of the analysis, novel features of the inference are the use of a Gaussian process prior to infer a mollification length-scale of inferred profiles and the use of Gauss-Laguerre quadratures to directly calculate the depolarisation term associated with the TS forward model. Results are presented from an application of the method to data from the high resolution TS system on the Mega-Ampere Spherical Tokamak, along with a comparison to profiles coming from the standard analysis carried out on that system.


I. INTRODUCTION
The incoherent Thomson scattering (TS) of laser light off of electrons is the foundation for standard diagnostics used to measure electron temperature temperature and density in fusion devices. 1 Recently, the MAST Thomson scattering (TS) system was upgraded to measuring 130 points across the midplane at a frequency of up to 240Hz. 2 In this work, Bayesian methods are used to infer both T e and n e profiles using both TS and interferometric data coming from diagnostics on the Mega-Ampere Spherical Tokamak (MAST). The primary advantage of this analysis is that an absolute calibration of the time-integrated TS laser pulse energy is not required to infer either the thermal electron temperature nor density profiles.
A stochastic model, based on Gaussian processes (GPs) 3 , is used to model the correlation between TS observation points. The noise, signal-variance and length-scale associated with this model are inferred as nuisance parameters in addition to the T e and n e profiles.
This provides a strong benefit of the presented approach, in that signal noise is strongly decoupled from the inferred profiles; and thus, helps to mitigate the probability of previous errors [4][5][6] , where signal noise was given a physical interpretation, from reoccurring. Moreover, the standard perturbative methods for approximating the depolarisation term in the TS forward model, (c.f. Naito,et. al. 7 ) are bypassed in this analysis, in favour of a more direct and flexible numerical integration calculation using Gauss-Laguerre quadratures. Caching of depolarisation calculations is employed to negate the higher computational cost of this approach.
The paper is structured as follows. Section §II gives a brief overview of Bayesian inference using diagnostic data and the application of GPs to model the correlation between observation points. Next, the TS and interferometric forward models used are presented with a description of the depolarisation computation. Section IV present profiles inferred for a high-performance MAST discharge along with a comparison to profiles calculated from the MAST standard analysis. Finally, conclusions and possible extensions are discussed.

II. OVERVIEW OF BAYESIAN INFERENCE
The objective of any inference scheme is to statistically infer a vector of model parameters, denoted λ, given a vector of diagnostic data and associated uncertainties, µ and σ respectively. In the Bayesian perspective, inference centres around Bayes' formula: where I denotes background assumptions. To keep notation uncluttered, I is dropped for the rest of the paper, with background assumptions being explicitly indicated where appropriate.
The parts of Eq. (1) and their application/interpretation in the context of diagnostic data are well documented in the literature 8-11 and will not be discussed in detail here.
TS and interferometer uncertainties are assumed to be pairwise uncorrelated, with each observation having an associated likelihood of the assumed form where N (µ, σ 2 ) is a Gaussian distribution of mean µ and σ 2 the variance; F(λ) is the forward model associated with the given diagnostic. Justifications for this form of the likelihood are given elsewhere 8,10 .
A GP is employed to define the covariance matrix reflecting a spatial correlation between TS observation points: where R i and R j represent the radial coordinate of the ith and jth TS observation point along the midplane; and the k index indicates correspondence to electron temperature or density measurements, with a value of 0 or 1 respectively. In Eq. (3) ζ k , τ k and η k are commonly referred to as hyper-parameters 3 : non-physical quantities which help characterise the prior and/or likelihood in the overall inference. In this analysis, these are scalar quantities uniquely associated with each profile: τ k reflects the average radial length-scale over which the profile is changing; σ k is the signal variance, which serves to decouple the average profile gradient from the length-scale; and η k is the average scalar noise on the profile. With the expression in Eq. (3), the prior for the inference is proportional to

III. FORWARD MODEL
In the MAST TS system, Thomson scattered light from each observation point is spectrally divided into four bands via a polychrometer. Each filtered band is then focused onto an avalanche photodiode (APD), translating the integrated intensity over the spectral band into a voltage signal. When integrated over the TS laser pulse length, a quantity is produced which is sensitive to both the thermal electron temperature and density at the associated observation point: where C S encompasses a collection of known, fixed system constants; E L is the integrated laser energy; φ(λ) is the polychrometer response functions; λ L is the TS laser wavelength; λ s is the wavelength of the scattered photons; θ is the scattering angle; and S(λ s , λ L , θ, T e ) the standard Selden expression. 2,13 The Selden relation relates the intensity of scattered light off of thermal electrons to T e and is standard in the literature; but the relation is recalled here for completeness (note the variable transformations in Eqs. (9-10)): q( , θ, 2α) = 1 + 2x x := 1 + where q( , θ, 2α) represents the relativistic depolarisation correction term. 2,7,13 For TS systems, the expressions presented by Naito,et. al. 7 are normally used to approximate q( , θ, 2α). In this work, however, Gauss-Laguerre quadratures are utilised to provide a more direct and flexible calculation of the depolarisation correction. The fundamental difference in this approach is that it is a non-perturbative calculation, which contrasts the approximations of Naito, et. al. 7 that are based Taylor expansions. Indeed, changing vari- which can be integrated directly using a Gauss-Laguerre quadrature 14 . The initial computational cost of the quadrature construction is offset by the fact that the integrals in Eq. (11) are computed via pre-calculated quadrature poles and weights. Gauss-Laguerre quadratures are very accurate/efficient for calculating integrals of the form seen in Eq. (11) and allow for arbitrary levels of accuracy to be specified by simply changing the number of quadrature points. 14 The primary issue with a forward model based on Eq. (5) is that it requires an absolute calibration of E L , in addition to the calibrations reflected in the value of C S . Fortunately, MAST has a midplane CO 2 interferometer that provides a line-integrated measurement of n e in the midplane. Using this data, a simple coordinate transformation is employed to construct the integrated electron density along the TS laser's line of sight (also in the midplane).
As E L is the same for all TS observation points, it can be inferred as a nuisance parameter (i.e. an unphysical parameter which is integrated out in the inference of physical model parameters) that can also absorb any error in C S , with n e still being well-constrained by both TS and the line-integrated interferometeric observation. This serves to greatly reduce the errors seen on the inferred profiles, even when E L is given a physically unconstraining uniform prior, as in this analysis (see §IV).

IV. RESULTS
To demonstrate the analysis detailed above, an inference and subsequent comparison is  The presence of global constraints and over-constraining local observations make the inference very robust against APD errors, mis-calibrations or signal loss. In contrast, the MAST analysis uncertainty reflects a maximum entropy result (i.e. with minimal prior assumptions relative to the forward model used) and is expected to have higher uncertainties than results utilising the prior in Eq. (4) (or any analogy thereof).
As mentioned in §II, this inference yields mollified profiles, along with the associated adjust the prior on any of the hyper-parameters in the inference to reflect a priori knowledge of the length-scales or random noise seen in the system; this can even be taken to the point where these hyper-parameters are even fixed at particular values. Of course, such priors will effect the structure of the inferred profiles; e.g. fixing a relatively small length-scale and scalar noise will yield profiles which have a structure closer to those produced by the MAST analysis. Exploration of physics using these more informed priors on the hyper-parameters is a current research endeavour.
Nuisance Parameter (Unit) Sampling Expectation w/ 95% confidence interval  Finally, as the inference outlined in this paper is non-analytic in nature, having approximately 270 model parameters for a given discharge, it is slower than the standard analysis.
Indeed, to calculate statistical moments of the profiles using NS takes approximately thirty minutes per inference (on average), on a 2.2GHz processor with 8GB of memory. It is a current research focus to speed up this inference by developing a parallelised version of sampling algorithm.

V. CONCLUSIONS
A new method for the unified Bayesian inference of thermal electron temperature and density profiles has been demonstrated, which is also able to infer length-scales and scalar noise parameters intrinsically contained within the diagnostic data. By employing GPs, the average length-scale, signal variance and noise variance are inferred as nuisance parameters, which directly yield profiles where noise is minimised. Finally, a new approach to calculating the depolarisation correction in the TS forward model is presented, which is simple to implement and affords easy adjustment of calculation accuracy.