Ensemble-marginalized Kalman filter for linear time-dependent PDEs with noisy boundary conditions: Application to heat transfer in building walls

In this work, we present the ensemble-marginalized Kalman filter (EnMKF), a sequential algorithm analogous to our previously proposed approach [1,2], for estimating the state and parameters of linear parabolic partial differential equations in initial-boundary value problems when the boundary data are noisy. We apply EnMKF to infer the thermal properties of building walls and to estimate the corresponding heat flux from real and synthetic data. Compared with a modified Ensemble Kalman Filter (EnKF) that is not marginalized, EnMKF reduces the bias error, avoids the collapse of the ensemble without needing to add inflation, and converges to the mean field posterior using $50\%$ or less of the ensemble size required by EnKF. According to our results, the marginalization technique in EnMKF is key to performance improvement with smaller ensembles at any fixed time.


Introduction
Uncertainty in the thermophysical properties of building envelopes has been recognized as one of the main sources of uncertainty when simulating the thermal performance of buildings [3,4,5,6,7]. Simulations of this kind are essential to the development of cost-effective retrofitting measures aimed at improving the energy efficiency of existing buildings. Moreover, accurate uncertainty analyses of the energy performance of the housing stock are vital for drafting policies to reduce global carbon emissions [8,3]. Most existing approaches use simplified heat diffusion models to quantify uncertainty in the thermophysical properties of walls [8,9]. However, recent works have suggested that a PDE-constrained data-assimilation approach is required to accurately estimate the thermophysical properties of walls [10,2].
Most existing statistical approaches that infer thermophysical properties of walls [8,9,10] assume that the boundary temperatures, T int (t) and T ext (t), can be approximated by their corresponding measurements recorded on the internal and external surfaces of a wall by temperature sensors. Although these approaches  augmented state-parameter vector at time t k w k centered Gaussian noise of the state vector T k with covariance matrix W k v k centered Gaussian noise of the observation vector y k with covariance matrix V k q k centered Gaussian noise of the control vector u k with covariance matrix Q k c k centered Gaussian noise of the observed control vector z k with covariance matrix C k T k|k E[T k |θ, z 1:k , y 1:k ] T k|k−1 E[T k |θ, z 1:k , y 1:k−1 ] P k|k Cov(T k |θ, z 1:k , y 1:k ) P k|k−1 Cov(T k |θ, z 1:k , y 1:k−1 ) u k|k E[u k |z 1:k ] P u k|k Cov(u k |z 1:k ) P k|k−1 Cov(X k |z 1:k , y 1:k−1 ) ignore the uncertainty in those measurements, they enable the construction of a well-defined parameterto-measurements map that can be inverted via existing frameworks [11]. However, we recently showed that ignoring the uncertainty in boundary temperatures can lead to biased estimates of the thermophysical properties and, thus, reduce the accuracy of uncertainty analyses in energy-performance evaluations of buildings [2]. In order to account for the uncertainty of boundary measurements within a PDE-constrained Bayesian framework, we developed a marginalization technique that assimilates the available data all at once. This approach was both (i) accurate in identifying thermophysical properties of walls, and (ii) useful for developing off-line experimental design strategies to reduce the measurement campaigns.
Following these recent advances, practitioners would substantially benefit from a data assimilation framework capable of updating the probabilistic knowledge of thermophysical properties as new measurements become available. Such a framework could be used to assess in real time whether a specific level of accuracy or uncertainty has been achieved, in order to reduce the long measurement campaigns that often involve several weeks [5]. The objective of this work is to develop a sequential Bayesian approach to infer the thermal properties of walls and estimate the corresponding heat flux within a computationally tractable framework that accounts for the uncertainty in the measurements of the boundary temperatures.
Bayesian filtering [12,13] can be used to compute the desired distribution for a joint state-parameter assimilation problem. However, sampling is required to approximate the desired distribution when the Bayesian posterior cannot be expressed in a closed form. For example, particle filters use importance sampling to represent the posterior distribution. Unfortunately, particle filters may become computationally prohibitive [14] and, thus, unsuitable for practical implementation in real-time data assimilation. As an alternative to fully Bayesian samplers, the ensemble Kalman filter (EnKF) is the preferred method for data assimilation in partially observed systems where the underlying dynamics are nonlinear and the state space is high-dimensional [15]. Initially proposed for state estimation [16], modified versions of EnKF have been proposed to address joint state-parameter estimation [17]. The EnKF methodology uses a Gaussian approximation for the predictive step in the Bayesian filtering framework; this enables the characterization of the Bayesian posterior within the analysis step as a Gaussian distribution with mean and covariance computed via standard Kalman-like formulas. Different approaches to characterize this Gaussian distribution have led to several EnKF algorithms including the stochastic EnKF and the ensemble square-root Kalman filter that are reviewed elsewhere [18,15].
The Gaussian approximations within the EnKF framework do not lead to algorithms with asymptotic convergence to the desired posterior when the underlying dynamics of the state-parameter system are nonlinear [19]. Nevertheless, EnKF has been successfully used in numerous applications, including oceanography, meteorology, subsurface flow and engineering [20,21]. In most of these studies, the success of EnKF was reliant on ad-hoc fixes such as covariance inflation and localization [22,23,20]. More recently, regularized versions of EnKF were proposed that merged ideas from particle filters with iterative regularization techniques [24,25,10]. For example, a regularizing EnKF was applied for parameter estimation of thermal properties of walls [10]. This approach, however, focused entirely on the Bayesian parameter estimation of the thermophysical properties and did not consider joint state-parameter estimation. Consequently, the resulting algorithm required that the heat transfer model was run from the initial start time until the current assimilation time to update the state of the system (i.e., the wall-temperature profile). A joint state-parameter estimation approach for the real-time assimilation of in-situ measurements that enabled sequential updating of both the parameters and the state would be much more efficient.
In this paper, we study the joint state-parameter estimation problem within a setting of linear PDEs with noisy boundary conditions motivated by the aforementioned application which involves the mathematical modeling of heat transfer through walls. More specifically, we are interested in the real-time uncertainty quantification of thermophysical properties of walls via the sequential assimilation of in-situ measurements of the wall's surface temperature and heat flux. We propose an ensemble-marginalized Kalman filter (EnMKF) to approximate the joint state-parameter Bayesian estimation problem for a par-tially observed linear system that is obtained from the discretization of linear time-dependent PDEs. In this general setting, we obtain a linear forward operator that depends nonlinearly on a vector of parameters while the observation operator is linear and independent of all parameters. In our specific application, we also adapt EnMKF and EnKF to handle an observation operator that depends linearly on the thermal resistance parameter.
The remainder of the paper is organized as follows. In Section 2, we introduce the state-space formulation that can be used to analyze a class of linear PDE problems. We present the filtering approach for estimating the unknown state-parameter vectors in Section 3. In particular, subsection 3.3 provides a Bayesian formulation for the proposed marginalized filtering algorithms. Subsection 3.4 contains our novel ensemble-marginalized Kalman filter (EnMKF). In subsection 3.5, we consider a slightly modified EnKF where the boundary conditions are sampled from their filtered distribution, and we describe the primary differences between EnMKF and the modified EnKF. The performances of the EnMKF and the modified EnKF algorithms are compared using real and synthetic data in Section 4. Conclusions are summarized in Section 5.

