Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

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 of the Hong Kong Special Administrative Region Standards and Calibration Laboratory 36/F Immigration Tower, 7 Gloucester Road, Wanchai, Hong Kong Phone: (852) , Fax: (852) , Authors: C.M.Tsui, Y.K.Yan, H.W. Li The Government of the Hong Kong Special Administrative Region Standards and Calibration

2 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

3 X3 Y1 = X1 + X3 Y2 = X2 + X3 X1 X2 Measurement Model ? Y1 Y2 0 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.

4 Case 3 : Complex Number Measurement Model n A simplified measurement model for the effective output voltage reflection coefficient ( ) of a power splitter. n The 3-port S-parameter and are complex quantities.

5 A Short Demonstration First Dont Worry If You Dont Know What I am Doing I Will Explain Shortly

6 What happens if we change the measurement model from this : Y1 = X1 + X3 Y2 = X2 + X3 to that : Y1 = X1 + X3 Y2 = X2 - X3 Lets Try Some Variation

7 GUM and the Supplements n In 1993, the GUM was released. It defined the GUM Uncertainty Framework (GUF) for evaluation of measurement uncertainties. n 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. n 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.

8 GUM and the Supplements n The GUM and Supplement 1 mainly deal with models having any number of input but only one output quantity. n 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. n 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.

9 The SCL software tools (1) n 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) n The software tools, written in Visual C++ and Visual Basic, are tightly integrated with Microsoft Excel which serves as front-end user interface. n Computational intensive routines that require faster execution speed were developed in Visual C++ and compiled into a Dynamic Link Library (DLL).

10 n The SCL software tools include two parts that can be used separately. n Simulator n User Defined Function n 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. n 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)

11 The 3 Stages of Uncertainty Evaluation n Formulation –Define input X and output Y. –Establish mathematical relationship between X and Y (i.e. the measurement model) n Propagation –Obtain PDF of Y from X through the measurement model. n Summarizing –The expectation, covariance matrix and coverage region of Y are obtained from PDF of Y.

12 Formulation (setting up measurement model) n Section 9.2 of Supplement 2 describes the following additive measurement model. Y1 = X1 + X3 Y2 = 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

13 Formulation (Setting up Input Quantities and Assigning PDF) The following PDF types are supported: CTP - curvilinear trapezoid; E - exponential; G - Gaussian; R - rectangular; TP - trapezoidal; TR - triangular; T - student-t; U - arc sine.

14 n 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

15 n the input quantities are characterized by : –a vector representing the estimates of the input quantities x = (x 1, x N ) T –a covariance matrix U x containing the covariance of the input quantities. n Measurement model denoted by Y = f(X), n Estimate y = f(x). n Covariance matrix U y = C x U x C x T n C x 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)

16 n 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. n 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)

17 Summarizing Histogram of PDF for an output quantity. Contour of the joint PDF for the output quantities

18 n It is not easy to determine the multidimensional coverage regions for vector output quantities. n Supplement 2 considers only two types of coverage regions for multivariate cases: hyper-ellipse and hyper- rectangle. n 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)

19 Case 3 : Complex Number Measurement Model n A simplified measurement model for the effective output voltage reflection coefficient ( ) of a power splitter. n The 3-port S-parameter and are complex quantities.

20 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 calledComplex (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 Double End Type

21 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 Complex S22.r = x(1) * Cos(x(2)) S22.i = x(1) * Sin(x(2)) From now on you can treat S22 as a single item.

22 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.i End Function The following is an example of using the cadd function. R = P+Q = (1 – i)+(3 + 2i) = 4 + I Dim P As Complex, Q As Complex, R As Complex P.r = 1 : P.i = -1 Q.r = 3 : Q.i = 2 R = cadd(P, Q)

23 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.r End Function

24 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) / D End Function

25 Representing Complex Number Equation n 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))

26 Type Complex r As Double i As Double End Type Public 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 phase Dim S22 As Complex, S12 As Complex, S23 As Complex, S13 As Complex Dim VRC As Complex S22.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.i End Sub Putting All Together

27 The Input Quantities for Case 3 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.

28 n 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. n It is recommended that the output quantities of the model should be in terms of real and imaginary parts. n The reason is that in the summarizing stage of MCM, statistical analysis is applied to the MCM trials. n 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)

29 n Potential problems in statistical analysis on polar form n The transformation between rectangular and polar form is non-linear. n The real and imaginary axes extend to plus and minus infinity while the magnitude is always non-negative. n The phase is cyclical in nature. n To avoid these problems, the output quantities of the measurement model should be in terms of real and imaginary parts. n Results should only be converted into polar form after statistical analysis. Some Considerations in Encoding Complex Quantity Models (2)

30 n 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. n 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. n 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

31 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 function sim_mode : Enter 1 to select adaptive simulation mode. Enter 2 to select fixed sample size simulation mode sim_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

32 Computed by MCMComputed by GUF indexReturn parameterindexReturn parameter 1expectation of measurand 1101expectation of measurand 1 2standard uncertainty of measurand 1 102standard uncertainty of measurand 1 3low boundary of 95% confidence interval of measurand 1 103effective degree of freedom of measurand 1 4high boundary of 95% confidence interval of measurand 1 104coverage factor of measurand 1 11expectation of measurand 2105expanded uncertainty of measurand 1 12standard uncertainty of measurand 2 111expectation of measurand 2 13low boundary of 95% confidence interval of measurand 2 112standard uncertainty of measurand 2 14high boundary of 95% confidence interval of measurand 2 113effective degree of freedom of measurand 2 21kp114coverage factor of measurand 2 22kq115expanded uncertainty of measurand 2 23correlation coefficient121correlation coefficient User Defined Function


Download ppt "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."

Similar presentations


Ads by Google