Presentation is loading. Please wait.

Presentation is loading. Please wait.

FITTING PROCEDURE LABVIEW FITTING INSTRUMENTS class of “Experimental Methods of Physics” Mikhail Yurov Kyungpook National University March 28 th, 2005.

Similar presentations


Presentation on theme: "FITTING PROCEDURE LABVIEW FITTING INSTRUMENTS class of “Experimental Methods of Physics” Mikhail Yurov Kyungpook National University March 28 th, 2005."— Presentation transcript:

1 FITTING PROCEDURE LABVIEW FITTING INSTRUMENTS class of “Experimental Methods of Physics” Mikhail Yurov Kyungpook National University March 28 th, 2005

2 Contents 1.Curve fitting. Introduction  The Least Squares Method  Linear Fits. Straight Line  Linear Fits when both Variables have Errors  Nonlinear Fits 2.LabView. Introduction  Programming with LabView  LabView fitting instruments  Example of fitting program

3 Curve fitting. Introduction The functional relation between two ore more variables describing a physical process, y=f(x 1,x 2,…), is investigated by measuring the value of y for various of x 1,x 2,…. It is then desired to find parameters of a theoretical curve which best describe these points. For example, to determine the lifetime of a certain radioactive source, measurements of the count rates, N 1,N 2,…,N n, at various times, t 1,t 2,…,t n, could be made and the data fitted to the expression N(t)=N 0 exp(-t/τ) The method most useful for this is the method of least squares.

4 The Least Squares Method Suppose that measurements at n points, x i, are made of the variable y i with an error σ i (i=1,2,…,n), and that is desired to fit a function f(x;a 1,a 2,…,a m ) to these data where a 1, a 2,…, a m are unknown parameters to be determined. The method of least squares states that the best values of a j are those for which the sum is a minimum. This is just the sum of the squared deviations of the data points from the curve f(x i ) weighted by the respective errors on y i.

5 To find the values of a j, one must solve the system of equations Depending on the function f(x) this equation may or may not yield on analytical solution. In general, numerical methods requiring a computer must be used to minimize S. covariance or error matrix Assuming we have the best values for a j, it is necessary to estimate the errors on the parameters. We form the so-called covariance or error matrix, V ij,

6 Linear Fits. Straight Line Consider the example of fitting a straight line to a set of data points. Thus the function is y=ax+b. According to our formula we have to minimize Where the summation extends over all the n data points. After differentiating we obtain This leads to the solution where

7 The errors on a and b. Forming the inverse error matrix, we then have where Inverting the matrix, we find To complete the process, it is necessary to also have an idea of the quality of the fit. reduced chi-square Do the data, in fact, correspond to the function f(x) we have assumed? A quick and easy test is to form the reduced chi-square Which should be close to 1 for a good fit

8 Linear Fits when both Variables have Errors In previous, the independent variables x i were completely free of errors. In cases where the errors on both variables are comparable ignoring the errors on x leads to incorrect parameters and an underestimation of their errors. For these problems the effective variance method may be used. The method consists of simply replacing the variance Where σ x and σ y are the errors on x and y respectively. Since the derivative is normally a function of the parameters a j, S is nonlinear and numerical methods must be used to minimize S

9 Nonlinear Fits Nonlinear fits generally require a numerical procedure for minimizing S. Number of methods have been developed for this purpose. However, no one method can be said to be applicable to all functions. Numerical minimization methods are generally iterative in nature – repeated calculations are made while varying the parameters in some way, until the desired minimum is reached. The criteria for selecting a method are speed and stability against divergence. The methods can be classified into two board categories: grid searches and gradient methods.

10 The most elementary procedure for grid methods is to form a grid of equally spaced points in the variables of interest and evaluate the function at each of these points. The size of the grid step, Δx, depends on accuracy desired. The elementary grid method is intrinsically stable but it is quite inefficient and time consuming. Gradient methods are techniques which make use of the derivatives of the function to be minimized. One obvious use of the derivatives is to serve as guides pointing in the direction of decreasing F. The simplex method for function minimization

11 LabView. Introduction LabVIEW is a graphical programming language that uses icons instead of lines of text to create applications. In contrast to text-based programming languages, where instructions determine program execution, LabVIEW uses dataflow programming, where the flow of data determines execution.