General formulation
Consider the linear time-dependent parabolic initial-boundary value problem on the domain D × [0, t N ] ⊂ R d+1 : T and θ = (a 11 , . . . , a dd , b 1 , . . . , b d , c). Our goal is to estimate θ and T sequentially in time given partial observations of T (x, t) and measurements of u(x, t). As a special case, we consider in Section 4 the heat equation to model the heat transfer process through building walls and, given real measurements, we estimate the thermal properties of a brick wall.
By discretizing (1) using finite differences or finite elements [1], we can derive the discrete state-space model where T k n×1 is the state vector at time t k , y k m×1 corresponds to measurements of T k , A θ is the forward model operator that depends on the parameter vector θ p×1 , H is a linear observational map, B θ is the control matrix operator, and we assume that the control vector u k ×1 follows another state observation system: where F is a user-defined linear evolution operator (see subsection 3.1) and z k ×1 is the observed control vector at time t k . We further assume that w k , v k , q k , c k are independent centered Gaussian random vectors with covariances W k , V k , Q k , C k , respectively. The joint Bayesian estimation of θ and T k , in a sequential filtering approach, as the observations {z 1:k , y 1:k } become available can be now posed in terms of the computation of the conditional density p(T k , θ|z 1:k , y 1:k ). Following the marginalization technique [1,2] and ideas from marginalized particle filters [26,27,28], we exploit the linear structure of (2) and propose an ensemble-marginalized Kalman filter (EnMKF) that provides an approximation of p(T k , θ|z 1:k , y 1:k ). From (2), it is easy to approximate the conditional distribution p(T k , θ|u k , y 1:k ). In order to incorporate the error of the boundary conditions, we use the tractability of the distribution p(u k |z 1:k ). In other words, by noticing from (3) that u k follows a linear dynamic system independent of (2), and under further Gaussian assumptions on u 0 , it follows that the distribution p(u k |z 1:k ) can be expressed in closed form by using the Kalman filter [29]. The desired joint distribution p(T k , θ|z 1:k , y 1:k ) is then approximated by integrating out u k from the fully joint distribution p(T k , θ, u k |z 1:k , y 1:k ) = p(T k , θ|u k , y 1:k )p(u k |z 1:k ).

