Top Banner
Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government of the Hong Kong Special Administrative Region Standards and Calibration Laboratory 36/F Immigration Tower, 7 Gloucester Road, Wanchai, Hong Kong Phone: (852) 2829 4850, Fax: (852) 2824 1302, Email: [email protected] Authors: C.M.Tsui, Y.K.Yan, H.W. Li The Government of the Hong Kong Special Administrative Region Standards and Calibration Laboratory
32

Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Mar 31, 2015

Download

Documents

Zachary Coghill
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Software Tools for Evaluation of Measurement Models for

Complex-valued Quantities in Accordance with Supplement 2 to the GUM

Speaker: C.M.TsuiThe Government of the Hong Kong Special Administrative Region

Standards and Calibration Laboratory36/F Immigration Tower, 7 Gloucester Road, Wanchai, Hong Kong

Phone: (852) 2829 4850, Fax: (852) 2824 1302, Email: [email protected]: C.M.Tsui, Y.K.Yan, H.W. Li

The Government of the Hong Kong Special Administrative RegionStandards and Calibration Laboratory

Page 2: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Y1 = X1 + X3

Y2 = X2 + X3

X1

X2

X3

Multivariate Measurement Model

?Y1

Y2

What are the standard uncertainties of output

quantities Y1 and Y2 ? And what is the correlation

between them ?

Input quantities X1, X2, X3 are independent and have Gaussian distribution with mean = 0 and standard uncertainties of 1.

Case 1 : A Simple Case First

Page 3: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

X3

Y1 = X1 + X3

Y2 = X2 + X3

X1

X2

Measurement Model

?Y1

Y2

0 3 √3

Case 2 : A little bit more complicated

Input quantities X1, X2 remain the same. X3 now has rectangular distribution with

mean = 0 and standard uncertainty of 3.

Page 4: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Case 3 : Complex Number Measurement Model

A simplified measurement model for the effective output voltage reflection coefficient () of a power splitter.

The 3-port S-parameter and are complex

quantities.

13

231222 S

SSS

Page 5: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

A Short Demonstration First

Don’t Worry If You Don’t Know What I am Doing

I Will Explain Shortly

Page 6: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

What happens if we change the measurement model from this :

Y1 = X1 + X3Y2 = X2 + X3

to that :

Y1 = X1 + X3Y2 = X2 - X3

Let’s Try Some Variation

Page 7: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

GUM and the Supplements

In 1993, the GUM was released. It defined the GUM Uncertainty Framework (GUF) for evaluation of measurement uncertainties.

There are limitations in the application of GUF. In 2008, Supplement 1 was published. It concerned with the propagation of probability distributions through a measurement model.

The conditions for valid application of the GUF are described in details in sections 5.7 and 5.8 of Supplement 1. When these conditions cannot be met, a Monte Carlo method (MCM) should be used.

Page 8: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

GUM and the Supplements

The GUM and Supplement 1 mainly deal with models having any number of input but only one output quantity.

In many real world measurement systems, especially when complex numbers are involved, there are more than 1 output. The output may be correlated. The coverage region is multidimensional and much more complicated than the univariate cases.

The GUM and Supplement 1 are inadequate for measurement models with multiple outputs. The new Supplement 2, deals with models having any number of input quantities and any number of output quantities.

Page 9: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

The SCL software tools (1)

The SCL software tools support evaluation of complex valued measurement models in accordance with Supplement 2. Users only need to : encode the measurement model as a Visual

Basic subroutine specify parameters of uncertainty

components, such as estimates, standard uncertainties and probability distribution function (PDF)

The software tools, written in Visual C++ and Visual Basic, are tightly integrated with Microsoft Excel which serves as front-end user interface.

Computational intensive routines that require faster execution speed were developed in Visual C++ and compiled into a Dynamic Link Library (DLL).

Page 10: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

The SCL software tools include two parts that can be used separately. Simulator User Defined Function

The simulator enable the users to vary the parameters of input quantities and the measurement model interactively. Users can experiment with different configurations of the measurement system and see the effects on the measurement uncertainties.

The user-defined function can be embedded in any Microsoft Excel worksheet like an ordinary function for GUF or MCM computation.

The SCL software tools (2)

Page 11: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

The 3 Stages of Uncertainty Evaluation

Formulation– Define input X and output Y. – Establish mathematical relationship between X

and Y (i.e. the measurement model) Propagation

– Obtain PDF of Y from X through the measurement model.

Summarizing– The expectation, covariance matrix and

coverage region of Y are obtained from PDF of Y.

Page 12: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Formulation (setting up measurement model)

Section 9.2 of Supplement 2 describes the following additive measurement model.Y1 = X1 + X3Y2 = X2 + X3

Public Static Sub model(x() As Double, y() As Double) y(1) = x(1) + x(3) y(2) = x(2) + x(3)

End Sub

Page 13: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Formulation (Setting up Input Quantities and Assigning PDF)

PDF* valueG, T : std.devR,U,TR : semi-rangeCTP, TP : a

T : DOFCTP, TP : b

TP : b

CTP : d

