# Monte Carlo for dynamic measurements

Name
Type
MATLAB
Date
08.02.2013
The propagation of measurement uncertainty using the GUM Supplement 2 Monte Carlo method requires an efficient implementation in the case of dynamic measurements in order to achieve high accuracies. The reason for that is the high dimensionality of the measurand in dynamic measurements, which requires a huge amount of computer memory in a standard implementation of the Monte Carlo method. Thus, a high accuracy with the standard implementation is possible only by using high performance computers. To this end, an efficient implementation has been developed jointly by PTB and NPL which enables high accuracy Monte Carlo on standard desktop computers. This software is an implementation of methods for the evaluation of dynamic measurement uncertainty, developed jointly at PTB (Germany) and NPL (UK).

S. Eichstädt, A. Link, P. Harris and C. Elster (2012). Efficient implementation of a Monte Carlo method for uncertainty evaluation in dynamic measurements. Metrologia 49, 401-410.

The software package contains the following methods

• BMC - batch Monte Carlo, a direct implementation of GUM-S1/S2
• UMC - update Monte Carlo, Monte Carlo using update formulae for mean, covariance and histograms
• SMC_F - sequential Monte Carlo using a digital filter difference equation
• SMC_SS - sequential Monte Carlo using a digital filter in state-space form

Usage of the methods is documented in terms of 4 examples, where example1 is the most easiest one and example4 the most complicated.
For information, suggestions and requests contact EmailSascha.

### Example

%% Input signal
% sampling interval
Ts = 1e-7;
% sampling frequency
Fs = 1/Ts;
% noise variance (zero covariance assumed)
sigma = 1e-3;
% signal
x = [zeros(1,200),ones(1,800),zeros(1,1000)];
x = x + randn(size(x))*sigma;
N = numel(x);
time = (0:N-1)*Ts;

%% measurement system (read from data file)
% IIR filter with coefficent vectors b (numerator) and a (denominator)
% and associated uncertainty/covariance matrix Uba
[b,a,Uba] = ReadFromFile('example1_filter.txt',5);

%% application of filter and propagation of uncertainty

% number of Monte Carlo trials
runs = 1e4;

% Batch Monte Carlo (only for small number of MC runs)
[y1,uy1,P1] = BMC(b,a,Uba,x,sigma,runs);
% Sequential Monte Carlo using difference equation
[y2,uy2,P2] = SMC_F(b,a,Uba,x,sigma,runs);
% Sequential Monte Carlo using state-space equation
[y3,uy3,P3] = SMC_SS(b,a,Uba,x,sigma,runs);
% Update formulae
[y4,uy4,P4] = UMC(b,a,Uba,x,sigma,runs);

DISCLAIMER

This software was developed at Physikalisch-Technische Bundesanstalt (PTB). The software is made available "as is" free of cost. PTB assumes no responsibility whatsoever for its use by other parties, and makes no guarantees, expressed or implied, about its quality, reliability, safety, suitability or any other characteristic. In no event will PTB be liable for any direct, indirect or consequential damage arising in connection with the use of this software.
x
This website uses cookies occasionally to provide you with the best web browsing experience. However, no web-analytics tracking based on cookies is employed here.