Methodology
In this section, we introduce the ensemble-marginalized Kalman filter (EnMKF) as a state-parameter estimation algorithm for the partially observed linear system (2). The boundary conditions u k are estimated first by applying the classical Kalman filter to (3). Next, we derive a marginalized Kalman filter for the state T k , assuming that θ is known. Then, this intermediate result is generalized to develop a joint filter for the state T k and parameter θ based on the EnKF framework. EnMKF differs from EnKF in the prediction step; in EnMKF, the prediction covariance of T k is inflated by the expectation of the analysis covariance matrix of u k with respect to θ.

Kalman filtering for u k
The state-space model for u k in (3) is linear and independent from T k . Therefore, we can implement Kalman filter given the observation z k as follows: 1. Prediction step: 2. Analysis step: where K u k is the Kalman gain matrix of the state-space model for the control vector u k .
Assuming u 0 is Gaussian, the Kalman filter provides the exact filtering distribution as N (u k|k , P u k|k ). In many applications, the forward operator F is unknown and autoregressive models must be considered [30]. Some proposals for the autoregressive forward models are: In subsection 4.2, we impose AR(1) and AR(2) on the boundary temperatures, T int (t) and T ext (t), and compare the filtered results with the real data.
Remark. Although the state-space model for u k is independent from T k , we apply the Kalman filter within the time propagation of either EnMKF or EnKF.

Marginalized Kalman filter for T k |θ
Before deriving the filtering algorithm for the joint state-parameter vector, we derive the marginalized Kalman filter for the conditional state T k |θ given the observations (z 1:k , y 1:k ). Assuming T 0 is Gaussian, the Kalman filter is sufficient to estimate the filtering distribution of T k given θ. We derive the conditional mean and the conditional covariance for T k |θ given the observations (z 1:k , y 1:k−1 ): (using the mutual independence of T k−1 , u k and w k ) From (6) and (7), the marginalized Kalman filter for T k |θ is summarized by 1. Prediction step: where T k|k−1 is the state prediction at time k, given θ and the observations (z 1:k , y 1:k−1 ), and P k|k−1 is the corresponding covariance matrix. 2. Analysis step: where T k|k is the state estimation at time k, given θ and the observations (z 1:k , y 1:k ), and K k is the Kalman gain.
Remark. The prediction step can be generalized under the Bayesian approach and corresponds to the following equation: where the marginalization of u k appears explicitly. The analysis step is generalized under the Bayesian approach as p(T k |θ, z 1:k , y 1:k ) = p(y k |T k )p(T k |θ, z 1:k , y 1:k−1 ) p(y k |T k )p(T k |θ, z 1:k , y 1:k−1 )dT k ∝ p(y k |T k )p(T k |θ, z 1:k , y 1:k−1 ) .