X1 G 0.000E+00 1.000E+00

X2 T 0.000E+00 1.000E+00 5

X3 R 0.000E+00 1.000E+00

X4 U 0.000E+00 1.000E+00

X5 TR 0.000E+00 1.000E+00

X6 CTP -1.000E+00 1 0.3

X7 TP -1.000E+00 1 0.5

X8 E 1.000E+00

X9

X10The following PDF types are supported: CTP - curvilinear trapezoid; E - exponential; G - Gaussian; R - rectangular; TP - trapezoidal; TR - triangular; T - student-t; U - arc sine.

Page 14: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

3 ways to propagate the distributions.

Analytical method (impractical for most real world measurement systems)

First order Taylor series approximation of the measurement model (GUF)

Numerical method (MCM)

The SCL software tools support the second and third methods.

Propagation

Page 15: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

the input quantities are characterized by :

– a vector representing the estimates of the input quantities x = (x1, xN)T

– a covariance matrix Ux containing the covariance of the input quantities.

Measurement model denoted by Y = f(X), Estimate y = f(x). Covariance matrix Uy = CxUxCx

T

Cx is the sensitivity matrix. The entry at row i and column j of Cx is given by the partial derivative fi/xj.

Propagation (First order Taylor series approximation)

Page 16: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

The idea of MCM is to make large number of draws from the PDF of the input quantities and to derive the output quantities for each draw. The larger is the number of draws, the more reliable are the results. The trade-off is a longer computation time.

There are two ways to select the number of Monte Carlo trials. A fixed number can be chosen beforehand. Alternatively an adaptive algorithm may be used to determine the number of trials on-the-fly based on the stability of the simulated output.

Propagation (MCM)

Page 17: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Summarizing

0.000

0.020

0.040

0.060

0.080

0.100

0.120

0.140

-10 -5 0 5 10-8

-6

-4

-2

0

2

4

6

8

-8 -6 -4 -2 0 2 4 6 8

Y1

Y2

Histogram of PDF for an output quantity.

Contour of the joint PDF for the output

quantities

Method y1 y2 u(y1) u(y2) r(y1, y2)

MCM -0.004 0.001 3.161 3.161 0.900

GUF 0.000 0.000 3.162 3.162 0.900

Covariance matrix of output

obtained by MCM

Covariance matrix of output

obtained by GUF

9.995 8.996 10.000 9.000

8.996 9.995 9.000 10.000

Page 18: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

It is not easy to determine the multidimensional coverage regions for vector output quantities.

Supplement 2 considers only two types of coverage regions for multivariate cases: hyper-ellipse and hyper-rectangle.

They are characterized by two sets of quantities: the covariance matrix for the output quantities and a scalar parameter (kp for hyper-ellipse and kq for hyper-rectangle) which determines the volume under the PDF corresponding to the coverage probability.

Summarizing (coverage region)

Page 19: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Case 3 : Complex Number Measurement Model

A simplified measurement model for the effective output voltage reflection coefficient () of a power splitter.

The 3-port S-parameter and are complex

quantities.

13

231222 S

SSS

Page 20: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Visual Basic User Defined Data Type

It is quite easy to represent complex numbers in Visual Basic by means of the user defined data type.

The following declares a user defined data type called “Complex” (actually you can give it any name you like), variable r is the real part and i is the imaginary part

Type Complex r As Double i As DoubleEnd Type

Page 21: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Declare a Variable as Complex Quantity

Suppose the variable x(1) stores the magnitude of a complex number and x(2) stores the phase.

We can declare a variable S22 as complex data type and initialize its real and imaginary parts as follows

Dim S22 As ComplexS22.r = x(1) * Cos(x(2))S22.i = x(1) * Sin(x(2))

From now on you can treat S22 as a single item.

Page 22: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Function to add complex numbers

Next, we can define function to manipulate complex numbers. The following is a function to add two complex numbers

Public Function cadd(a As Complex, b As Complex) As Complex

cadd.r = a.r + b.r cadd.i = a.i + b.iEnd Function The following is an example of using the cadd function. R = P+Q = (1 – i)+(3 + 2i) = 4 + IDim P As Complex, Q As Complex, R As ComplexP.r = 1 : P.i = -1Q.r = 3 : Q.i = 2R = cadd(P, Q)

Page 23: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Function to multiply complex numbers

From high school algebra, for complex number multiplication, we have(p + qi) (x + yi) = (px-qy) + (qx+py)i

Public Function cmul(a As Complex, b As Complex) As Complex

cmul.r = a.r * b.r - a.i * b.i cmul.i = a.r * b.i + a.i * b.rEnd Function 

Page 24: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Function to divide complex numbers

 For complex number division, we have

Public Function cdiv(a As Complex, b As Complex) As Complex Dim D As Double D = b.r * b.r + b.i * b.i cdiv.r = (a.r * b.r + a.i * b.i) / D cdiv.i = (a.i * b.r - a.r * b.i) / DEnd Function

