## 1. Introduction

In low and midlatitudes, the vertical density (temperature) structure usually consists of a surface mixed layer, a sharp gradient region (the pycnocline or thermocline), and then a weaker gradient region below where the change in density increases (temperature decreases) at an exponentially lower rate (Sprintall and Cronin 2010). An exception to this general picture are so-called fossil layers that form double pycnoclines, usually found in subtropical regions (Sprintall and Roemmich 1999). The pycnocline region is the most dynamically and ecologically significant aspect of the ocean stratification because the strong gradients suppress turbulent transport of tracers, yet there is still considerable debate around how to objectively quantify its main properties, such as the depth and strength (Fiedler 2010). Fiedler (2010) provides an overview of several historical strategies for determining upper-ocean thermal structure, including fitting a series of discontinuous linear segments.

Continuous analytical functions are an effective means of capturing the vertical density, or temperature, structure because they allow properties such as pycnocline depth (depth of maximum gradient) and strength (maximum gradient) to be calculated objectively (e.g., Chu et al. 1997; González-Pola et al. 2007; Zhou et al. 2017). González-Pola et al. (2007) propose the product of a Gaussian and an exponential to represent the temperature structure below the surface mixed layer, whereas Zhou et al. (2017) use a series of Gaussian curves. González-Pola et al. (2007) cites the physical basis for their function: it approximately resembles a complementary error function, a solution to a one-dimensional heat diffusion equation under appropriate boundary conditions. An exponential profile is often used to represent the density structure in the deeper ocean, although it does not capture the pycnocline variability (e.g., Llewellyn Smith and Young 2003). More recently, Rayson et al. (2019) use a double hyperbolic tangent (DHT) function to reconstruct the full vertical structure of

The above works produce valid databased estimates of density profiles but offer no mathematically coherent mechanisms to quantify the degree of belief or uncertainty that accompanies any such synthesis of hypothetical model and data. Probability is perhaps the most acknowledged calculus for uncertainty quantification and scientific inference (Singpurwalla 2006; Hennig et al. 2015), but concepts, such as confidence intervals and standard errors, of traditional frequentist statistics do not supply a probabilistic description of parameter uncertainty (Jaynes and Kempthorne 1976). This work demonstrates how to formally account for uncertainty by uniting the DHT of Rayson et al. (2019) with a probabilistic framework that is suited to the structure of data analyzed herein. Before introducing how this is accomplished, we discuss why this is important in the context of density profile estimation and, importantly, the implied consequences for ocean dynamical process models (i.e., nonlinear functions of density) that are analyzed in more detail later.

First, our knowledge of a true, full-water-column, continuous ocean background profile density will always be uncertain. Estimates are typically derived through an equation of state using temperature–conductivity measurements informed either from moored instruments at a finite number of depths, often without measurements near the surface or bottom boundaries, or from repeated vertical profiles with continuously sampling instruments that seldom resolve down to the seabed (Nash et al. 2005). Natural variability also contributes to noisy fluctuations at various time scales because of seasonal processes (e.g., mean ocean currents, monsoons), weekly processes (e.g., mesoscale eddies), and hourly processes (e.g., internal gravity waves). For internal gravity wave propagation, we are interested in

*H*is the total water depth (Gill 1982). Since computation of

*c*. Any uncertainty associated with the initial value of

*ϕ*.

*a*

_{0}and

*ω*are the initial wave amplitude and frequency, respectively. Equation (5) suggests that nonlinear waves may occur if

*c*and inversely proportional to

*α*, both of which are nonlinear functions of

This article quantifies uncertainty using probability theory and performs statistical inference via Bayes’s law. Bayes’s law is a framework that, in receipt of new information such as data, coherently updates a *prior* distribution over unknown quantities (e.g., summarizing prior scientific knowledge) to their *posterior* distribution (Jeffreys 1998). The posterior distribution then supplies direct probabilistic inference and uncertainty quantification, conditional on the data. When the process of interest is complex, Bayesian hierarchical models (BHMs) can be used to decompose the problem into a series of conditionally independent components, the product of which yields the model’s joint distribution. Compartmentalizing the model both eases the burden of specifying dependencies in high-dimensional distributions and is a flexible way to meld multiple sources of information. BHMs are well suited to multivariate data that are repeatedly measured (e.g., spatiotemporal data), where local processes within a measurement benefit from the sharing of global information supplied by repetition (Gelman et al. 2013; Betancourt and Girolami 2015).

Previous applications of BHMs to oceanography can be found in a number of papers: Berliner et al. (2000) use BHMs to produce long-lead sea surface temperature predictions, Furrer et al. (2007) combine observations and future climate projections within a BHM to predict atmosphere–ocean circulation processes, Milliff et al. (2011) develop a regional ocean forecast system for surface vector wind fields, and Aldrin et al. (2012) assess climate sensitivity using hemispheric temperatures and global ocean heat content data. By embedding prior knowledge of ocean dynamics within a probabilistic framework, such work resides at the interface of statistical and oceanographic research with analytically unavailable posterior distributions, often due to high-dimensional and strongly dependent parameter spaces, that are estimated using carefully constructed Markov chain Monte Carlo (MCMC) sampling algorithms (Metropolis et al. 1953; Hastings 1970). For a more comprehensive review of BHMs applied to oceanographic processes, their challenges, and estimation strategies, see Wikle et al. (2013).

