Information • Textbooks • Media • Resources edited by
Computer Bulletin Board
Steven D. Gammon
Nonlinear Least-Squares Using Microcomputer Data Analysis Programs: KaleidaGraph™ in the Physical Chemistry Teaching Laboratory
University of Idaho Moscow, ID 83844
W
Joel Tellinghuisen Department of Chemistry, Vanderbilt University, Nashville, TN 37235;
[email protected] The method of least squares has long been the standard tool for the analysis of experimental data in physical science. Although the procedures for fitting data to both linear and nonlinear models have been known for more than half a century (1), computational tedium made all but the simplest straight-line and low-order polynomial fits impracticable prior to the advent of the computer in the 1960s (2). Even then, program coding demands made such methods practically inaccessible to undergraduate students in the teaching laboratory, except in “black-box” mode (3–5).1 However, that has begun to change in the last few years as the microcomputer has “come of age”. And a number of recent works have described the use of microcomputer programs that make it feasible for students to analyze their own data interactively and in the same manner that researchers might use (6–14). With only a few exceptions (7, 10), these recent works have emphasized the use of spreadsheet programs (especially Microsoft Excel) and mathematics packages (mainly Mathcad). In my judgment, as data analysis tools, both of these are less efficient and much less “user friendly” than any of a number of more specialized data analysis and display programs. At Vanderbilt we have chosen one of the latter— KaleidaGraph2—as the focus of data analysis work in the undergraduate physical chemistry laboratory. A particularly useful feature in this program (and also in others of this type) is a user-defined nonlinear least-squares curve-fitting routine. The purpose of the present paper is to describe some of the features of this program (and by analogy, other data analysis programs), illustrate its application to specific experiments included in the standard physical chemistry laboratory repertoire, and discuss our procedures for implementing its use in the lab curriculum.
R (correlation coefficient). Complex fit functions can be defined in a Library and can call other defined functions. •
Weighted fits can be carried out as easily as unweighted, again through the General routine. Weights are calculated from standard deviations provided by the user as a third column of values associated rowwise with the corresponding (x,y) data.
•
A number of useful operations can be initiated simply by selecting a menu function. These include sorting, binning, and statistics commands, numerical differentiation and integration, and random number generation (as well as others the user may choose to define). Complex calculations can be performed on associated columns of data through the use of a simple Formula Entry window, in which one can include both prepackaged functions and functions defined by the user in a Library.
•
A comprehensive menu of graphical display options is provided. These include y vs x, double-y vs x, and several histogram and probability options.
•
In this era of ever-increasing reliance on online manuals, KaleidaGraph comes with a very detailed printed manual!
Some of KaleidaGraph’s limitations should also be noted: •
Only data in the form of y = f (x) can be fitted, and only y can be treated as uncertain.3
•
In keeping with the emphasis on two-dimensional display of data, there is currently no provision for three-dimensional or contour plots.
•
Parameter errors and χ2 values are obtainable only from the General routine; weighted fits are similarly restricted. Of course, one can use this mode for all the standard linear fits as well as for nonlinear models.4
•
Fit models can incorporate a maximum of only 9 adjustable parameters.
Advantages and Drawbacks of KaleidaGraph Among the virtues of the KaleidaGraph program are the following: •
The curve-fitting routines are invoked from the active plot window, and the results of the fit are plotted and displayed in numerical form immediately upon completion of a fit.
•
Users who are familiar with spreadsheet programs may be discomfited initially by the columnar structure of the data sheets in KaleidaGraph, whereby all entries in a given column must be of the same data type.
•
The results from multiple fits can be displayed simultaneously—a real plus for trial-and-error aspects of data analysis, such as model selection.
•
The manual is almost 700 pages long!
•
Quite sophisticated fit functions can be employed through the General command, which is the mode for user-defined models. In this mode the program also provides parameter errors, χ2, and a value of Pearson’s
Because of this last point and my observation that few students have had prior experience with programs of this type, I have designed several tutorial problem sets that students complete during the first few weeks of the lab course while they are also learning the essentials of statistical data analysis. These are largely of the “follow-the-bouncing-ball” type, with
JChemEd.chem.wisc.edu • Vol. 77 No. 9 September 2000 • Journal of Chemical Education
1233
Information • Textbooks • Media • Resources
some additional exercises in least squares, error propagation, and interpretation of errors using the normal distribution. In some cases students are directed to explore both a numerical and a formal approach to the solution of these problems.
3.5
z
z
Tutorial Exercises
3.0
y = a + 0*x Value
A Linear Example Students are introduced to the program (henceforth referred to as KG) through exercises in entering and importing data, displaying data in graphs, running simple statistics computations on columns of data, and manipulating data by using the Formula Entry window. The General curve fitter is introduced through the simplest of examples—a fit of data to a straight line through the origin. To this end I have used the data from a textbook problem, problem 6.4 in the book by Bevington and Robinson (15). (This problem must be handled through the General routine, because the standard straight-line fitters, including that in KG, include an unwanted intercept parameter.) The fit is accomplished by selecting the General curve fit option and simply entering a*x; a=1 in the Define Fit box; this also introduces students to the need to provide an initial (nonzero) estimate for each parameter when using this routine. The data are fitted (i) unweighted, (ii) weighted uniformly, with all σyi = 1.0, and (iii) weighted with all σyi = 1.5 (as stated in the problem in ref 15). The results of these fits reveal some differences in the way KG handles weighted vs unweighted fits: 1. All three yield identical values for the slope parameter, as they must, since the values of least-squares parameters are always independent of scale factors for the weights. 2. Since χ2 ≡ Σ(δ i /σ i) 2 (where δi = y calc(x i) – yi, and σi is the standard deviation in yi) fits i and ii yield identical values for χ2 (26.80256; see below), while iii yields a value smaller by 2.25 (= 1.52). (KG uses σi = 1 by default for unweighted fits.) 3. On the other hand, the estimated standard errors in the slope a are all different. The differences relate to what can be called a priori vs a posteriori weighting (16 ): when the weights option is selected KG uses the former, which is the same as assuming that the quality of the data is known at the outset; for an unweighted fit, KG invokes a posteriori weighting, which means that the quality of the data is assessed from the fit itself.W
y z≡ x =a
(1)
If the weights in y are uniform, those in z are not, as can be seen by a straightforward application of the error propagation expressions (9, 15):
σy σz = x i → w z = σz i i i i
2
=
x i2 σy
2 i
a
Error
3.6016924
0.02941742
Chisq
11.912255
NA
R
0.68450881
NA
2.5
2.0 0
5
10
x
15
(2)
20
25
Figure 1. Weighted fit of data from problem 6.4 in ref 15 to a constant, after transforming the original y values in accord with zi = yi /x i. The “y” and “x” in the Fit Results box are generic labels for the dependent and independent variables.
In fact, I include this as the students’ first error propagation exercise. The columns of zi and σzi are easily generated using the Formula Entry (FE) window. The calculation now needed is simply a weighted average. KG does not have a menu function for doing weighted averages. In a case this simple, one could easily muscle through the needed computations using FE to operate on columns. But in fact the General routine can again be used for this computation. If one enters just a; a=1 in the Define Fit box, the General quickly goes “belly up”; but it can be fooled into running the calculation by entering a+0.0*x; a=1. Results of this fit are shown in Figure 1, which includes the propagated error bars on the z values, showing the now variable uncertainties. An important point about Figure 1 is that the fit results are identical in every respect to those obtained in calculation iii above. This is a general property of linear least-squares fits: the results are independent of the representation chosen for the fit, as long as weights are properly taken into account. But suppose we knew just that the original y values were equally uncertain, leading to
1 σz ∝ x → w z = σz i i i i
This last point has practical consequences in cases where the data are known to be unequally weighted, but the weights are known in only a relative, not an absolute sense. As an example of this, consider refitting the data of this example after transforming according to
1234
4.0
2
∝ x i2
(3)
We would still need to choose the weights option and generate a column of σzi values to carry out the fit. By default we would probably take the proportionality constant to be 1.0, whereupon we would obtain values identical to those produced in calculation ii above. In all of these weighted fits, we could switch to the a posteriori assumption by simply multiplying the parameter standard error by the estimated σy, which is calculated from the KG output quantities as
χ2 N –p where N is the number of data points and p is the number of adjustable parameters.W This scaling yields a parameter error identical to that obtained in the original unweighted fit, calculation i, σa = 0.030613. (Of course in a multiparameter fit, every standard error should be similarly scaled.)
Journal of Chemical Education • Vol. 77 No. 9 September 2000 • JChemEd.chem.wisc.edu
Information • Textbooks • Media • Resources
A Nonlinear Example One of the most common nonlinear problems in experimental physical science is that of the declining exponential on a background, y = a e bx + c
(4)
Because of the presence of the background, a logarithmic transformation does not render the model linear. The standard approaches (9) for dealing with this problem have been (i) driving the process to completion (e.g., large x in a kinetics study) where y = c, then measuring c and treating it as a known in the analysis; and (ii) subtracting values at constant intervals ∆x to eliminate c, then linearizing with a logarithmic transformation. Both of these approaches have deficiencies. In the first case these may include the inconvenience of having to wait a long time (in kinetics measurements) to obtain the important final measurement or not being sure the process has gone to completion, and having to vest absolute confidence in the x = ∞ measurement(s). The last of these is particularly problematic if the apparatus is subject to drifts over long time, as it can introduce significant systematic errors. The second approach is known as the Guggenheim method. Its drawbacks include dependence of results on the choice of ∆x, and the need for a weighted linear fit following the log transformation. If the data are noisy and the time interval too short, negative differences can occur, which give obvious problems in the log transformation. The method requires the recording of data at some preselected fixed times, which can be a serious practical limitation (see below). Also, the subtraction process means that not all the data are used in the fit. A more subtle problem is that subtraction introduces correlation into the differences, meaning that the subsequent fit should properly be a correlated one (16 ). I have students examine some of these issues by carrying out both a direct nonlinear analysis and at least three Guggenheim analyses of a sample data set that they download from my course Web site. This exercise demonstrates that the direct fit is not only the statistically proper approach—it employs all the data and avoids the arbitrariness and correlation problems of the Guggenheim method—but is also easier than the Guggenheim method.W Since the direct fit in this case is a truly nonlinear one (unlike that in the first example), students may discover the importance of “reasonable” initial guesses. The KG General routine uses the reliable Marquardt algorithm (15), but poor initial values (including inadvertent values of zero if the initial values are omitted!) can still lead to divergence.
The Normal Distribution Students are introduced to the normal distribution and the effects of averaging through a computational experiment (a very basic Monte Carlo calculation) employing the random number generator in KG. A column of random numbers in the range 0–1 is generated by selecting Random # from the Macro menu, or by entering c0=ran() in the FE window. When these are displayed using the Stack Histogram option under the Stat plot type, they reveal the fluctuational nature of the random numbers. The parent distribution is the uniform one, meaning that each bin should contain, on average, the same number of counts. The magnitudes of the fluctuations
roughly follow Poisson statistics, so the standard deviation in the bin counts should be about the square root of the average bin count (15). The effects of averaging are demonstrated by generating sums of random numbers and then dividing by the number summed. The resulting histogram approximates the normal distribution.W This demonstration illustrates the very important central limit theorem, which says that the distribution of averages of random variates is approximately Gaussian, no matter what the distribution of the individual random variates (here uniform). The values of the bin counts can be extracted and fitted to the normal distribution using the General routine, for comparison with the theoretical values. Here one can readily calculate for the uniform distribution on the interval 0 ≤ x ≤1, the mean µ = 0.5 and the variance σ 2 = 1⁄12. Thus the variance in the mean (σ 2/N ) is σ 2/12, or σµ = 1⁄12. Equivalently, the sum of 12 such random numbers has a theoretical mean of 6 and a standard deviation of 1. In fact, this kind of calculation can be used to generate approximately Gaussian noise to be added to sample data in tests of fit models (although it is not the most efficient way to do so). Applications in the Teaching Laboratory
First-Order Kinetics A widely used example of first-order kinetics in the teaching laboratory is the study of the acid-catalyzed inversion of sucrose by polarimetry (17, 18). The use of nonlinear fitting to analyze the data has an important practical consequence in this experiment: freed from having to record optical rotation at precise time intervals (as required for a Guggenheim analysis), students can easily conduct several runs in “parallel” mode. Also, there is no need to return later for an α∞ measurement, so the work can be concluded each day and the equipment left ready for successor groups. We have students conduct at least half a dozen runs, sampling [H+] concentrations in the range 0.5–2.0 M at room temperature and at 40.0 °C. Our polarimeters are not thermostatable, so for the high-T data, students must expeditiously extract the polarimeter tube from the water bath, dry it, record the optical rotation, and then return it to the bath. (While less than ideal, this procedure appears not to introduce significant errors into the results.) Students are advised to record at least 20 points for each run, using shorter time intervals at the outset and longer intervals later. The data—angle of rotation in degrees, as a function of time in min—can be analyzed directly using eq 4. However, it is preferable to fit to a form in which the physical parameters α0, α∞, and keff are defined as the adjustable parameters: α(t) = α∞ + (α0 – α∞) exp(keff t)
(5)
In this way the returned parameter errors are directly the errors in the physical quantities, whereas to generate the correct errors from the generic parameters in eq 4, it is necessary to use error propagation in a more sophisticated way than is customarily taught at the undergraduate level (and indeed, which is widely neglected even at the research level) (19, 20). The actual entry in the Define Fit box of KG might be, for example, a+(b–a)*exp(–c*x); a=–5; b=10; c=0.01 (6)
JChemEd.chem.wisc.edu • Vol. 77 No. 9 September 2000 • Journal of Chemical Education
1235
Information • Textbooks • Media • Resources
Vapor Pressure The measurement and analysis of vapor pressure as a function of T is an important component of the thermochemistry laboratory curriculum. Over a small range of T, ln P is a linear function of T 1, with slope proportional to the heat of vaporization, as expressed in the integrated Clausius– Clapeyron equation ln P = A –
∆H m,vap RT
(7)
or the equivalent form
∆H m,vap 1 ln P = – 1 R P0 T0 T
(8)
where P0 and T0 are the pressure and temperature at some reference point. It is customary to fit the data to one of these log forms (with x ≡ T 1). However, pressures are often measured with devices that are approximately linear in P (e.g., manometers), so that uncertainties in the measured pressures are independent of P. Accordingly, the transformation to the log form implies the need for a weighted fit, for reasons already discussed. The linear display of the data according to eq 7 is both instructive and a useful check on the data. But if indeed the measured P values have constant uncertainty, then an obvious alternative to the weighted log fit is an unweighted nonlinear fit to the exponential version of eq 7 or 8. In either case, it is again desirable to define the fit parameters as the physical parameters (e.g., T0 and ∆Hm,vap), because then the fit will yield directly the proper errors in these quantities.5 (See the online supplement for a more detailed treatment of this example,W in which the KG Library is used to define complex fit functions that include corrections to the assumptions behind eqs 7 and 8.)
Emission Spectroscopy The study of the emission spectrum of atomic hydrogen (18) offers students an instructive introduction to methods of optical spectroscopy, including the importance of calibration, the need to correct from “standard air” wavelengths to vacuum in calculating energy differences, and the limitations of spectral resolution. Standard scanning UV–vis spectropho1236
10 9
Intensity (arb u)
For a typical polarimeter the uncertainty in the measurement of α is roughly independent of α, so an unweighted fit to eq 5 is appropriate. The outcome of the foregoing analysis is a set of k eff values for each temperature, from which a weighted fit to keff = k [H+] yields k at each T. The activation energy and its uncertainty can then be computed from the two k values and their uncertainties. While the error propagation calculation required here is an instructive exercise for students, KG can be induced to do this determination, too. A weighted fit of the two k values to the Arrhenius equation, k = A exp(Ea/RT ), will yield nothing (because KG recognizes that the number of degrees of freedom is zero). But if each value and its uncertainty are entered twice, the fit will run and will yield results for – Ea and its uncertainty. However, the latter will be a factor of √ 2 too small, in keeping with the false assumption of N = 4 points instead of 2.
8 7 6 5 4 3 2 433.6
433.8
434.0
434.2
434.4
Wavelength / nm Figure 2. Emission spectrum (uncorrected for wavelength calibration) of H and D from a deuterium discharge lamp, as recorded on a Shimadzu UV-2101PC spectrophotometer near 434 nm. The stronger line is the D line. The smooth curve is the result of a fit to a sum of two Gaussians and yields estimates of 433.8959(6) and 434.0251(21) nm for the locations of the two components.W
tometers can often be used directly for collecting the spectra. We use a Shimadzu UV-2101PC and set both the slit width and the sampling interval to their smallest permitted values (0.1 and 0.05 nm, respectively) to record spectra. The deuterium discharge lamps on such instruments (which are used for UV absorbance measurements) are ideal emission sources; since they normally contain about 25% H, they yield data for both H and D, further introducing students to isotope effects in spectroscopy. With the goal of extracting experimental estimates of the Rydberg constant from the spectra, we treat the H/D spectra as “unknowns”. Wavelength calibration is then achieved by removing the D2 lamp and recording a number of “known” lines from atomic sources such as Ne and Hg discharge lamps. The limited spectral resolution for such instruments is evident in the spectrum shown in Figure 2 for a Balmer-series line (H- γ) near 434 nm. With “eyeball” techniques, it is difficult to extract reliable estimates of the wavelengths of the component peaks in such spectra and virtually impossible to estimate their precision. However, analysis by means of a nonlinear fit to a sum of Gaussian lines (or more complex line shapes, if desired) is readily implemented using a program like KaleidaGraph. (Some “tricks” are needed to coax proper performance.W) A weighted average of data of this type for four such doublets gave values of the infinite-mass Rydberg constant of 109,735.5 ± 2.5 cm1 for H and 109,736.3 ± 1.8 cm1 for D, both within 1σ of the accepted value, 109,737.32 cm1.
Infrared Spectroscopy of HCl The study of the infrared absorption spectrum of HCl introduces students to the quantization of rotational and vibrational energy in molecules. The experiment typically yields much high-quality data, the analysis of which can test students’ “staying power”. Most lab text descriptions of this experiment suggest that students record the fundamental and first overtone for both HCl and DCl. They can thereby obtain for both isotopomers (isotopic isomers) precise estimates of the rotational constants for vibrational levels υ = 0, 1, and 2, from which the internuclear distance Re can be determined, and vibrational energy intervals E1 – E0 and E2 – E0, from which the vibrational frequency, anharmonicity correction, and
Journal of Chemical Education • Vol. 77 No. 9 September 2000 • JChemEd.chem.wisc.edu
Information • Textbooks • Media • Resources
force constant may be estimated. The results for multiple isotopomers can be checked for consistency, using theoretical relations for isotopic mass dependence. Many FTIR instruments routinely available in organic teaching labs can achieve a spectral resolution of 1 cm1, which suffices to resolve the H35Cl–H37Cl line splitting in most of the spectral lines in both the fundamental and first overtone. This makes it possible for students to study the isotope effect by recording spectra for just “natural” HCl. The software that comes with such instruments also makes it relatively easy to extract the line positions. In the event that not all the spectral doublets are resolved, they can be analyzed using procedures like those just described for the H and D emission lines. When the line positions have been extracted and the lines assigned rotationally, the standard approach for analysis is the method of combination differences (17 ). Subtraction of P and R lines sharing a common upper or lower level yields expressions that can be fitted to linear relations to obtain estimates of the rotational (Bυ) and centrifugal (Dυ) distortion constants for the υ level in question. Although this treatment is instructive, it is statistically flawed in several ways.W The proper procedure is a direct fit of all R and P lines at once to a form that includes all five parameters for the band under analysis. This can be done using the “m representation” (9), in which the P lines are labeled as m = J and the R lines with m = J + 1, yielding for the IR fundamental (the 1–0 band) ν(m) = ν0 + (B1 + B0)m + (B1 – B0 – D1 + D0)m2 –
2(D1 + D0)m3 – (D1 – D0)m4
(9)
where ν0 is the band origin. The required fit is linear and is again readily carried out using the General routine of KG. As before, the adjustable parameters should be entered in just the way they occur in eq 9, and the fit will then directly yield estimates of their values and errors. Repetition of this procedure for the first overtone (the 2–0 band) will yield estimates for ν0(2–0), B2, D2, and another set of values for B0 and D0. By combining results of similar analyses for both isotopomers, one can then calculate a single set of “equilibrium” parameters (ωe, Be , De, Re , ke , etc.), from which a Morse potential curve can be calculated and plotted for the ground state.W
A Final Example The examples given so far involve cases where all the data are fitted with a single model equation. However, there are situations in which more than one equation is required to fit different subsets of the data. The General routine in KG can also handle some of these. To illustrate, I have chosen a laboratory example for which students normally are quite happy not to have to carry out any “serious” computations: bomb calorimetry. Figure 3 shows temperature as a function of time for a run with a Paar bomb calorimeter, with temperatures measured with a thermistor and recorded on a computer at intervals of about 2.5 s. The figure also includes results of a fit of these data to a two-function model, which is accomplished by entering in the Define Fit box, ((x>f)?(g-b*(x-f)+a*(1-exp(-d*(x-f)))):(g-h*(x-f)))
(10)
This fit model includes a conditional test that directs data for x>f to the first function in parentheses, and data having x≤f to the function entered after the colon. The latter function (for the small-x data) is linear, with intercept g (at x = f ) and slope h; the former function is similarly linear but with an added term that allows for the asymptotic approach to the line, of intercept (g+a) and slope b. Note that a is thus the desired temperature jump at x = f, and that the fit itself determines this jump point (f ). Note also the remarkable precision (0.0025 K) in the estimate of a. However, one should be cautious about using such precision estimates obtained from fits of large, high-quality data sets, as the results can be quite model sensitive. In this case, a fit to a different but comparable model suggests that the estimate of σa is optimistic by at least a factor of 2.W Implementation in the Curriculum
θ / °C
Compared with programs like Excel and Mathcad, and especially programming languages like Fortran and C, KaleidaGraph is ultimately not as powerful or flexible, though its capabilities can be extended through Macro programming. Still, its ease of use makes it my preferred data analysis tool not only in the teaching laboratory but also in many research applications. To emphasize this point, I conducted two time tests on myself, analyzing the kinetics data discussed by Zielinski and Allendoerfer (12) (their Table 1) and the standard additions analytical data treated recently by Bruce and Gill (21). In the former, I had entered the data and conducted nonlinear fits 27 y = ((x>f)?(g - b*(x-f) + a*... to both the second-order and the first-order kinetics 24.35 Value Error models within 5 minutes (with output of parameter a 3.18506 0.00253939 26 24.30 errors and χ 2); within 10 minutes I had added fits to b 0.000178338 7.44177e-07 d 0.0194985 5.01173e-05 24.25 test for the inclusion of a constant background term, f 277.441 0.093285 then had positioned both graphs with all four sets of 24.20 g 24.1721 0.00233641 25 fit results on a single page layout and sent the latter to h 0.000135271 1.59618e-05 24.15 0 50 100 150 200 250 300 Chisq 0.140274 NA the printer. The 5 data points given as Example 1 by R 0.999919 NA Bruce and Gill required less than 3 minutes to enter 24 0 500 1000 1500 2000 2500 and fit to a form that yielded directly the desired analyte concentration (cx) and its correct (Method 1) t /s standard error. It should be clearly understood that the Figure 3, Temperature as a function of time for a bomb calorimetry experiuser-defined fitting routines in programs like KG do not ment. The smooth curve is the result of a fit to a two-function model, as require any precoding or template definition, just the given in eq 10. The inset shows the behavior in the vicinity of the bomb entry of the fit function and initial values in the Deignition time. JChemEd.chem.wisc.edu • Vol. 77 No. 9 September 2000 • Journal of Chemical Education
1237
Information • Textbooks • Media • Resources
fine Fit box—e.g., in the case of the second-order analysis of the ref 12 data, a/(1+a*b*x); a=.01; b=.001. As much as anything, it was this empowerment attribute that led me to adopt KG in the physical chemistry teaching laboratory. In an ideal world I would prefer that students learn to code the “nuts and bolts” of least-squares fitting for themselves, using programs like Fortran or Mathcad; but there simply is not time for this in the framework of a one-hour laboratory course, for students who have mostly had little or no exposure to statistics. Even with KG I need to budget almost half the semester for instruction in statistics and data analysis and the use of the program. Without it we would be relegated to embarrassingly out-of-date analysis methods, including the “black-box” approach previously used for some of the experiments discussed above. Regarding the tutorial exercises, students do these during the first four weeks of the course, when they are learning about data analysis in lab lectures but are not yet doing experiments. The assignments are designed to be doable in 3–5 hours each week and are worth a significant fraction (1⁄4) of the credit in the course. In the first week students learn to enter data, display these in various ways, add error bars and invoke built-in fits, do simple statistics on columns of data, use the Formula Entry window for simple computations, and prepare plot Layout windows for printing. In the second week they import data from text files and become acquainted with the Library, and are introduced to the General routine through the example of Figure 1. In the third week they fit very high quality data (density of water as a function of T ) to high-order polynomials and learn to examine the fit residuals for insight into the performance of the fits; they are also introduced to the random number generator and the uniform and normal distributions. In the fourth week they analyze first-order kinetics data with a background, comparing the direct nonlinear analysis with the Guggenheim approach. At this point they should be prepared to analyze any data they collect in the laboratory. Late in the semester a “dry-lab” project in partial molar volumes is assigned as a refresher and reinforcement device. In all this work students are encouraged to help one another in mastering the idiosyncrasies of the program, but are supposed to do the “scientific” components on their own. The academic price of KaleidaGraph is comparable to the current cost of physical science textbooks and thus is, in principle, affordable to students. Indeed, a few students have elected to purchase their own copies each semester. But since Vanderbilt students are not required to own personal computers, it has been necessary to make the program available to them in the university’s microcomputer laboratories. We currently have about two dozen copies to serve up to ~60 students in the lab course. However, as few as one copy to every four or five students could suffice, since the greatest demand always comes 1–2 days before due dates, which are usually distributed throughout the week. In addition we have two copies running on computers in the physical chemistry laboratory (but available only during normal lab hours). For historical reasons most of our program copies are loaded on Macintoshes. However, students these days seem more familiar with Windows machines and hence prefer them, so we have also obtained a few Windows versions of the program. Although the files created on one platform 1238
are also usable on the other, students can experience some frustration when, for example, the Mac program doesn’t properly recognize the Windows-created files and vice versa. (The fact that today’s Macs automatically read both Mac- and PC-formatted diskettes plays a role here.) These problems can usually be solved by steps as simple as renaming the files with recognizable extensions. However, students often will not know to do this, so it is probably wise to avoid such difficulties by advising them to stick to one platform or the other to the extent possible and to use Mac-formatted diskettes on the Macs. The use of this program and the kind of techniques I have described in this article have greatly expanded students’ abilities to analyze and display their data in the laboratory. From the “public relations” standpoint, however, the project is not yet an unqualified success. Statistics and data analysis is seldom a wildly popular topic of study. And, like most sophisticated programs, KaleidaGraph has its share of pitfalls and even a few genuine bugs. Students who are adept with computers will have little problem with these. But those who are not can find themselves wasting hours on “stupid” problems and stupid mistakes. Unfortunately it takes only a few of these to leave them with a bad taste for data analysis in general and KaleidaGraph in particular. Accordingly, instructors must be vigilant in trying to anticipate these situations and forewarn students about them. In my case this has meant a fair amount of “bench testing” of the tutorial exercises on undergraduate students, “captive” (though not “captivated”) graduate TAs, …, and even my own daughter! Indeed, this is still very much a “work in progress”. W
Supplemental Material
Supplemental material for this article is available in this issue of JCE Online. Notes 1. This mode is arguably of less heuristic value to students than the old-fashioned graphical methods; this is especially true if students are thereby excused from preparing graphical displays of their data. 2. Synergy Software, Reading, PA. This program is available for both Macintosh and PC platforms, with files interchangeable across platforms, for an academic price less than $100. 3. The treatment of x as error-free is still the standard approach in most least-squares fitting and is seldom a serious limitation. 4. In least-squares parlance, “linear” means cases where the equations to be solved are linear in the adjustable parameters. This includes not only the common straight-line fits but also fits to polynomials and to other sums of functions in which the adjustable parameters occur simply as coefficients of terms in the sum. For example, a paper by Harris (13) actually describes a linear fit to a nonlinear function of x. Conversely, some apparently linear fits are actually nonlinear in the parameters, as is illustrated in the discussion of vapor pressure data. From a computational standpoint, the fundamental difference is that linear problems are in principle solved in a single computation, whereas nonlinear problems require iteration. 5. If ∆Hm,vap and boiling point (T0) are taken as the parameters in a fit of vapor P data to eq 8 (with P0 ≡ 760 torr), the linear relationship between ln (P/P0) and 1/T is actually nonlinear in the parameters.
Journal of Chemical Education • Vol. 77 No. 9 September 2000 • JChemEd.chem.wisc.edu
Information • Textbooks • Media • Resources
Literature Cited 1. Deming, W. E. Statistical Adjustment of Data; Wiley: New York, 1943. 2. Wentworth, W. E. J. Chem. Educ. 1965, 42, 96–103, 162–167. 3. Christian, S. D.; Tucker, E. E. J. Chem. Educ. 1984, 61, 788. 4. Chandler, W. D.; Lee, E. J.; Lee, D. G. J. Chem. Educ. 1987, 64, 878–881. 5. Dado, G.; Rosenthal, J. J. Chem. Educ. 1990, 67, 797–800. 6. Ogren, P. J.; Norton, J. R. J. Chem. Educ. 1992, 69, A130–A131. 7. Brewer, G. J. Chem. Educ. 1992, 69, 1006–1009. 8. Alonso, V.; Camacho, L. J. Chem. Educ. 1993, 70, A312–A314. 9. Shoemaker, D. P.; Garland, C. W.; Nibler, J. W. Experiments in Physical Chemistry, 6th ed.; McGraw-Hill: New York, 1996. 10. Coleman, W. F. J. Chem. Educ. 1996, 73, 243–245. 11. Machuca-Herrera, J. O. J. Chem. Educ. 1997, 74, 448–449. 12. Zielinski, T. J.; Allendoerfer, R. D. J. Chem. Educ. 1997, 74,
1001–1007. 13. Harris, D. C. J. Chem. Educ. 1998, 75, 119-121. 14. Pandey, S.; McHale, M. E. R.; Coym, K. S.; Acree, W. E. Jr. J. Chem. Educ. 1998, 75, 878–880. 15. Bevington, P. R.; Robinson, D. K. Data Reduction and Error Analysis for the Physical Sciences, 2nd ed.; McGraw-Hill: New York, 1992. 16. Tellinghuisen, J. J. Mol. Spectrosc. 1996, 179, 299–309. 17. Daniels, F.; Williams, J. W.; Bender, P.; Alberty, R. A.; Cornwell, C. D. Experimental Physical Chemistry, 6th ed.; McGraw-Hill: New York, 1962. 18. Salzberg, H. W.; Morrow, J. I.; Cohen, S. R.; Green, M. E. Physical Chemistry Laboratory: Principles and Experiments; MacMillan: New York, 1978. 19. Tellinghuisen, J. J. Mol. Spectrosc. 1990, 141, 258–264. 20. Salter, C. J. Chem. Educ. 2000, 77, 1239–1243. 21. Bruce, G. R.; Gill, P. S. J. Chem. Educ. 1999, 76, 805–807.
JChemEd.chem.wisc.edu • Vol. 77 No. 9 September 2000 • Journal of Chemical Education
1239