Marginalized Bayesian filtering for T k and θ
We now derive filtering algorithms to estimate the joint state-parameter vector, X k = [ θ T k ] , given the observations (z 1:k , y 1:k ) up to time k. In this case, the evolution of the joint vector, X k , is nonlinear and approximate filtering algorithms are needed. We derive first the underlying Bayesian formulation for the filtering algorithms. The static parameters, θ, have a trivial evolution in the prediction step and therefore we neglect their time subscript.

EnMKF for θ and T k
Here, the main idea is to consider an ensemble version of the marginalized Kalman filter introduced in 3.2 to approximate the Bayesian filter 3.3. We initialize the algorithm by drawing independently M samples from the prior distributions of the parameters and the initial state, Then, in the prediction step, we evolve each state vector T i 0 in time given the parameters θ i to obtain the state vectors at time t 1 . The measurements at time t 1 are then utilized in the analysis step to update both states and parameters. We iterate the prediction and analysis steps until we use all measurements and reach the final time point t N .
The evolution of the joint vector, X k , is nonlinear because T k depends on θ nonlinearly. Therefore, we can not use Kalman filter directly. The ensemble Kalman framework is introduced to handle the nonlinear dependence on θ, and it uses a Gaussian approximation to update the ensemble members in the analysis step. In our EnMKF algorithm, we exploit the conditional linearity of the joint vector to derive its prediction mean and covariance.
Following the stochastic EnKF scheme [20,17], we assume a trivial evolution of the static parameters and denote the samples from p(θ|y 1:k−1 ) by θ i |k−1 . Given the ensemble size M , we compute the predicted The prediction covariance matrix, P k|k−1 , is usually approximated by the sample covariance matrix of This approximation is needed due to the nonlinearity. Instead, we derive the covariance matrix of X k|k−1 using the law of total covariance by conditioning on θ |k−1 : where θ |k−1 = 1 M M i=1 θ i |k−1 , and P i k−1|k−1 must be computed using the Kalman update equations: Computing and storing these covariance matrices P i k|k and P i k|k−1 for each i = 1, . . . , M may be burdensome, especially when dim(T k ) is large. Therefore, we consider the following approximation of the prediction covariance matrix: which requires the computation of B θ i for each i = 1, . . . , M in addition to the standard prediction covariance of EnKF (9). The additional term in (11) can be interpreted as inflation with respect to u k and w k . The full prediction covariance (10) provides an extra inflation with respect to T k−1 . However, it is computationally intractable except in very simple cases. The standard practice in EnKF is to consider the sample covariance (9) only. Our implementation (11) inflates the covariance in a tractable way. In the next section, we introduce another algorithm where we sample u k ; therefore, the inflation is not needed.
After applying the prediction step in (8) and (11), the analysis step for X k is computed by where H m×(p+n) is the observation operator that maps the augmented vector X k to the corresponding observation space and v i k ∼ N (0, V k ) is used to perturb the observations. A clear advantage of EnMKF is that it runs sequentially on time without the need to restart from the initial state. At a given time t k , the static parameters are updated in the analysis step using measurements at time t k . We summarize the complete algorithm of EnMKF in Algorithm 1. run the Kalman filter for u k (equations (4) and (5)) to obtain u k|k and P u k|k 5: run the prediction step for i = 1, . . . , M compute the prediction covariance matrix P k|k−1 using (11) 7: run the analysis step for each X i , i = 1, . . . , M In general, ensemble Kalman filters suffer from bias errors, especially with nonlinear systems. A common bias error is due to the Kalman formula that assumes Gaussianity. Nevertheless, the incorporation of the boundary temperature uncertainties will reduce the total bias error in the estimated parameters [2]. We show in subsection 4.7 that EnMKF admits smaller bias errors than the following EnKF algorithm.

