In part I of this series on statistical concepts related to cannabis analysis, we introduce the normal distribution, standard deviation, and how to calculate precision and accuracy.
Whether you are trying to decipher a certificate of analysis, minimize analysis error, or develop a representative sampling plan, statistics are an important part of cannabis analysis. In this first of a series of columns devoted to statistical concepts related to cannabis analysis, I will introduce the normal distribution, standard deviation, and how they determine how precision and accuracy are calculated.
Statistics is a large and complex mathematical field, and I am neither a mathematician nor a statistician. I am a PhD physical chemist who has taken advanced undergraduate courses in statistics, have used statistics frequently throughout a 40 year career, and have discussed the applications of statistics to spectroscopy in my book Quantitative Spectroscopy: Theory and Practice (1), which I will be citing frequently in this article. The warning is that since statistics is not my full time job, my writing on the subject may be overly simplified for some or not detailed enough for others. If you want to learn more about statistics, I recommend the books Probability and Statistics for Scientists and Engineers (2) and Statistics in Spectroscopy (3).
When I first took freshman physics, me and my two lab partners entered the laboratory and were presented with a meter stick and told to measure the length of a table 10 times each. I thought this was absurd. I measured the table once, it was clearly 2 meters long, so why did we need to measure the table 29 more times? Surely all the other measurements would be the same as what I obtained. I at least thought that was true until we compiled all the measurements. Not only were the measurements not all the same, but there was a significant scatter to them. Most were at 2 meters ± 1 cm, but some were as high 2.2 and as low as 1.8 meters. And when we plotted the number of measurements at a given length versus length, to my surprise we obtained the distribution seen in Figure 1. This is what some of us know as a “bell shaped curve,” but what mathematicians call a “Gaussian” or “Normal” distribution (4).
“Gaussian” is named after Carl Friedrich Gauss, a 19th century German mathematician and scientist who contributed much to our understanding of statistics and to other fields such as magnetism (5). I was shocked not only that our measurements were a distribution, but that the shape of the curve was well known, characterized by known mathematics, and widely used in physics and other sciences. It turns out that being human beings we each made mistakes in measuring the length of the table, and that the size of the errors we made were randomly distributed resulting in a Gaussian distribution. In general, a set of measurements containing random error will follow a Gaussian distribution, such as a set of potency measurements on the same marijuana sample. Given how goofy and random my lab mates and I were at the age of 19, I am surprised the size of our errors weren’t bigger than what we measured!
The top of a Gaussian distribution, in our case the table length measured most often, is the average for the data plotted. The average of the 30 measurements was 2 meters. I think we all may know how to calculate an average, but the formula is given in equation 1 just to be clear.
where µ is the average; n is the total number of measurements in a dataset; Xi is the ith value in a data set; i is 1…n; and ∑i is the mathematical notation to add sum the members of a dataset from the first to nth members.
In other words, to calculate an average take a set of data with n numbers in it, add them together, and then divide by n.
The Gaussian distribution also contains what are called inflection points. The inflection points of a graph are where the concavity changes sign as illustrated in Figure 2.
Figure 2 uses an infrared (IR) absorbance band for illustration, but the idea of inflection points also carries over to other spectroscopic peaks, peaks in chromatograms, and so on. Concavity measures the curvature of a function, be it up or down. Imagine pouring water on the peak in Figure 2. The spots where water pools are concave up, the spots from where it drains are concave down, and the transition spots are the inflection points.
In the normal distribution seen in Figure 1 the half-width of the function at the inflection points is called the standard deviation or σ, and at this point the function is 2σ wide (6). The standard deviation is calculated via equation 2.
where σ is the standard deviation; µ is the average; n is the number of measurements; i is 1…n; and Xi is the ith value.
The numerator in equation 2 contains the difference between any given measurement in a dataset Xi and the average of that dataset µ, which we will call a difference. Each difference is then squared, and they are all added together. The differences are squared so that they are all positive, and the squared difference gives the absolute distance between a data point and the average. Summing unsquared differences would defeat the purpose here because when summed the positive and negative differences would cancel each other. We then divide by n-1 and take the square root obtaining the result, the standard deviation, which is essentially the average absolute difference for the dataset.
Here is an example calculation of a standard deviation using real world analytical chemistry data. Figure 3 is a series of five mid-IR spectra of isopropyl (“rubbing”) alcohol dissolved in water. Thanks to Beer’s Law the peak size and area at 2973 cm-1 in these spectra vary with concentration (1,7). The volume percent isopropyl alcohol (IPA) and peak area data are seen in Table I.
By the way, I have too often heard in the cannabis analysis world that mid-IR spectroscopy is not quantitative. This is of course news to me since I have written a book on the subject (1). Many high pressure liquid chromatography (HPLC) cannabinoid detection methods use ultraviolet-visible (UV-vis) detection (8–10), which makes use of Beer’s Law. There are no theoretical or practical reasons why Beer’s Law won’t work at other wavelengths including the mid-IR, so it is absurd to say that Beer’s Law doesn’t work in a specific wavelength region. To put this issue to rest, a plot of the IPA% and peak area data from Table I is seen in Figure 4.
There is clearly an excellent linear relationship between volume percent and peak area in Figure 4 as expected from Beer’s Law, and the correlation coefficient (1), a measure of model quality we will discuss in a future column, is 0.999 where 1 is a perfect model. These data are proof that mid-IR spectroscopy is quantitative. So please no more blanket statements about infrared spectroscopy not being quantitative as it will make me pull my hair out, and believe me I don’t have that many hairs left!
To calculate the standard deviation of a data set we first have to calculate its average. For the peak area data in Table 1 the average is 5.42. Table II shows the peak areas, Xi, in the left hand column, the differences between each data point and the average, (Xi - µ), in the middle column, and the squared differences, (Xi - µ)2, in the right hand column, note the squared differences are all positive. The sum of the squared differences, ∑i = (Xi – µ)2, the numerator in equation 2, is in the bottom row and is 67.97.
To complete the standard deviation calculation we take 67.97, divide it by n-1 = 4, and take the square root. The answer is 4.12. What this calculation tells us is that on average each data point is 4.12 peak area units away from the average.
So, what does all this standard deviation stuff have to do with cannabis analysis? Recall from an earlier column the definitions of precision and accuracy (11). Briefly, precision measures how reproducible a set of measurements is, while accuracy is a measure of how far off you are from the true value. Table III shows a set of hypothetical weight percent (Wt.%) total tetrahydrocannabinol (THC) values measured on the same dried, ground marijuana sample.
Since these data are repeat measurements on the same sample, we can use this dataset to calculate the precision of the method used to make these measurements. The standard deviation of a set of repeated measurements is a common measure of precision. Recall that we must calculate the average of a dataset before calculating the standard deviation. Using equation 1, the average for the data in Table III is 24.4 Wt.% total THC, as indicated in the table. Using equation 2, we find that the standard deviation of these five measurements is 1.4 Wt. % total THC. Note that the standard deviation is reported in the units of the data set, be it Wt.% total THC, wt.% beta-caryophyllene, or parts per million of lead. So, what does the standard deviation mean in the context of the data in Table III? We would say that the precision of the method used to generate the data in Table III is ±1.4 Wt.% total THC, that is, the precision of the data is ±1.4 Wt.%.
What about standard deviation and accuracy? Remember that to calculate accuracy we need to have reference samples for which we know the correct answer. In previous columns I have bemoaned the lack of what the National Institutes of Standards and Technology (NIST) calls matrix reference materials or MRMs (12,13). An MRM is a sample of the matrix being analyzed with a known amount of the analytes of interest. In the cannabis industry examples of MRMs would be dried ground plant samples, extracts, or distillates with known cannabinoid concentrations. We are sorely lacking these in cannabis analysis except for hemp. The University of Kentucky has issued a series of four dried, ground hemp samples that have been analyzed by more than 60 laboratories across the United States (14). The certificates of analysis (COAs) of these samples contain the average of the analyses of these 60 laboratories for a number of cannabinoids including total THC, total cannabidiol (CBD), cannabidiolic acid (CBDA), and ∆-9 THC. The values in these COAs can be used as the right answers in accuracy calculations.
I have analyzed these four hemp matrix reference materials using mid-IR spectroscopy and published the results in this esteemed journal (15). A comparison of the known and measured total THC values for these samples is seen in Table IV.
The left hand column in Table IV contains the sample names, the second column shows the weight percent total THC as the average of the 60+ laboratories that have analyzed these samples by chromatography. The third column shows the total THC values as measured by mid-IR spectroscopy, and the fourth column shows the difference between the two methods for each sample. The standard deviation of a dataset like the one seen in column 4 of Figure 4 is a common measure of accuracy (1). The standard deviation here is 0.03 Wt.% total THC. The “SEP” in Table IV stands for standard error of prediction, which is the standard deviation between the known and predicted values for a set of validation samples. Given the data in Table IV we would then report that the accuracy of mid-IR spectroscopy for determining total THC in dried, ground hemp is ±0.03 Wt.% reported as a standard error of prediction.
When reporting accuracies sometimes the values can be reported as multiple of the standard deviation. For example, here we reported the accuracy as ±1σ; sometimes the accuracy is reported as ±2σ, or other multiples of σ. Thus, it is important to report what multiple of the standard deviation is being used in your accuracy measurement. To be complete then for Table IV, it is correct to say that “the accuracy for the determination of total THC in dried, ground hemp by mid-IR spectroscopy is 0.03 Wt.% as reported as a standard error of prediction at ±1 σ.” Why different multiples of the standard deviation are used to calculate accuracy gets into confidence limits, a topic for a future column.
The normal or Gaussian distribution is a result of the random error in a set of measurements. The top of this distribution is the average, and its width is characterized by the standard deviation. We saw how to calculate an average and calculate a standard deviation. We then used standard deviation calculations to determine the precision and accuracy in sets of total THC measurements.
Brian C. SMITH, PHD, is Founder, CEO, and Chief Technical Officer of Big Sur Scientific. He is the inventor of the BSS series of patented mid-infrared based cannabis analyzers. Dr. Smith has done pioneering research and published numerous peer-reviewed papers on the application of mid-infrared spectroscopy to cannabis analysis, and sits on the editorial board of Cannabis Science and Technology. He has worked as a laboratory director for a cannabis extractor, as an analytical chemist for Waters Associates and PerkinElmer, and as an analytical instrument salesperson. He has more than 30 years of experience in chemical analysis and has written three books on the subject. Dr. Smith earned his PhD on physical chemistry from Dartmouth College.
Direct correspondence to: firstname.lastname@example.org
How to Cite this Article
B. C. Smith, Cannabis Science and Technology 4(8), 8-13 (2021).