The dataset we consider here contains multivariate density profile measurements over depth in the upper ocean. Repeatedly collected at regular time intervals over a year, each profile measurement is regressed on depth at the first level of the BHM, using DHT functions as the expected values. While each DHT function has its own parameterization, the second level specifies that these parameters a priori share a common probability generating mechanism. This permits not only the borrowing of global (or annual) information to reduce local (or time specific) parameter uncertainty but also incorporates the evolution of the parameters, and hence

Although the BHM is easily interpretable and models the evolution of profile density measurements well, the statistical nonlinearity of the DHT and the complex spatiotemporal dependencies contained in its joint distribution induce a posterior distribution sufficiently complicated to appeal to more sophisticated and efficient MCMC algorithms. We use Hamiltonian Monte Carlo (HMC), an algorithm that exploits geometric knowledge about the posterior surface (Betancourt 2017). The model is implemented in the open-source software Stan (Carpenter et al. 2017). Diagnostic plots to verify the MCMC algorithm, as produced by Stan, are presented in the article. Data, code, and additional documentation are publicly available online (https://github.com/hhau/density-profile-examples). The R package used to fit the density profile model is available separately (https://github.com/hhau/ddcurves2). Quantification of uncertainty is presented via the following estimated quantities: full posterior distributions of DHT parameters at selected time points and posterior intervals for their corresponding density profiles and the annual evolution of posterior intervals of density profile characteristics, isopycnal heights, and the nonlinear functions for the ocean dynamical processes *N*(*z*)^{2}, *ϕ*(*z*), *c*, *α*, and *L*_{s}.

The paper is structured as follows. Section 2 gives a brief introduction to Bayesian inference and MCMC algorithms, which is intended for the nonspecialist statistician. Section 3 describes the DHT function in the context of marginal seas, and section 4 describes the shelf mooring dataset used as an example in this paper. Section 5 contains details of the BHM, while section 6 presents the results. Section 7 concludes the article.

## 2. Bayesian inference and estimation via MCMC

### a. The Bayesian paradigm

*likelihood function*

**y**, conditioned on the model parameters contained in

**is considered unknown but fixed. The uncertainty associated with any estimator of**

*θ***(e.g., maximum likelihood) is quantified by the estimator’s probability distribution over notional repeated samples, but does not provide direct probabilistic inference for a given observed sample. Under the Bayesian paradigm, where probability is a quantitative representation of belief or uncertainty, our initial knowledge about**

*θ***is encoded in a**

*θ**prior*distribution

*posterior*distribution,

Some researchers find it difficult to articulate conclusions drawn from frequentist methods, for example, the interpretation of a confidence interval that hinges on hypothetical repeated samples (Jaynes and Kempthorne 1976). In contrast, Bayesian inference is appealing because Eq. (6) supplies direct probabilistic statements about model parameter uncertainty, conditioned on the particular dataset observed. For example, estimates of

### b. Posterior estimation

**,**

*θ****, for the**

*θ**t*th realization from a suitable proposal density,

*effective sample size*can be computed as

*n*is the number of MCMC samples used for estimation and

*k*. These diagnostics for our analysis are presented in section 6. For an introduction and more details about MCMC and its validation diagnostics, we direct the interested reader to Robert and Casella (2013) and Brooks et al. (2011).

The complexity of modern day applied Bayesian analyses requires input from both domain specialists and statisticians. One outcome of these collaborations is statistical research into the construction of efficient MCMC proposal densities due to parameter spaces that are high-dimensional and/or exhibit strong posterior dependencies [see Girolami and Calderhead (2011) and discussions]. In these situations, standard MCMC algorithms, such as random-walk Metropolis–Hastings (Hastings 1970) or Gibbs sampling (Gelfand and Smith 1990), can result in excessive warm-up periods and unacceptably strong autocorrelations. HMC, a recent variant of MCMC, is specifically designed to deal with such issues. HMC proposal densities harness first-order gradient information about the posterior surface to identify regions of sampling exploration and ensure high acceptance rates. While the theoretical foundations of HMC, and how it circumvents the above issues, are beyond the scope of the present article, we direct the interested reader to the textbook chapter of Neal (2011), a conceptual introduction by Betancourt (2017), and a short overview aimed at applied scientists in Monnahan et al. (2017).

### c. Overview of Bayesian hierarchical models

*θ*_{1},

**y**is independent of

*θ*_{2}. Equation (9) is a succinct summary of the full BHM proposed in this paper: stage 1 describes the data, conditional on the parameters that govern the ocean pycnocline model parameters, stage 2 provides the mechanism to allow the pycnocline model parameters to vary temporally, and stage 3 specifies priors on the remaining parameters contained in

*θ*_{1}.

Fortunately, the appeal of BHMs has led to the development of many software packages (also known as probabilistic programming languages) to facilitate MCMC implementation for the scientific community. While users must understand the basics of Bayesian modeling and MCMC output, these software packages provide straightforward model specification, data synthesis, and output retrieval. This article uses Stan (Carpenter et al. 2017) and its interface to R (R Core Team 2018), RStan (Stan Development Team 2018). The HMC algorithm inside Stan (Hoffman and Gelman 2014) is also adaptive, so hand tuning of the proposal density by the practitioner is minimal, and it readily provides the MCMC diagnostics suggested above. However, we note that Stan does have one drawback that more traditional MCMC algorithms and accompanying software do not: the inability to estimate models with discrete (or noncontinuous) parameters because of its need to compute gradients (Gelman et al. 2015).

## 3. A parametric ocean pycnocline model

Ocean water density

A parametric model for the density profile is needed to reduce the dimensionality from a finite number of discrete points to a few parameters that can provide inference. Such a model should have the following properties. First, it must appropriately fit observed data in the presence of either one or two distinct pycnoclines, the most dynamically significant aspect of the ocean stratification. Second, the function must allow for sensible extrapolation both above the shallowest observation to the ocean surface and beyond the deepest observation to the ocean floor. Such behavior is not an immediate attribute of parametric forms such as polynomials nor nonparametric methods such as splines or Gaussian processes. Third, the function should be monotonic to maintain gravitational stability.

^{−3}) is approximately the mean density over the profile, while