Ensemble Kalman filter for θ and T k
An alternative approach to solve our problem (2)-(3), is to apply an adequately modified EnKF to the joint vector X k = [ θ T k ] . In this modified EnKF, the control vector u k is sampled from its distribution, which was determined during the prediction step. Thus, we sample u i k from N (u k|k , P u k|k ) for each i = 1, . . . , M . Then, the prediction step differs from (8) and is given by In this case, the prediction covariance matrix is approximated by The analysis step is the same as the one that we developed for EnMKF, which is summarized by equations (12) and (13). Both EnMKF and EnKF are Monte Carlo implementations of Bayesian filtering. The main difference appears in the prediction step, especially in the integration with respect to u k . In EnMKF, we use the fact that u k |z 1:k and T k |θ, u k , T k−1 have Gaussian distributions and, therefore, the resulting distribution is Gaussian with mean (6) and covariance (7). In EnKF 3.5, the same integral is approximated with the Monte Carlo method by sampling from p(u k |z 1:k ).
The modified EnKF approach avoids the computation of the matrices B θ i that are needed in formula (11) of EnMKF. However, the additional term in EnMKF can be considered inflation induced from the law of total covariance by conditioning on the unknown parameters θ. Similarly, the joint distribution of the state and parameters can be split into the distribution of the conditional state and the marginal distribution of the parameters [31]. In our case, the linear evolution of the state and control vectors simplifies the conditional distribution to the conditional mean (6) and the conditional covariance (7).

