FITTING DATA

   

ENTERING YOUR DATA 

ACCESSING THE FARADAY FITTER 

USING THE FARADAY FITTER

 

 

For many cases when you need to fit data to a function (linear, quadratic, etc.) the fitter in DataStudio is fine, and very simple to use. However this fitter does not correctly include the effect of errors and you will want to use the far more sophisticated fitter on the main lab computer, Faraday. Instructions on how to access and use this fitter follow.

Details of the use of the Faraday Fitter and useful Tips are contained in the relevant pages of the Laboratory Manual. You will find the fitter MUCH easier to use if you have these pages in front of you. 

If you want to enter, read, and edit your data files from home, or to run DataStudio at home, make sure you read the Computing Use section.

 

ENTERING YOUR DATA ...

1. .... from DataStudio

Either - A. You have taken the data using DataStudio. In this case, drag the Table icon on to a free area on the screen. If the data that you want does not appear in the table, click on the Data menu on the toolbar to select the run you want, or drag the appropriate icon from the Data menu at the left of the screen. If you want to edit the data at this stage - though since you do have to edit it in Notepad before it goes to Faraday, you might as well wait till that step - you can do so in DataStudio by clicking on the the pencil icon on the Table toolbar (see B. below for details).

Or - B. You want to fit data that was not taken directly in DataStudio. In this case, drag the Table icon on to a free area on the screen. Using the large red X on the Table toolbar remove any data that appears there. Click on the pencil icon on the toolbar. The title of the Table will change to Editable Data; the first row will be highlighted and you can type in your data. The right button has useful items to delete unwanted rows, etc.

THEN you need to save the file for use in Faraday's fitter Use the Export Data option in the pull-down File menu. You will then be asked to choose the data you want to export - whatever table you have highlighted will be exported in text ( .txt ) form. You then have to choose where to save the exported data. You can leave the files on your local computer or drag them into your Faraday directory (named x****). 

In both of these cases you have to delete the first two lines of the file - the title of the table and the names of the variables given by DataStudio - since Faraday expects only numerical data in this file. This is easiest done by going to the desktop, finding the file, double clicking on it to open it in Notepad, deleting the first two lines and re-saving.

2. ... from Excel

As in 1B, suppose you want to fit data that was not taken directly in DataStudio. In this option you enter your data in Excel. The file must contain only numbers (no heading) with each variable in its own column - e.g. x, dx, y, dy . Save it as a .txt file (tab or space delimited) in the local computer you are using or in your directory in Faraday. If you want to name the variables (optional), create another .txt file with the variables in the same order as the data file, their names in the first row. Save this file, again in .txt format.

3. ... directly to Faraday

This is the easiest option for data that has not been taken directly in DataStudio. Click on the Faraday X terminal icon on the desktop (or log on to the computers in MP257, MP125 or MP126). Follow the menu to find the item create ; enter your data following the instructions (data goes in columns). Then you can go directly to the fitter (use themenu item labelledfit !).

ACCESSING THE FARADAY FITTER

You can access Faraday's fitter by telnet from your home computer; click on Start on your desktop, type in telnet faraday.physics.utoronto.ca. Login to get the main menu. This is a good option if you want to massage your data before fitting. If, however, all you want to do is fit the data, the access through the Web is more convenient (see below).