^{−3}) is a scale for the density difference over the water column. The additive factors

## 4. Mooring data

We demonstrate the suitability of embedding the parametric form in Eq. (11) within a BHM using temperature data collected from a through-the-water-column mooring deployed in 250-m-deep shelf region on the Australian North West Shelf (13.7589°S, 123.3462°E,) for 12 months (April 2016–May 2018). The mooring was serviced in early November 2016 to download data and remove biofouling, resulting in two 6-month data blocks separated by a 2-day gap. The mooring consisted of 11 thermistors (Starmon mini temperature loggers) spaced at 20–30-m-depth intervals and sampling every 60 s. The uppermost instrument was nominally located 10 m below the free surface, although knockdown due to drag caused this depth to vary. A pressure sensor on the upper float measured knockdown, allowing us to map temperature onto a moving vertical coordinate. Temperature data were converted to density by assuming constant salinity (34.6 psu) and a nonlinear equation of state (Feistel 2008). Raw or measured density

Background density for the 12-month record was linearly interpolated from the discrete observation depths to produce a time series of isopycnals heights (Fig. 2). The density field in the region evolved over an annual time scale with smaller, weekly time-scale fluctuations. A cool mixed layer down to approximately 70-m depth occurred during the *austral* winter (August 2016) with a sharp pycnocline between 70 and 200 m. Lighter, more buoyant water appeared in the upper 50 m during the summer months because of warming and the pycnocline also broadened. A secondary pycnocline occurred intermittently throughout the 12-month period. However, this view (Fig. 2) of the data does not contain any information about the uncertainty of the isopycnal heights or about general features like the pycnocline width. In section 6, we show how our BHM produces not only point estimates of the isopycnal heights, as reported in Fig. 2, but also their credible intervals.

Background density temporal evolution derived from the mooring data. Nominal measurement heights are indicated by black diamonds. Contours (isopycnals) are spaced at 0.5 kg m^{−3} intervals and computed via linear interpolation.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

Background density temporal evolution derived from the mooring data. Nominal measurement heights are indicated by black diamonds. Contours (isopycnals) are spaced at 0.5 kg m^{−3} intervals and computed via linear interpolation.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

Background density temporal evolution derived from the mooring data. Nominal measurement heights are indicated by black diamonds. Contours (isopycnals) are spaced at 0.5 kg m^{−3} intervals and computed via linear interpolation.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

## 5. The Bayesian hierarchical model

As in section 4, we have a mooring at a fixed latitude/longitude with a one-dimensional spatial component over depth and repeated measures over time. The first level of the hierarchy describes each time-specific observed density vector (over depth) as a DHT function with normal errors. The second stage allows the parameters of the DHT to vary from profile to profile according to a multivariate normal distribution. The third stage completes the BHM by specifying prior distributions for the remaining parameters and also utilizes scientific knowledge about the characteristics of vertical density profiles.

### a. Data

*t*and depth

*d*. For the data in this article, observations correspond to

*T*= 1473 time periods and

*D*= 11 discrete depths. Write

*t*, our BHM specifies

_{D}is the

*D*×

*D*identity matrix, and the errors contained in the

*D*× 1 vector

### b. Density model parameters

*N*

_{+}indicates a normal distribution constrained to be positive and hence ensures the density profiles at each time point are monotonic. Equation (14) implies the existence of some common density profile parameterized by

*t*is a deviation from this mean. This level of the BHM structure allow us to share information across time points, permits global inference about

Directed acyclic graph of the hierarchical model. Circular nodes are (hyper)parameters of the model, for which we specify prior distributions. The elliptical node is the structural node that enforces the common prior for each

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