Real-world application: Heat transfer across a solid brick wall
In this section, we show how to formulate and implement the EnMKF method to deal with the state and parameter estimation problem in a real-world heat-transfer application, which is summarized in subsection 4.1. Next, we compare the results obtained with the EnMKF Algorithm 1 to those obtained with the modified EnKF method from Section 3.5 using experimental and synthetic data. We also propose stopping criteria that indicate when the ensemble parameters are stationary with adequate non-zero variance.
We consider the problem of describing the thermal performance of a solid wall given in-situ measurements. This can be posed as a state and parameter estimation problem constrained by the heat equation. For simplicity, we consider the case of a single-layer wall with homogeneous density, thermal conductivity, and specific heat capacitance. Therefore, we characterize the thermophysical properties of the wall in terms of its heat capacity per unit area (J/m 2 K) and thermal resistance (m 2 K/W ). These are denoted by ρC and R, respectively. Under the standard assumption of uni-directional heat flux across the wall's thickness, the forward model is described by the internal temperature profile of the wall, denoted by T (x, t). This profile is the solution to the 1D heat equation [32]: where L is the wall thickness, T int and T ext are the internal and external wall surface temperatures, respectively, and T 0 (x), is the initial temperature of the wall. The goal is to estimate the thermophysical properties θ = (R, ρC) given boundary temperature measurements T int and T ext as well as measurements of the internal and external boundary heat flux defined via: An experimental setting consistent with (15)- (16) can be designed by placing temperature sensors and heat flux meters on the internal and external surfaces of the wall [2,10]. These quantities are then monitored for a period of time which often consist of at least two weeks. In order to reduce the effect of solar radiation (not considered in (15)), measurement campaigns are usually conducted on north-facing walls during the winter [33]. For simplicity, we also assume that the initial condition, T 0 (x), is well-approximated by the piecewise linear function where we assume τ 0 = 16.1 • C, according to the estimate we obtained in our previous study [2]. To formulate the discrete state observation system, we consider the following uniform space-time discretization: x 0 = 0, x 1 = ∆x, . . . , x i = i∆x, . . . , x n = n∆x = L , t 0 = 0, t 1 = ∆t, . . . , t j = j∆t, . . . , t N = N ∆t , and denote byT k = (T (∆x, k∆t), . . . , T ((n − 1)∆x, k∆t)) , T int,k = T int (k∆t) and T ext,k = T ext (k∆t) the inner, internal and external surface temperatures at time t k , respectively. The inner temperature vector T k can be written as a linear function of T int,k and T ext,k as follows [2]: where the matricesÃ θ ,B θ,int , andB θ,ext are specified exactly (see [2]).
We let T k = [ T int,kT k T ext,k ] be the temperature vector on the closed interval [0, L] and Then, the time evolution equation of the state vector T k is given by The heat-flux vector F k = F int,k F ext,k is approximated by the first difference Therefore, the observation matrix operator takes the form where v k ∼ N (0, V k ) is the measurements noise and H = [ 0 H ] is the observation operator that maps the augmented vector X k to the observation space.
We define the observation matrix operator without R to avoid dependence of the Kalman gain on this unknown parameter. Instead, we keep the Kalman gain fixed in each iteration of the algorithm and modify the so-called innovation to be Ry k − HT k . We tailor the EnMKF in Algorithm 1 to the state observation system (18)- (19) in Algorithm 2, by augmenting the state vector with log(R) and log(ρC) to ensure that the physical parameters are positive.
The heat conduction problem described in (15) for a single-layer wall model is relevant for the experimental setting described in the following subsection. However, it is important to emphasize that the EnMKF algorithm introduced in subsection 3.4 can be used to infer thermophysical properties of a much wider class of walls. Multilayer walls, for example, can be described by suitable modifications to (15) that incorporate the thermophysical properties on each layer. Each of these properties can then be included in the unknown vector of parameters θ that is inferred within the EnMKF. run the Kalman filter for T int,k and T ext,k to obtain T int,k|k , T ext,k|k , P int,k|k and P ext,k|k 7: run the prediction step for i = 1, . . . , M compute the prediction covariance matrix run the analysis step for each X i , i = 1, . . . , M estimate the heat flux and its sample mean and sample covariance 11: end for

Experimental data set
We use real data from an experiment conducted inside an environmental chamber in the Energy Technologies Building at Nottingham University Innovation Park. The chamber was divided into two rooms by a 215−mm thick partition wall. The aim of the experiment was to estimate the thermal properties of a brick section of the partition wall. The temperature in both rooms was controlled to resemble internal conditions in Room 1 and external conditions in Room 2. The wall boundary temperature and heat-flux measurements were recorded every minute by sensors placed on the surface of the brick wall [2]. Figure 1 shows the time series of the temperature and heat flux measurements corresponding to the two sides of the brick wall, identified by internal and external measurements. The measurements contain noise that we can analyze, in a non-sequential framework, by using a smoothing spline method to fit a curve to each time series. Then, we approximate the noise by the difference between the measurements and the smooth curve values. The noise variance is estimated to be around 0.01 for the temperature measurements. The noise variances for the internal and external heat flux measurements are estimated to be 20 and 5, respectively. Therefore, the covariance matrix V k is approximated by Alternatively, we can approximate V k by using prior knowledge on the accuracy of the measuring devices in different situations or by assuming a prior model with unknown hyper-parameters and estimate them sequentially along with the quantities of interest. Further statistical analyses and details about these experimental data are provided in [2].