Log on to the Web. Follow the links from the Department of Physics home page to UPSCALE, then to Data. In the "Data Analysis Tools" click on Linear Fit. (Although the computer has a data-plotting utility called graph, if you wish to plot your data points and nothing more, our advice to you is don't do it on the computer. You will learn much more about what your data looks like and how your experiment is behaving if you plot by hand - which is usually much easier in any case!) You will be asked for your login name and password. Click on the appropriate link to find the file with your variable names (optional) and your data (use the Browse button to be sure of the file address!) then click on Submit. (N.B. a small bug in the programme sometimes means that you will get an erroneous message telling you that the selected file contains no data. If that happens, click the RIGHT button on the mouse and select Open Frame in New Window on the pop-up menu.) The set-up window should then appear. When entering the data to the fitter, remember that whatever you want to go on the y-axis is called the Dependent Variable.

USING THE FARADAY FITTER

(This section has been reprinted for your convenience from the Laboratory Manual).

By default the Faraday fitter fits to a polynomial in the independent variable where the independent variable may be any legitimate Mathematica expression involving the variables in addition to the simple variables you have entered. To use the fitter to fit to other linear models such as Fourier Series or Bessel Functions etc. see "Advanced Options" in the Fitter.

Fitting a Curve (Line) To Your Data

The lab computer provides an "objective" procedure for giving a best fit of a straight line or a specified polynomial to your data, along with correctly calculated error estimates on that fit. It uses the programme called Mathematica. Basically the computer calculates the square of the distance between your data points and the curve it is trying to find; it then adjusts the constants of the polynomial representing the curve until the sum of these squares is a minimum. It gives you the values of the constants so found, along with their errors (one standard error). In addition it draws a graph which shows your data points and the fitted curve. If the errors in your data points are large enough to be visible on the graph, the computer also draws two lines which correspond to the "maximum" and "minimum" lines which would appear in a hand-drawn graph; however the computer's lines are correctly calculated to be ± one standard deviation from the fitted line. The graph itself is an important visual aid to determine the reasonableness of your fit.

The programme is menu-driven, and mostly self-explanatory.

READ THE FOLLOWING TIPS BEFORE YOU USE THE COMPUTER FOR THE FIRST TIME

they will save you huge amounts of time!!

Your variable names should be short mnemonics, in lower case; e.g. s,t,vc etc., rather than distance, time, voltage (the less typing, the less chance of error; Mathematica functions start with an upper case letter).

Always enter your raw data, just as you have taken it (the computer will do any calculations on it that you need - see below).

As long as the errors on your data are either constants (e.g. 0.005, 0.3, etc.) or functions of the variables (e.g. 0.005/t2, 2s/t, etc.) you do NOT need to enter them (you can enter them at the time of setting up the graph). Otherwise, however, you need to define a variable name for your errors and enter the numerical value for each point.

The fit window has a table which contains the variable names you have defined; alternatively it will provide the names var1 and var2. As far as the computer is concerned, the dependent variable will appear on the y-axis and the independent variable on the x-axis (these don’t necessarily have anything to do with which variable was dependent or independent in your actual experiment); make your own choice depending on how you want your final graph to look. You also need to define the errors in these quantities. If you want to plot the variables and errors just as they were defined, choose the appropriate "buttons"; if you want to manipulate the data somewhat (or, e.g. insert a constant value for an error) choose the button which reads An expression - you can then enter a constant value or a formula to calculate the variable you want to use.

Notes on calculations using Mathematica.

Some of the grammar you may need when you calculate mathematical expressions involving your variables is listed in the table opposite; (you can probably guess at any others you may need - see also "Mathematica", listed in References).

Algebraic Expression Mathematica Expression
xy x*y OR x  y (be safe -  use x*y)
1/x 1/x
xn x^n
Square root of x Sqrt[x]
ln(x) Log[x]
ex Exp[x]
log10(x) Log[10,x]
cos(x)  Cos[x]
sin-1(x) ArcSin[x]
|x| Abs[x]

 

N.B. Use "(" and ")" as parenthesis in your expressions; "[" and "]" are reserved for the arguments of Mathematica functions. Angles are measured in radians.

To all data, the computer fits a general polynomial which has the form:

y = A(0) + A(1)x + A(2)x2 + A(3)x3 + ...

You need to specify which of the terms in the polynomial are relevant to the fit of your data; this is done by inserting the required powers (separated by commas or spaces) in the box provided or by selecting the appropriate "buttons" in the window from the set:

0

1

2

3

4

5

6

7

8

9

to choose one or more of the coefficients

A(0)

A(1)

A(2)

A(3)

A(4)

A(5)

A(6)

A(7)

A(8)

A(9)

(Often you will be specifying 0 and 1, which is a fit to the straight line y = A(0) + A(1)x with A(1) = slope and A(0) = intercept on the y axis). Follow the on-screen menu to try another fit, or re-plot the graph with a variety of options, or print the graph on the lab printer.

Other Useful Features of the Faraday Analysis Programmes.

If you have entered your data directly into Faraday (see section above), the following features are available.

Note: When you use a menu item, you need usually type in only enough letters to uniquely identify the word; most of the time only the first letter is sufficient.

A) Once you have used create to enter your data, you can always look at it by choosing the menu item show which is available on the data and the analyse menus (the latter also gives you the option to print the data file).

B) There are several ways in which you can change your data after you have created it. You should almost never have to type in the full set of data again, since these programmes will make almost all the corrections you want.

i) edit. This is the simplest of these programmes, and should be used only for simple fixes. You can move around your data file, deleting, changing and adding data. To exit edit click on File (top left corner of the screen) to pull down the menu there. Choose the End option; you will then be prompted to Save before exiting. CAUTION! Occasionally you will get a message which reads Wrong columns or non-numbers found ; this often means that you have left the cursor sitting on a new line instead of exactly at the end of your data. Move the cursor to the end of the file and use the Backspace button to delete any extra spaces or line returns till the cursor is sitting immediately after the last digit of your last data point. Then try exiting again.

ii) massage. You will find this programme in the analyse menu. Clicking on massage will lead you to another menu with several options. The two which you will find most useful are now discussed.

recalc. This option presents you with the opportunity to add variables to your data set which are either constants or functions of the ones you have already defined. For example, in the Boyle’s Law experiment you may mistakenly have added mm of mercury (from the barometer reading) to cm of mercury (manometer reading), and all your pressure data has to be changed. Or you may have a very complicated expression to calculate from the raw data which you have entered in the file (the Flywheel experiment is a good example). You are asked how many new variables you want to define, their names, and how the computer is to calculate them from the data already in your file. NOTE! You are first asked if you want to keep the original data - it is usually a good idea to answer yes to this question.

addvar. You may decide that you want to add the values of a variable which you had forgotten to enter the first time. This option will ask you how many variables you want to add, and their names. It will present you, a line at a time, with the data that is already in your file. You just have to type in the new values. The programme will exit automatically when you reach the last line.