Directed acyclic graph of the hierarchical model. Circular nodes are (hyper)parameters of the model, for which we specify prior distributions. The elliptical node is the structural node that enforces the common prior for each

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

Directed acyclic graph of the hierarchical model. Circular nodes are (hyper)parameters of the model, for which we specify prior distributions. The elliptical node is the structural node that enforces the common prior for each

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

### c. Final level priors

^{3}. Thus, our prior for

On the other hand, prior specification of standard deviation parameters is more difficult to elicit. Furthermore, if the number of repetitions within the data is small or the standard deviations approach close to zero, uninformative priors, despite their intention, can exert a significant influence on the posterior (Gelman 2006). Our dataset contains substantial repetitions (*T* = 1473), and we specify weakly informative priors similar in spirit to those recommended by Gelman et al. (2013). In particular, we set

## 6. Results

We first present some diagnostics of the MCMC output produced by Stan. Since the BHM has 8851 unknown parameters, we restrict this discussion only to

Trace plots of

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

Trace plots of

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

Trace plots of

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

ACF plots of

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

ACF plots of

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

ACF plots of

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

In describing the BHM results and the effect of uncertainty quantification on ocean dynamics, we first demonstrate the appropriateness of the BHM described in section 5 by comparing

### a. Background density profile and characteristics

Three example time periods, shown in Fig. 6, demonstrate the performance of the BHM for density profiles that exhibited diverse stratification conditions: a double pycnocline on 7 May 2016 (*t* = 27), a single pycnocline on 26 August 2016 (*t* = 469), and a broader single pycnocline on 9 October 2016 (*t* = 647). Figure 6 shows that the expected values fit the data well, providing sensible monotonic interpolation and extrapolation both at the sea bed and surface. The credible intervals for the density profiles in Fig. 6 were greater at the sea surface where the profile was extrapolated upward. Overall, the credible interval widths ranged from 0.1 to 0.25 kg m^{−3}.

The posterior mean (line) and 0.95 credible intervals (gray shading) for the double hyperbolic tangent density profile model. Red dots indicate the background density profile measurements. (a) Plot for 7 May 2016 (*t* = 27) when the density profile was characterized by was a double pycnocline. (b) Plot for 26 Aug 2016 (*t* = 469) when there was a single pycnocline. (c) Plot for 9 Oct 2016 (*t* = 647) when there was a broader single pycnocline.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

The posterior mean (line) and 0.95 credible intervals (gray shading) for the double hyperbolic tangent density profile model. Red dots indicate the background density profile measurements. (a) Plot for 7 May 2016 (*t* = 27) when the density profile was characterized by was a double pycnocline. (b) Plot for 26 Aug 2016 (*t* = 469) when there was a single pycnocline. (c) Plot for 9 Oct 2016 (*t* = 647) when there was a broader single pycnocline.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

The posterior mean (line) and 0.95 credible intervals (gray shading) for the double hyperbolic tangent density profile model. Red dots indicate the background density profile measurements. (a) Plot for 7 May 2016 (*t* = 27) when the density profile was characterized by was a double pycnocline. (b) Plot for 26 Aug 2016 (*t* = 469) when there was a single pycnocline. (c) Plot for 9 Oct 2016 (*t* = 647) when there was a broader single pycnocline.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

Figure 7 displays the posterior distributions of the profile characteristics for the three example time periods in Fig. 6. Recall that the characteristics provided by the DHT function are the mean density *t* = 27) with a value of 1.3 kg m^{−3}. This date corresponded to expected values of *t* = 469 and 44.4 m at *t* = 647 (Figs. 6b,c), indicating wider upper pycnoclines. Furthermore, both single pycnocline time periods reported an expected value of the density difference ^{−3}. The relatively small density difference and relatively wide upper pycnocline were the key characteristics that resulted in the single pycnocline structure as opposed to the distinct double pycnocline seen at *t* = 27 (Fig. 6a).

Uncertainty quantification as represented by the posterior probability distributions of *t* = 27, (6 May 2016), (middle) *t* = 469 (25 Aug 2016), and (bottom) *t* = 647 (8 Oct 2016). The value in each panel indicates the posterior mean.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

Uncertainty quantification as represented by the posterior probability distributions of *t* = 27, (6 May 2016), (middle) *t* = 469 (25 Aug 2016), and (bottom) *t* = 647 (8 Oct 2016). The value in each panel indicates the posterior mean.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

Uncertainty quantification as represented by the posterior probability distributions of *t* = 27, (6 May 2016), (middle) *t* = 469 (25 Aug 2016), and (bottom) *t* = 647 (8 Oct 2016). The value in each panel indicates the posterior mean.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