Kalman filtering for u k
The first step in implementing EnMKF is to run a Kalman filter for the control vector u k in (3), which in this case, consists of the boundary conditions T int,k and T ext,k . The forward-evolution operator for the boundary conditions is unknown but noisy measurements are available. We consider the two autoregressive models AR(1) and AR(2) from subsection 3.1 and use them with the measurements to apply the Kalman filter. Figures 2 and 3 show the results from the Kalman filter with each model and the real temperature measurements. In the experiments with EnMKF and EnKF presented below, we use only the results from the Kalman filter with AR(1). We also estimate the variance for the boundary conditions T int,k and T ext,k . For example, Figure 4 shows the estimated mean and confidence bands for the internal temperature measurements using Kalman filter with AR(1). The estimated variances capture the variability of the data and therefore we can marginalize the uncertainty of the boundary conditions accurately.

EnMKF results
We run EnMKF Algorithm 2 with M = 100 and using the complete experimental data set, N = 6, 900. We initially sample R i and ρC i from the uniform priors, U (0.17, 0.36) and U (234000, 431000), and sample T i 0 from the normal prior distribution, N (T 0 , 0.01I n ).  Figure 5 shows the convergence of the ensemble parameters R and ρC with respect to time as more observations are incorporated. The thermal-resistance mean converges to 0.31 m 2 K/W and the mean of the heat capacity per unit area converges to 3.11 × 10 5 J/m 2 K. As we increase the ensemble size, we obtain results that are more accurate and consistent with the MCMC results in [2]. We further analyze the convergence of EnMKF with respect to the ensemble size M and compare it with the convergence of the modified EnKF in subsection 4.5.  We also compute the heat flux from the estimated temperature and parameters by EnMKF. Figures  6 and 7 show that the estimated heat fluxes match the real measurements suitably. The corresponding variances for the estimated heat fluxes converge to be smaller than 1. We recall that the heat flux measurements are very noisy and it would not be optimal to recover the measurements variance through the variance of the estimates. Figures 6 and 7 indicate that our estimates are unbiased and therefore smaller variances are preferable.

EnKF results
We apply the modified EnKF approach introduced in Section 3.5, with ensemble size M = 100, to infer the parameters R and ρC as in the previous example. Figure 8 shows that the ensemble of R and ρC collapse at time t = 1734 minutes. After this time, the parameters remain fixed at the biased estimates R = 0.3 m 2 K/W and ρC = 3.42 × 10 5 J/m 2 K. Thus, the estimated heat fluxes do not match the measurements. In Figures 9 and 10, we show only the sample mean of the heat-flux ensemble because the variances of the internal and external heat fluxes are approximately 390 and 130, respectively. These values are much larger than the estimated variances produced by the EnMKF approach. We can gradually increase the ensemble size M to mitigate the ensemble collapse and reduce the bias error in the estimated parameters. Figures 11, 12 and 13 show the estimated parameters and heat-flux mean when M = 300. Although the bias error of the estimated parameters is reduced, the corresponding variances still vanish as time increases, which is not a realistic feature. While the internal and external heat fluxes variances are reduced to 375 and 124, respectively, they are still very large values when compared with the estimated variances produced by EnMKF.

Comparing EnMKF and EnKF
Finally, we compare the EnMKF method and the modified EnKF method by analyzing the convergence of the estimated parameters at a fixed time with respect to the ensemble size M . Figures 14, 15  show the convergence of the parameters-ensemble mean and standard deviation with ensemble size M at time t = 3000 minutes. The ensemble mean converges linearly for both methods but EnMKF has a better error constant and, therefore, is more reliable for small ensemble sizes. Moreover, due to the collapse of the ensemble, the convergence of the ensemble standard deviation for EnKF occurs only after M > 1000.

Stopping criteria
EnMKF solves the collapse problem that usually arises with EnKF algorithms for state-parameter estimation. Ideally, we want the ensemble of each parameter to converge with time to become samples from the posterior distribution. Assuming this posterior distribution is unimodal, the convergence of our algorithm can be confirmed by computing the ensemble mean and standard deviation for each parameter. The time convergence of these estimated values can be used to suggest stopping criteria for ongoing measurement campaigns. For example, when the difference between two consecutive means and two consecutive standard deviations are relatively small, then the measurement campaign should be stopped.
In Figures 17 and 18, we see that the ensemble mean and standard deviation for R and ρC stabilize after 5000 minutes. This indicates that the measurements collected up to that time are sufficient and the experiment can be stopped.