12 LabVIEW programs are called virtual instruments, or VIs, because their appearance and operation imitate physical instruments, such as oscilloscopes and multimeters. LabVIEW contains a comprehensive set of tools for acquiring, analyzing, displaying, and storing data.

13 In LabVIEW, it is possible to build a user interface, or front panel, with controls and indicators. Controls are knobs, push buttons, dials, and other input devices. Indicators are graphs, LEDs, and other displays. After building the user interface, it is possible to add code using VIs and structures to control the front panel objects. The block diagram contains this code.

14 Programming with LabView The terminals represent the data type of the control or indicator. Terminals are entry and exit ports that exchange information between the front panel and block diagram. Data entered into the front panel controls enter the block diagram through the control terminals. The data then enter the Add and Subtract functions. When the Add and Subtract functions complete their internal calculations, they produce new data values. The data flow to the indicator terminals, where they exit the block diagram, reenter the front panel, and appear in front panel indicators

15 Nodes are objects on the block diagram that have inputs and/or outputs and perform operations when a VI runs. They are analogous to statements, operators, functions, and subroutines in text-based programming languages. Data are transfer among block diagram objects through wires. Each wire has a single data source, Wires are different colors, styles, and thicknesses, depending on their data types. Structures are graphical representations of the loops and case statements of text-based programming languages. Structures are use on the block diagram to repeat blocks of code and to execute code conditionally.

16

17 LabVIEW includes VIs and functions to help in building specific applications, such as data acquisition VIs and functions, VIs that access other VIs, and VIs that communicate with other applications.

18 LabView fitting instruments Curve Fitting is only a part of a big branch of Mathematics in LabView. Mathematics covers Curve Fitting Probability and Statistics Linear Algebra Optimization Polynomials The technique of curve fitting analysis extracts a set of curve parameters or coefficients from a data set to obtain a functional description of the data set. The Curve Fitting VIs automatically set up and solve the Jacobian system and return the set of coefficients that best describes the data set.

19 Figure shows the block diagram of a VI that uses the Linear Fit VI to fit a line to a set of data points.

20 The practical applications of curve fitting include the following applications: Removing measurement noise Filling in missing data points, such as when one or more measurements are missing or improperly recorded Interpolating, which is estimating data between data points, such as if the time between measurements is not small enough Extrapolating, which is estimating data beyond data points, such as looking for data values before or after a measurement Differentiating digital data, such as finding the derivative of the data points by modeling the discrete data with a polynomial and differentiating the resulting polynomial equation

21 LabView contains a built-in Curve Fitting VIs which make it easier to create fitting program. For the Curve Fitting VIs, the input sequences Y and X represent the data set y(x). Some Curve Fitting VIs return only the coefficients for the curve that best describe the input data while other Curve Fitting VIs return the fitted curve. Using the VIs that return only coefficients allows to further manipulate the data. The VIs that return the fitted curve also return the coefficients and the mean squared error (MSE).

22 1.Linear Fit.VI 2. Linear Fit coefficients.VI 3.Exponential.VI 4.Exponential Fit coefficients.VI 5.General Polynomial Fit.VI 6.General LS Linear Fit.VI 7.Non-linear Lev-Mar Fit.VI 8.Levenberg Marquardt.VI 9.Polynomial Interpolation.VI 10.Rational Interpolation.VI 11.Spline Interpolant.VI 12.Spline Interpolation.VI 13.Curve Fitting.VI LabView Instruments palette for Fitting

23 Number 13.Curve Fitting.VI is the most general case of fitting Vi

24 Example of fitting program This Vi’s purpose is to measure the 3 He polarization signal during the NMR sweep. Up to now this VI is uder development

25 The Block Diagram of Extract Polarization VI

26 Examples of test results performed by VI for different parameters

27

28 References L.Lyons, “Statistics for nuclear and particle physics”, Cambridge (1985) William R.Leo “Techniques for Nuclear and Particle Physics Experiments”, Springer-Verlag Berlin Heidelberg (1987) LabView User Manual (www.ni.com)


Download ppt "FITTING PROCEDURE LABVIEW FITTING INSTRUMENTS class of “Experimental Methods of Physics” Mikhail Yurov Kyungpook National University March 28 th, 2005."

Similar presentations


Ads by Google