Figure 7 demonstrates how each of the DHT parameters behave for the three contrasting density profiles and posterior distributions of the parameters for all time points are presented in Fig. 8. The expected values of the ^{−3} on 9 September 2016 (*t* = 563) with a credible interval of (1023.9, 1024.3). The minimum expected value of the ^{−3} on 19 November 2016 (*t* = 801) with a credible interval of (1023.1, 1023.3). The ^{−3}, with a credible interval of (0.81, 1.00), on 2 October 2016 (*t* = 621), and peaked on 3 May (*t* = 10) at 1.30 kg m^{−3} [credible interval of (1.26, 1.36)]. The primary pycnocline *t* = 308) with an expected value 129.7 m [credible interval of (121.0, 140.3)]. The credible intervals of

Posterior distribution for *t* the posterior distribution is summarized by the upper and lower bounds of the 0.95 credible interval (gray shading) and the posterior mean (black line).

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

Posterior distribution for *t* the posterior distribution is summarized by the upper and lower bounds of the 0.95 credible interval (gray shading) and the posterior mean (black line).

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

Posterior distribution for *t* the posterior distribution is summarized by the upper and lower bounds of the 0.95 credible interval (gray shading) and the posterior mean (black line).

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

The expected values of *austral* summer indicating a wider upper pycnocline during the warmer months. Expected values for the secondary pycnocline depth *austral* winter (169 m) and decreased substantially to 115 m during the transitional season around October. There was no clear seasonal pattern in the width of the secondary pycnocline; the expected

### b. Squared buoyancy frequency and vertical mode structure

Posterior summaries for *t* = 27) resulted in two maxima of the expected value of

Posterior mean and 0.95 credible regions for the (a)–(c) squared buoyancy frequency

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

Posterior mean and 0.95 credible regions for the (a)–(c) squared buoyancy frequency

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

Posterior mean and 0.95 credible regions for the (a)–(c) squared buoyancy frequency

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

The credible intervals allow us to make direct probabilistic statements about the properties of *t* = 27, the credible intervals only include

### c. Nonlinear internal wave quantities

Over the entire observational period, the posterior distributions of phase speed *c* and *α*, and note that the width of the credible intervals for the steepening length scale *by several orders of magnitude*. Given the relatively small credible intervals of the background density profiles (see, e.g., Fig. 6), these results demonstrate large uncertainties in these ocean dynamic quantities.

The 12-month time series of posterior median (black) and 0.95 credible intervals (gray shading) for (a) the linear phase speed *c* [Eq. (2)], (b) the nonlinear parameter *α* [Eq. (4)], and (c) the steepening length scale *L*_{s} [Eq. (5)]. An initial amplitude *a*_{0} = 20 m was used to estimate *L*_{s}.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

The 12-month time series of posterior median (black) and 0.95 credible intervals (gray shading) for (a) the linear phase speed *c* [Eq. (2)], (b) the nonlinear parameter *α* [Eq. (4)], and (c) the steepening length scale *L*_{s} [Eq. (5)]. An initial amplitude *a*_{0} = 20 m was used to estimate *L*_{s}.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

The 12-month time series of posterior median (black) and 0.95 credible intervals (gray shading) for (a) the linear phase speed *c* [Eq. (2)], (b) the nonlinear parameter *α* [Eq. (4)], and (c) the steepening length scale *L*_{s} [Eq. (5)]. An initial amplitude *a*_{0} = 20 m was used to estimate *L*_{s}.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

The credible intervals for

The steepening length *δ* is a distance from the internal wave generation site, then

### d. Isopycnal height

Figure 11 shows the expected values and credible intervals for isopycnal heights as the density profile evolves over time. The credible interval widths for isopycnal heights ranged from 5 to 10 m at the approximate location of the main pycnocline (i.e., between 50 and 200 m). Uncertainty in isopycnal heights increased near the seabed and surface, where credible interval widths extended to approximately 20–40 m. These are usually regions of weaker vertical density gradients that result in larger isopycnal height uncertainty. Note that contouring via linear interpolation, as is typical in the literature and shown in Fig. 2, does not provide this additional information about the heights of individual isopycnals.

The temporal evolution of the background density derived from the fitted hierarchical model. The posterior mean (line) and 0.95 credible intervals (gray shading) are displayed for the isopycnal values specified in the legend. The dashed vertical lines correspond to the times at which the density profiles depicted in Fig. 6 occur.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

The temporal evolution of the background density derived from the fitted hierarchical model. The posterior mean (line) and 0.95 credible intervals (gray shading) are displayed for the isopycnal values specified in the legend. The dashed vertical lines correspond to the times at which the density profiles depicted in Fig. 6 occur.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

The temporal evolution of the background density derived from the fitted hierarchical model. The posterior mean (line) and 0.95 credible intervals (gray shading) are displayed for the isopycnal values specified in the legend. The dashed vertical lines correspond to the times at which the density profiles depicted in Fig. 6 occur.

Citation: Journal of Atmospheric and Oceanic Technology 36, 7; 10.1175/JTECH-D-18-0200.1

## 7. Summary and conclusions

