Experiment 0
Computing and Graphing

Revised Aug 29, 2004

Introduction

 In Physics 191 we use the computer to acquire data from instruments via interface cards and associated software. In addition, we will make extensive use of Kaleidagraph [Kgraph], a software package for graphing and data analysis. Kgraph is a substantial program but is nonetheless intuitive and extremely easy to use. Three major needs that Kgraph will address for us are:

1. Making high quality, easily customized graphs of your data.

2. Algebraic manipulation of numbers, equivalent to a powerful calculator;

3. Curve fitting, i.e., finding the parameters of a theoretical function that best describe your data. Kgraph provides estimates of the statistical uncertainties of the fit parameters, which are difficult to obtain with other commercial software (such as Excel).

Projects in the first Laboratory Period

Goals:

1) Familiarize yourself with Kaleidagraph's plotting, calculation, and fitting options

2) Provide yourself with notes for using these capabilities for the rest of the term.

3) Have a first look at histograms and standard deviation (more coming in the next experiment)

In the first lab [Experiment 0], we will learn how to use Kgraph on a PC equipped with the Windows 98 operating system. Your lab report will document the steps that you have followed to carry out the following exercises. It will contain printouts of the graphs that you generate. Since most of the ensuing labs will require Kgraph for plotting and analyzing data, this lab report will also serve as your guide for remembering how to do some basic operations. You can use Word to write your final report outside of class, but you must use your time carefully in class to record the procedures you used and the data you need.

Navigating Kgraph

Reading some selected Kgraph documentation will make completing the Exercises easier:

1.Start by reading the Kgraph Quick Start.pdf on your desktop. You don't have to perform the tutorial steps, but it will help you get a feel for what's in each menu. You can search the file with the binoculars button.

2. You will also find Kgraph's Help system useful; it is arranged by menus, with some further detail on the Plot Tools, and on Formulas and Curve Fitting. The >> spins you through successive menu entries. You can also use Help/Search.

3. In general, you can modify an existing graph by clicking on objects to bring up a menu for that object.

4. For exercise 3, see Help/Functions/Bin Data (this is a useful compact notation to record your procedures). Another method of varying the binning can be found in Format/Histogram Options and by clicking on the axis to change minimum and maximum x axis values.

5. For exercise 4b, you'll need the value of the fit at each data point. Our version of Kgraph does not have Curve_Fit/View/Copy Curve Fit described in Quick Start. However, it's still quite easy. Suppose you want the polynomial fit value in column 5, and your (x,y) were in columns (1,2). Use Windows/Formula then enter c5 = poly(c1,c2); and hit Run. Formula entry is discussed on page 12 of Kgraph Quick Start. For further help, see Help/Formula/Curve Fit Functions and Help/Formula/Syntax.  The mathematical methods Kgraph uses to find best fit curves is called “least squares” fitting. Least squares minimizes the sum of the square of the error ("residual") between the original data and the values predicted by an equation believed to describe the data.  This will be discussed in detail in Chapter 8 of Taylor; for now we can regard it as a black box whose results we can evaluate by eye. 

6. If you want to print out the “Statistics” screen, or anything else you can’t figure out how to print from a Windows program, hold down ALT and hit the Print Screen key.  A copy of the active window is now on the clipboard.  Then open Word, and paste with Ctrl-V, and print the windows document.


Exercises

1. Make a folder on your PC with the name c:\phy191\secn\exp0. Replace n with the number of your section, e.g., c:\phy191\sec1\exp0. Data from each week’s lab will be kept in a different, consecutively numbered folder.

2 a) Make a Scatter Plot of (x,y) data points in c:\phy191\samples\data1. Do NOT save your results in the samples directory. Make the size of the data points to be 16 point. (Under Plot/Plot Style, change the "marker size" to 16.)  Label the axes of the graph with names and units, e.g., Velocity (m/s) and Temperature (K). Explain your procedures and results at each step, of each exercise.

2 b) Convert the column 1 data, given in SI units, m/s, to ft/hr. Convert the data, given in Kelvins (K) to degrees Celsius. Label the axes of the graph with names and units, e.g., Velocity (ft/hr) and Temperature (degrees Celsius). Print a table with original and converted data.

2 c) Give each plot a title; include your name, section, experiment, and date in the upper right hand corner of the graph. Make sure that the graph labels, legends, etc. do not overwrite any significant part of the graph. Save both plots and print them on the laserjet printer. Note: To make the plot print correctly, you may have to make sure the graphics setup of the printer is chosen to print "raster graphics" rather than "vector graphics". You can ask your instructor for help if you are confused with these instructions.

3. Make a vertical bar (column) plot, and stack histogram plot of the file c:\phy191\samples\data2. In a histogram, data points are grouped into bins (ranges of values, say x between 20 and 30), with the number of points in each bin represented by the height of the stack or line. The plot will consist of bars rising from the x axis.  The position of the bar along the x axis will represent range values of the variable (grouped into the “bin” represented by the bar), and the height of the bar (in the y axis will represent how many data points fell into each bin.  Experiment with the effect of changing the bin size. Do this for at least two rather different bin sizes, so that the number of histogram bins containing data differs by a factor of 2 or more. Try menu items Functions/Bin Data and /Statistics. Print the table and the two graphs. Explain what the graphs represent, and why the two graphs differ. You can find more about histograms by looking up the term in the index of Taylor.

4a) Create two best fit curves to data1. Apply a linear and a fifth order polynomial function to the data for V vs. T. Before doing so, predict (write down before you do the fits!) which one you think will do the better job of describing the data, and why.  Print the graphs with the fit parameters included as labels on the figure. You may need to make two plots in order to show both fits.  For your report, discuss which fit actually looks “better” to your eye as a representation of the data.

4b) Residuals are defined as the difference: residual = data- fit, at each data point. Plot one set of residuals vs. T on another graph.

4c) Make a stack histogram plot of the residuals. Use "Statistics" to examine the residuals, looking particularly at the entries for Mean and Std Deviation.  The Mean is just the average value; the Std Deviation is an abbreviation for Standard Deviation; both are discussed in Taylor.  For now, you can think of the Standard Deviation as a measure of the scatter of the residuals about 0 (it’s related to what the fitting method is trying to make small). If you have time, compute residuals for both fits and compare the Statistics results, and see how well it matches to your comments in part 4a, and what features of the histograms the Mean and Std Deviation correspond to.

4d) Print out the table which contains the original data and the residuals for at least one of the fits. Make sure the columns of the table are labeled, including which fit the residuals refer to.

5. When you exit Kaleidagraph, select "None" in the dialogue box when you are asked whether you want to save changes. If  you don't, you risk messing up the setup for another student. If for any reason, you need to log in to windows, use the username "msu" and password "msu". Any other choice may prevent printing from your computer.
 

Reading and problems: (1 point per problem)

1. Read chapters 1, 2, and 5.1 You may also need to have a first look at parts of chapters 4 to understand some of your results for the lab. The handout on important things in Taylor may also be useful.

2. Homework 1: Do problems 2.4, 2.6. Also do the following exercise:

Lightly trace figure 5.2 onto the lower have of an empty piece of paper (lined or not). Then by hand sketch (with darker lines) what the histogram would look like if you had instead chosen bins of 22 to 24, 24 to 26, and 26 to 28.

Turn these 3 problems in with your lab report. It's due next week even though class isn't meeting to do a lab. Your instructor will discuss how to turn it in.