i)y(x

py)(qx

)y(x

qy)(px

yi)(x

qi)(p2222

Page 25: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Representing Complex Number Equation

Using the above functions, the following complex number equation can be represented by a single Visual Basic statement

VRC = cminus(S22, cdiv(cmul(S12, S23), S13))

13

231222 S

SSS

Page 26: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Type Complex r As Double i As DoubleEnd TypePublic Static Sub model(x() As Double, y() As Double)' X(1) : s22 magnitude X(2) : s22 phase' X(3) : s12 magnitude X(4) : s12 phase' X(5) : s23 magnitude X(6) : s23 phase' X(7) : s13 magnitude X(8) : s13 phaseDim S22 As Complex, S12 As Complex, S23 As Complex, S13 As ComplexDim VRC As ComplexS22.r = x(1) * Cos(x(2)): S22.i = x(1) * Sin(x(2))S12.r = x(3) * Cos(x(4)): S12.i = x(3) * Sin(x(4))S23.r = x(5) * Cos(x(6)): S23.i = x(5) * Sin(x(6))S13.r = x(7) * Cos(x(8)): S13.i = x(7) * Sin(x(8))VRC = cminus(S22, cdiv(cmul(S12, S23), S13))y(1) = VRC.r: y(2) = VRC.iEnd Sub

Putting All Together

Page 27: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

The Input Quantities for Case 3

PDF* value

G, T : std.dev

R,U,TR : semi-range

CTP, TP : a

s22 magnitude G 0.24776 0.00337

s22 phase G 4.88683 0.01392

s12 magnitude G 0.49935 0.00340

s12 phase G 4.78595 0.00835

s23 magnitude G 0.24971 0.00170

s23 phase G 4.85989 0.00842

s13 magnitude G 0.49952 0.00340

s13 phase G 4.79054 0.00835

Many people think it will be more appropriate to treat the magnitude and phase, rather than the real and imaginary parts, of S-parameter measured by a network analyzer as independent and use them as input quantities to a measurement model.

Page 28: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

There are commonly two ways to represent a complex quantity: either in terms of its real and imaginary parts or in polar form by its magnitude and phase.

It is recommended that the output quantities of the model should be in terms of real and imaginary parts.

The reason is that in the summarizing stage of MCM, statistical analysis is applied to the MCM trials.

It is known that statistical analysis on complex quantities will produce different results depending on whether the inputs to the statistical analysis are represented in polar form or not.

Some Considerations in Encoding Complex Quantity

Models (1)

Page 29: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Potential problems in statistical analysis on polar form The transformation between rectangular and

polar form is non-linear. The real and imaginary axes extend to plus and

minus infinity while the magnitude is always non-negative.

The phase is cyclical in nature. To avoid these problems, the output quantities of

the measurement model should be in terms of real and imaginary parts.

Results should only be converted into polar form after statistical analysis.

Some Considerations in Encoding Complex Quantity

Models (2)

Page 30: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

The second part of the SCL software tools is an Excel user-defined function (UDF) that can be embedded in any Excel worksheet for GUF or MCM computation.

An Excel UDF behaves just like other Excel built-in functions. It takes arguments and returns a value. An Excel UDF will be executed whenever any value in its argument list changes. Re-calculation is automatic.

A drawback of Excel UDF is that if it takes a long time to execute, such as when running MCM for a large number of trials on a complicated measurement model, Microsoft Excel will appear frozen.

User Defined Function

Page 31: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

The syntax of the UDF is=gum2(range, index, sim_mode, sim_par, conf_type, model_index)

range : To point to the table of input quantities.index : To specify the return parameter of the functionsim_mode : Enter 1 to select adaptive simulation mode. Enter 2 to select fixed sample size simulation modesim_par : Enter number of significant digits (1 or 2) for adaptive simulation mode. Enter the number of trials for fixed sample size simulation mode.  conf_type : Optional parameter. Enter 1 to select symmetrical coverage interval type. Enter 2 to select shortest coverage interval type. This is for compatibility with Supplement 1 to the GUM.model_index : Optional parameter for future expansion.

User Defined Function

Page 32: Software Tools for Evaluation of Measurement Models for Complex-valued Quantities in Accordance with Supplement 2 to the GUM Speaker: C.M.Tsui The Government.

Computed by MCM Computed by GUFindex Return parameter inde

xReturn parameter

1 expectation of measurand 1 101 expectation of measurand 12 standard uncertainty of

measurand 1102 standard uncertainty of

measurand 13 low boundary of 95%

confidence interval of measurand 1

103 effective degree of freedom of measurand 1

4 high boundary of 95% confidence interval of measurand 1

104 coverage factor of measurand 1

11 expectation of measurand 2 105 expanded uncertainty of measurand 1

12 standard uncertainty of measurand 2

111 expectation of measurand 2

13 low boundary of 95% confidence interval of measurand 2

112 standard uncertainty of measurand 2

14 high boundary of 95% confidence interval of measurand 2

113 effective degree of freedom of measurand 2

21 kp 114 coverage factor of measurand 222 kq 115 expanded uncertainty of

measurand 223 correlation coefficient 121 correlation coefficient

User Defined Function