We have outlined a methodology for constructing a Bayesian hierarchical model to estimate continuous vertical density profiles using discrete measurements. An analytical function (DHT) was used to objectively characterize the vertical density structure, whereas the BHM with the Hamiltonian Monte Carlo sampling technique infers the posterior distribution of the DHT parameters. The first level of the hierarchy models time-specific background density using a DHT function [Eq. (11)], thereby retaining local temporal characteristics of continuous vertical depth profiles. The second level permits the DHT parameters to vary temporally in order to assess their annual variability over the observational period. When available, scientific knowledge about the behavior of the density characteristics informed the third and final level prior distributions; otherwise, they were allocated weakly informative priors. It was shown that the DHT function is a flexible model for background density, performs well across different stratification conditions, and yields probabilistic statements about vertical density profiles and their characteristics.

For the interested user, variations to the BHM are straightforward to implement in the Stan software provided. For example, rather than the DHT function in Eq. (12), analytical functions such as exponential stratification models or those described in González-Pola et al. (2007) and Zhou et al. (2017) could be used, as could nonparametric mean functions such as smoothing splines or Gaussian processes. Similarly, various prior specifications, including nonparametric priors, over various model parameters may be substituted for the ones mentioned in this article. Furthermore, the DHT can be adapted to model temperature structure, instead of density, as mentioned in section 3.

This article concentrates on uncertainty as quantified by probability. The BHM provided posterior probabilistic inference for upper-ocean density characteristics, as given by the DHT parameters, at both at a given point in time and their evolution over a year. A novel way of assessing and visualizing the uncertainty in isopycnal heights was shown that provides users with information beyond what is typically reported via interpolating contour lines. Background density is also used as an initial condition in the calculation of various ocean scalars, process models, and parameterizations. We have provided a demonstration of how to propagate the uncertainty in initial background density profiles to obtain posterior distributions of various ocean dynamical properties that may serve as instruments for probabilistic inference.

These results also suggest the need for full uncertainty propagation, as opposed to ad hoc sensitivity analyses of input variables, to fully appreciate the effect that the background density profile uncertainty has on ocean dynamic quantities such as *N*(*z*)^{2}, *c*, and *L*_{s}. For example, at times during the observational period, the nonlinear steepening parameter showed significant uncertainty and the steepening length scale displayed credible interval widths that varied by orders of magnitude. To identify such phenomena a full coverage of the input space, and an associated probability distribution, is required. In this work, they were supplied by the BHM, the posterior distribution of which was validated against real measurements.

## Acknowledgments

AM, MR, EC, MH, GI, and NJ were supported by the ARC Industrial Transformation Research Hub for Offshore Floating Facilities, which is funded by the Australian Research Council, Woodside Energy, Shell, Bureau Veritas, and Lloyd’s Register (Grant IH140100012). MG was supported by EPSRC grants (EP/R034710/1, EP/R018413/1, EP/R004889/1, EP/P020720/1), an EPSRC Established Career Fellowship (EP/J016934/3), and a Royal Academy of Engineering Research Chair. This work is supported by a grant from the Lloyd’s Register Foundation on Data-Centric Engineering. MH was supported by a visiting fellowship from the Alan Turing Institute, London.

## REFERENCES

Aldrin, M., M. Holden, P. Guttorp, R. B. Skeie, G. Myhre, and T. K. Berntsen, 2012: Bayesian estimation of climate sensitivity based on a simple climate model fitted to observations of hemispheric temperatures and global ocean heat content.

,*Environmetrics***23**, 253–271, https://doi.org/10.1002/env.2140.Arthur, R. S., S. K. Venayagamoorthy, and J. R. Koseff, 2017: How we compute

*N*matters to estimates of mixing in stratified flows.,*J. Fluid Mech.***831**, R2, https://doi.org/10.1017/jfm.2017.679.Astfalck, L., E. J. Cripps, J. P. Gosling, M. R. Hodkiewicz, and I. A. Milne, 2018: Expert elicitation of directional metocean parameters.

,*Ocean Eng.***161**, 268–276, https://doi.org/10.1016/j.oceaneng.2018.04.047.Berliner, L. M., C. K. Wikle, and N. Cressie, 2000: Long-lead prediction of Pacific SSTs via Bayesian dynamic modeling.

,*J. Climate***13**, 3953–3968, https://doi.org/10.1175/1520-0442(2001)013<3953:LLPOPS>2.0.CO;2.Bernardo, J. M., and A. F. M. Smith, 1994:

*Bayesian Theory.*John Wiley and Sons, 586 pp.Betancourt, M., 2017: A conceptual introduction to Hamiltonian Monte Carlo. ArXiv, https://arxiv.org/abs/1701.02434.

Betancourt, M., and M. Girolami, 2015: Hamiltonian Monte Carlo for hierarchical models.

*Current Trends in Bayesian Methodology with Applications*, CRC Press, 79–101.Brooks, S., A. Gelman, G. Jones, and X.-L. Meng, 2011:

*Handbook of Markov Chain Monte Carlo.*CRC Press, 619 pp.Carpenter, B., and Coauthors, 2017: Stan: A probabilistic programming language.

,*J. Stat. Software***76**, 1–32, https://doi.org/10.18637/jss.v076.i01.Chelton, D. B., R. A. Deszoeke, M. G. Schlax, K. El Naggar, and N. Siwertz, 1998: Geographical variability of the first baroclinic Rossby radius of deformation.

