LITERATURE CITED (1) H. S. Hertz, R. Hites, and K. Biemann, Anal. Chem., 43, 681-691 (1971). (2) F. W. McLafferty. “Interpretation of Mass Spectra,” 2nd ed., W. A. Benjarnin, Inc., Reading, Mass., 1973, pp 16-27.
RECEIVEDfor review August 23, 1974. Accepted December 9, 1974. This material is presented for information only.
Distribution by this Agency does not imply endorsement of any product referred to herein. The Opinions Or assertions contained herein are the private views of the authors and are not to be construed as official or as reflecting the views of the Department of the Army or the Department of Defense.
Random Error Propagation by Monte Carlo Simulation Lowell M. Schwartz Department of Chemistr,y, University of Massachusetts-Boston,
Boston, MA 02 725
In general, a result or set of results yi are calculated from a number of experimental quantities x j but the x j are uncertain due perhaps to determinate and/or random (indeterminate) errors. To project these errors into the resultant yi is a topic treated in many analytical and physical chemistry texts under the title of “error propagation”. I wish to focus here on the particular problem of calculating the “most probable” uncertainty or error b3.i in yi due to random errors 6xj in the xj. The “most probable” uncertainty is to be distinguished from the “maximum probable” error, this latter quantity estimating the maximum excursion expected of the results yi from the (unknown) true values which can be rationalized by the bxj. This maximum by nature overestimates the most probable error. A formula for the most probable propagated random error is commonly given ( I , 2) as
The validity of this expression is based on a number of assumptions: (a) the various bxj are statistically uncorrelated; ( b ) the x j are functionally independent; and (c), if the yi are not linear functions of the xj, then each bxj must be sufficiently small relative to the corresponding mean values of the x j so that the functions can be reasonably linearized about the means. If one or moje of these assumptions is invalid, Equation 1 can be suitably corrected but a t the expense of computational effort. A more difficult problem arises when the functional forms yi(xj) are differentiable only with great difficulty or perhaps not a t all. This problem, however, could be attacked by numerical methods. The technique of Monte Carlo simulation is an alternative approach to be considered when Equation 1 or its corrected form is inconvenient and when digital computing facilities are available to handle the substantial and repetitive calculations. I t has been applied to various problems in engineering, economics, and industrial operations ( 3 ) ,but is relatively unfamiliar t o chemists. Calculational Method. The random error propagation calculation under consideration in this paper is generally attempted only when the 65i are required but when these cannot be determined directly by repeating the experiment enough times for statistical validity. Clearly, if the experiment could be done repeatedly to generate a reasonable statistical population of each y ; value, then the information on the random uncertainty in the yi would be in hand. T h e digital computer offers a convenient means of simulating the repetition. I t is only necessary to generate new sets of x; data values, calculate the resultant yi values and store these for later statistical analysis. The repeated sets of x j could be generated in accordance with any distribution function, but the Gaussian (normal) serves to represent fluctuation in most physical situation.
Experienced scientific programmers should have little difficulty with this straight-forward calculation, but for those readers wishing to adapt a written program to their own problem, one is hereby offered with the following features and limitations: 1) Written in FORTRAK IV language. 2) Accepts j 5 20 x j values and their uncertainties a x ; , assumed to be uncorrelated standard deviations. 3) Calculates i 5 20 yi results and their standard errors (estimated standard deviations) 6yi. 4) Simulates n I 100 repetitive experiments based on the assumption t h a t the x j values scatter normally. 5) Prints out calculated mean values and estimated standard deviations of the yi. A program listing and operating instructions will be sent without charge upon request to the author. The operator, in addition to writing his own subroutine relating his yi to xj, must select the number n of simulated repetitions. This choice is to be based on a trade-off between computer running time and the degree of certainty required of the calculated 6yi values. A quantity which may be helpful in making this choice is the standard error (estimated standard deviation) in 6yi which is given by ( b y i ) 2 d 2 / ( n- 1) and which is derived for normal distributions ( 4 ) but is an approximation for others. Reference ( 4 ) also describes how confidence limits may be estimated for by;. Sample Calculation. The following problem illustrates application of the technique. The primary dissociation constant pK1 of a dibasic acid is to be calculated from a potentiometric p H titration of 50.00 f 0.05 ml of 0.0563 f 0.0005F solution of the disodium salt Na2A with HC1 solution beyond the first equivalence point. T h e second dissociation constant K2 is known t o be 0.00538 i 0.00012. After addition of 7.00 i 0.01 ml of 0.634 f 0.003 F HCl, the p H is 1.525 f 0.002. Each of these six expressed uncertainties bx; are measured or estimated standard deviations. The desired result pK1 is calculated from the following set of coupled equations which represent the equilibria, stoichiometry, and activity coefficient correlation.
K, =
pK, = - l o g K ,
7 ,?[H’][HA-]
[H?‘41 -0.51irT [H’] = 7 log ?* = 1.0 + 2.017 ii 10-pH
[H’]
+
[HA-]
+
4[A2-]
+
C,,,!
+ ~,
+
2CI’ 1,
ANALYTICAL CHEMISTRY, VOL. 47, NO. 6, M A Y 1975
963
This set of equations cannot be solved explicitly for pK1 in terms of only the six independent variables, and so is solved iteratively for each set of scattered data. T h e result pK1 f 6pK1 is 0.576 & 0.041 for 25 simulations. T h e standard error in 8pKl is 0.0005. These results are interpreted to mean that if the titration is repeated 25 times with newly prepared solutions and 7.00 ml added acid each time, the pK1 values should average 0.576 and should scatter with an estimated standard deviation of 0.041. Then if the entire series of 25 repetitions were itself repeated again and again, the 6pK1 should average 0.041 and should scatter with a standard error of 0.0005. If the uncertainty of 0.0005 in dpK1 is too large, then the program would be rerun with the number of simulations chosen larger than 25. These considerations deal with only part of the full uncertainty of the pK1 value. Nonrandom (determinate) er-
rors are associated with such factors as instrument and volumetric calibrations, reagent purity, and the accuracy of the system of equations chosen as a model for the physical reality. These errors must be considered by other means.
LITERATURE CITED (1) I. M. Kolthoff, E. B. Sandell, E. J. Meehan, and S. Bruckenstein, "Quantitative Chemical Analysis", 4th ed.. The Macmillan Company, New York, NY, 1969, p 399. (2) D. P. Shoemaker, C. W. Garland, and J. I. Steinfeld. "Experiments in Physical Chemistry", 3rd ed., McGraw-Hill Book Co., New York, NY, 1974, p 51. (3) G. J . Hahn and S. S. Shapiro, "Statistical Models in Engineering", John Wiley and Sons, New York, N Y , 1967, Section 7-3. (4) J . F. Kenney and E . S. Keeping, "Mathematics of Statistics", Part One, 3rd ed., D. Van Nostrand Co., inc., Princeton, NJ, 1954, Section 12.13.
RECEIVEDfor review October 2, 1974. Accepted January 13, 1975.
Flow Cell for Electrolysis within the Probe of a Nuclear Magnetic Resonance Spectrometer Jeffrey A. Richards and Dennis H. Evans Department of Chemistry, University of Wisconsin-Madison,
Madison, WI 53706
In recent years most of the common spectrometric methods have been coupled to electrochemical experiments to obtain spectrometric information about electrolytic intermediates and products. Typically, the electrolysis is performed in or near the sample region of the spectrometer so that species may be detected soon after their formation. Nuclear magnetic resonance (YMR) spectrometry has not been used for this purpose partially because of its low sensitivity but principally because the presence of the electrochemical cell in the sample region degrades the homogeneity of the magnetic field causing loss of resolution and sensitivity. However, the ability of NMR to distinguish quite similar species makes its application to electrochemical investigations quite attractive. In this note is reported what is believed to be the first successful electrolysis within an NMR probe.
EXPERIMENTAL Electrochemical Cell. T h e cell is shown schematically in Figure 1. It consists of a porous 3-cm long cylindrical bed of mercury coated platinum wire bits (diameter: 0.16mm: length: ca. 0.5 m m ) packed inside a 3.5-cm length of 1.5 m m 0.d. DuPont Nafion XR-72 (11 \V 11 B) ion exchange tubing. Uncoated platinum as well as carbon cloth (Union Carbide, Carbon Products Division, New York. SY). and pulverized (80 mesh) glassy carbon rod (Tokai hlanufacturing Co., Tokyo) have also been used as packing materials. A concentric coil of platinum wire (0.41-mm diameter) was wound around t h e outside of the tubing t o serve as counter electrode and t o give structural support to t h e ion exchange tubing. LVhen the Nafion tubing swells in t h e presence of solvent, the platinum coil causes the tubing to constrict t h e bed electrode, effectively ensuring tight packing and minimal wall leakage around t h e bed. A mercury coated platinum wire (0.16-mm diameter) makes contact to the cathode bed and passes u p through a ca. 18-cm length of 3-mm o.d. Pyrex tubing through which t h e solution is pumped to the cell by means of a Sage Instruments (White Plains, NT) Model 237-2 Syringe P u m p (Figure 2). Flow rates were variable from 0 to 1 ml/min. T h e effect of solution flow on the NMR spectrum a t these flow rates is unimportant ( I , 2). A right angle glass adapter is attached to the top of the probe by means of a short length of vacuum tubing and solution is injected through a red rubber septum a t the end of t h e adapter. 964
ANALYTICAL CHEMISTRY, VOL. 47, NO. 6, M A Y 1975
T h e 3-mm Pyrex tubing was affixed t o the Nafion tubing by means of Elmer's Epoxy (Borden, Inc., New York, NY) as was the small glass conduit which forms t h e exit nozzle. T h e latter is a finely pulled capillary made from No. 34505 Kimax Capillary Tubes (Kimble, Toledo, OH) for t h e purpose of minimizing t h e delay time of solution from t h e electrode to t h e N M R detection region. T h e exit capillary also keeps the electrode itself outside of the N M R detection coil region, since the presence of the electrode assembly in the detection region was shown t o have a deleterious effect on spectrum intensity and resolution. Because of weakening of the epoxy, lifetime of the electrode is only a few hours in nonaqueous solvents such as dimethylsulfoxide, acetonitrile, and dimethoxyethane. No deterioration was observed in ethanol-water or methanol-water mixed solvents. Excess solution was removed from the tube by a small capillary epoxied to t h e side of the 3-mm Pyrex tube and connected a t t h e top t o a vacuum source to provide suction ( 3 , 4 ) . T h e dimensions of t h e above cell probe are such t h a t it fits inside a standard 5-mm o.d. NMR tube and permits it t o rotate freely when properly aligned. In the operating position, the opening of the exit capillary is a t or below the center of t h e detection coil region, For our instrument (Varian A60A), the detection coil region was centered a t 0.95 cm from the bottom of a normally positioned tube and it was effectively 4-5 m m in height. T h e electrode could be positioned vertically to better than fl m m by the stand shown in Figure 2 which also has facility for some lateral and angular adjustments. A firmly compressed glass wool plug was used in t h e bottom of a normal N M R tube to decrease the dead volume below t h e detection coil region. For t h e case above, a O.7-cm plug was used. T h e glass wool plug was packed sufficiently tight t h a t no electrolysis product could he observed entering the plug. In order to facilitate probe alignment, the NMR tubes were cut as short as possible (typically 10-14 cm), yet long enough to f i t into t h e normal spinning holder. T h e center of the detection coil region was determined by filling a 4-mm diameter glass bulb a t the end of a small capillary with 2iodopropane and monitoring the peak height of the downfield line of the methyl doublet as a function of the distance of t h e center of the bulb from the bottom of the NMR tube. Positioning was accomplished by using a No. 529 U'ilmad (Buena, N J ) Microcell Assembly Teflon Chuck. (Note: The location of the detection region differs slightly from one spectrometer t o another, and it is sometimes displaced during servicing of the spectrometer probe.) Since the cell was of two-electrode design (counter and working electrodes). t h e current was the experimentally controlled variable.