Bias error analysis
We treat the boundary conditions as random variables that are marginalized in EnMKF and sampled in EnKF. In both EnKF and EnMKF, the bias error of the estimated parameters and the variability of the estimated state are reduced by increasing the ensemble size. However, in EnKF, the bias error induced by the boundary conditions depends on the ensemble size, M ; with EnMKF, that bias error is eliminated independently from M . Therefore, EnMKF reduces the total bias error in comparison with the EnKF. To strengthen this conclusion, we use a synthetic data set similar to the experimental data set from Nottingham University (Figure 1). The synthetic data are generated by assuming R = 0.3106 m 2 K/W , ρC = 3.2 × 10 5 J/m 2 K, smooth boundary conditions, and the initial condition given in (17). We solve the heat equation and compute the heat flux at the boundaries for each minute. The temperature and heat- flux time series are then perturbed by Gaussian white noise. The resulting synthetic data are presented in Figure 19.
We apply the Kalman filter to the perturbed temperature series and obtain the filtered mean temperatures and their corresponding variances. Then, we apply EnMKF and EnKF to estimate the parameters R and ρC using the uniform priors: R ∼ U (0.28, 0.36) , ρC ∼ U (301000, 376000) .  Figure 20 shows the convergence of the sample mean of the estimated parameters using EnMKF and EnKF at time 2000 with respect to the ensemble size. The total bias error obtained by EnMKF is smaller and more stable than the error produced by the modified EnKF. For large ensemble sizes, both methods provide similar results.
In this case, the synthetic data have Gaussian noise. In the previous sections, the real noise is not Gaussian. Nevertheless, the results show that the influence of Gaussianity assumption is not very significant when the sequential framework is applied to this heat-transfer problem.

Summary and Conclusions
We studied the filtering problem for state observation system with random control vector and unknown static parameters. The control vectors may represent the boundary conditions or the source function of the underlying PDE model. By creating an artificial linear dynamic model for the control vector, we applied Kalman filter to obtain a Gaussian distribution of the random control vectors at each time step. The resulting distributions were then incorporated to generate a marginalized Kalman filter for the conditional state. The ensemble-marginalized Kalman filter (EnMKF) was derived using conditional probability, in particular, the law of total covariance. The main feature of EnMKF appeared in the prediction covariance which is approximated by the sample covariance of the augmented vector inflated by E Θ [Cov[B θ u k ]]. Another sample-based EnKF algorithm was also proposed where the prediction covariance is only approximated by the sample covariance.
To deal with high-dimensional joint state-parameter estimation problems, fully Bayesian techniques such as particle filters are not computationally affordable. The two introduced algorithms are not fully Bayesian; thus, they may handle nonlinear state-parameter systems and high-dimensional problems. EnKF usually requires additional adjustments in order to provide better approximations to the desired posterior distribution. EnMKF, on the other hand, completely avoids the ensemble-collapse phenomenon.
We applied both algorithms to estimate the thermal properties of a solid brick wall from experimental data. We showed that EnMKF provides better results than the modified EnKF. Due to the marginalization technique in EnMKF, we prevented the collapse of the parameters ensemble without artificial inflation. EnMKF had other advantages as well, such as a reduced heat-flux variance and more accurate fit of the measurements. We also considered a synthetic data example and compared the bias error from the parameters estimated using EnMKF and EnKF. The results confirmed that EnMKF provides a smaller bias error when the ensemble size is not very large. Finally, we proposed stopping criteria to reduce the time and cost required for real experiments, based on the estimated parameters reaching a stationary period.
While the numerical results are focused on the heat-transfer application, the EnMKF can be used for a wider PDE-constrained data assimilation problems in which the boundary conditions are subject to uncertainty; these include, for example, flood predictions via hydrological models [34].