,*J. Phys. Oceanogr.***28**, 433–460, https://doi.org/10.1175/1520-0485(1998)028<0433:GVOTFB>2.0.CO;2.Chu, P. C., C. R. Fralick, S. D. Haeger, and M. J. Carron, 1997: A parametric model for the Yellow Sea thermal variability.

,*J. Geophys. Res.***102**, 10 499–10 507, https://doi.org/10.1029/97JC00444.Feistel, R., 2008: A Gibbs function for seawater thermodynamics for −6 to 80°C and salinity up to 120 g kg−1.

,*Deep-Sea Res. I***55**, 1639–1671, https://doi.org/10.1016/j.dsr.2008.07.004.Fiedler, P. C., 2010: Comparison of objective descriptions of the thermocline.

,*Limnol. Oceanogr. Methods***8**, 313–325, https://doi.org/10.4319/lom.2010.8.313.Furrer, R., S. R. Sain, D. Nychka, and G. A. Meehl, 2007: Multivariate Bayesian analysis of atmosphere–ocean general circulation models.

,*Environ. Ecol. Stat.***14**, 249–266, https://doi.org/10.1007/s10651-007-0018-z.Gelfand, A. E., and A. F. M. Smith, 1990: Sampling-based approaches to calculating marginal densities.

,*J. Amer. Stat. Assoc.***85**, 398–409, https://doi.org/10.1080/01621459.1990.10476213.Gelman, A., 2006: Prior distributions for variance parameters in hierarchical models (comment on article by Browne and Draper).

,*Bayesian Anal.***1**, 515–534, https://doi.org/10.1214/06-BA117A.Gelman, A., and J. Hill, 2007:

*Data Analysis Using Regression and Multilevel/Hierarchical Models*. Cambridge University Press, 625 pp.Gelman, A., J. Carlin, H. Stern, D. Dunson, A. Vehtari, and D. Rubin, 2013:

*Bayesian Data Analysis*. 3rd ed. CRC Press, 675 pp.Gelman, A., D. Lee, and J. Guo, 2015: Stan: A probabilistic programming language for Bayesian inference and optimization.

,*J. Educ. Behav. Stat.***40**, 530–543, https://doi.org/10.3102/1076998615606113.Gill, A. E., 1982:

*Atmosphere–Ocean Dynamics*. Academic Press, 662 pp.Girolami, M., and B. Calderhead, 2011: Riemann manifold Langevin and Hamiltonian Monte Carlo methods.

,*J. Roy. Stat. Soc.***73B**, 123–214, https://doi.org/10.1111/j.1467-9868.2010.00765.x.González-Pola, C., J. M. Fernández-Díaz, and A. Lavín, 2007: Vertical structure of the upper ocean from profiles fitted to physically consistent functional forms.

,*Deep-Sea Res. I***54**, 1985–2004, https://doi.org/10.1016/j.dsr.2007.08.007.Hastings, W. K., 1970: Monte Carlo sampling methods using Markov chains and their applications.

,*Biometrika***57**, 97–109, https://doi.org/10.2307/2334940.Hennig, P., M. A. Osborne, and M. Girolami, 2015: Probabilistic numerics and uncertainty in computations.

,*Proc. Roy. Soc.***471A**, 20150142, https://doi.org/10.1098/rspa.2015.0142.Hoffman, M. D., and A. Gelman, 2014: The No-U-turn sampler: Adaptively setting path lengths in Hamiltonian Monte Carlo.

,*J. Mach. Learn. Res.***15**, 1593–1623, http://jmlr.org/papers/v15/hoffman14a.html.Holloway, P. E., E. Pelinovsky, and T. Talipova, 1999: A generalized Korteweg-de Vries model of internal tide transformation in the coastal zone.

,*J. Geophys. Res.***104**, 18 333–18 350, https://doi.org/10.1029/1999JC900144.Jaynes, E. T., and O. Kempthorne, 1976: Confidence intervals vs Bayesian intervals.

*Foundations of Probability Theory, Statistical Inference, and Statistical Theories of Science*, Springer, 175–257.Jeffreys, H., 1998:

*The Theory of Probability.*Oxford University Press, 470 pp.Kang, D., and O. Fringer, 2010: On the calculation of available potential energy in internal wave fields.

,*J. Phys. Oceanogr.***40**, 2539–2545, https://doi.org/10.1175/2010JPO4497.1.King, B., M. Stone, H. P. Zhang, T. Gerkema, M. Marder, R. B. Scott, and H. L. Swinney, 2012: Buoyancy frequency profiles and internal semidiurnal tide turning depths in the oceans.

,*J. Geophys. Res.***117**, C04008, https://doi.org/10.1029/2011JC007681.Lamb, K. G., and L. Yan, 1996: The evolution of internal wave undular bores: Comparisons of a fully nonlinear numerical model with weakly nonlinear theory.

,*J. Phys. Oceanogr.***26**, 2712–2734, https://doi.org/10.1175/1520-0485(1996)026<2712:TEOIWU>2.0.CO;2.Lee, F. M., M. R. Allshouse, H. L. Swinney, and P. J. Morrison, 2018: Internal wave energy flux from density perturbations in nonlinear stratifications.

,*J. Fluid Mech.***856**, 898–920, https://doi.org/10.1017/jfm.2018.699.Liu, A., and D. Benney, 1981: The evolution of nonlinear wave trains in stratified shear flows.

,*Stud. Appl. Math.***64**, 247–269, https://doi.org/10.1002/sapm1981643247.Llewellyn Smith, S. G., and W. R. Young, 2003: Tidal conversion at a very steep ridge.

,*J. Fluid Mech.***495**, 175–191, https://doi.org/10.1017/S0022112003006098.Metropolis, N., A. W. Rosenbluth, M. N. Rosenbluth, and A. H. Teller, 1953: Equation of state calculations by fast computing machines.

,*J. Chem. Phys.***21**, 1087–1092, https://doi.org/10.1063/1.1699114.Milliff, R. F., A. Bonazzi, C. K. Wikle, N. Pinardi, and L. M. Berliner, 2011: Ocean ensemble forecasting. Part I: Ensemble Mediterranean winds from a Bayesian hierarchical model.

,*Quart. J. Roy. Meteor. Soc.***137**, 858–878, https://doi.org/10.1002/qj.767.Monnahan, C. C., J. T. Thorson, and T. A. Branch, 2017: Faster estimation of Bayesian models in ecology using Hamiltonian Monte Carlo.

,*Methods Ecol. Evol.***8**, 339–348, https://doi.org/10.1111/2041-210X.12681.Nash, J., M. Alford, and E. Kunze, 2005: Estimating internal wave energy fluxes in the ocean.

,*J. Atmos. Oceanic Technol.***22**, 1551–1571, https://doi.org/10.1175/JTECH1784.1.Neal, R., 2011: MCMC using Hamiltonian dynamics.

*Handbook of Markov Chain Monte Carlo*, S. Brooks et al., Eds., CRC Press, 113–162.O’Hagan, A., C. E. Buck, A. Daneshkhah, J. R. Eiser, P. H. Garthwaite, D. J. Jenkinson, J. E. Oakley, and T. Rakow, 2006:

*Uncertain Judgements: Eliciting Experts’ Probabilities.*John Wiley and Sons, 338 pp.Phillips, O. M., 1977:

*The Dynamics of the Upper Ocean.*Cambridge University Press, 336 pp.Polzin, K. L., A. C. Naveira Garabato, T. N. Huussen, B. M. Sloyan, and S. Waterman, 2014: Finescale parameterizations of turbulent dissipation.

,*J. Geophys. Res. Oceans***119**, 1383–1419, https://doi.org/10.1002/2013JC008979.Rayson, M. D., N. L. Jones, and G. N. Ivey, 2019: Observations of large-amplitude mode-2 nonlinear internal waves on the Australian North West shelf.

,*J. Phys. Oceanogr.***49**, 309–328, https://doi.org/10.1175/JPO-D-18-0097.1.R Core Team, 2018: R: A language and environment for statistical computing. R Foundation for Statistical Computing, https://www.R-project.org/.

Robert, C., and G. Casella, 2013:

*Monte Carlo Statistical Methods.*Springer Science and Business Media, 649 pp.Singpurwalla, N. D., 2006:

*Reliability and Risk: A Bayesian Perspective.*John Wiley and Sons, 396 pp.Sprintall, J., and D. Roemmich, 1999: Characterizing the structure of the surface layer in the Pacific Ocean.

,*J. Geophys. Res.***104**, 23 297–23 311, https://doi.org/10.1029/1999JC900179.Sprintall, J., and M. F. Cronin, 2010: Upper ocean vertical structure.

*Encyclopedia of Ocean Sciences*, Academic Press, 217–224, https://doi.org/10.1016/B978-012374473-9.00627-5.Stan Development Team, 2018: RStan: The R interface to Stan, version 2.17.3. R package, http://mc-stan.org/.

Stastna, M., and K. G. Lamb, 2002: Large fully nonlinear internal solitary waves: The effect of background current.

,*Phys. Fluids***14**, 2987–2999, https://doi.org/10.1063/1.1496510.Wikle, C. K., R. F. Milliff, R. Herbei, and W. B. Leeds, 2013: Modern statistical methods in oceanography: A hierarchical perspective.

,*Stat. Sci.***28**, 466–486, https://doi.org/10.1214/13-STS436.Wikle, C. K., A. Zammit-Mangion, and N. Cressie, 2019:

*Spatio-Temporal Statistics with R.*CRC Press, 380 pp.Zhou, C., X. Ding, J. Zhang, J. Yang, and Q. Ma, 2017: An objective algorithm for reconstructing the three-dimensional ocean temperature field based on Argo profiles and SST data.

,*Ocean Dyn.***67**, 1523–1533, https://doi.org/10.1007/s10236-017-1104-x.