Chemical Kinetics
Rate Data
Rate Constant
Equation of a Line
Checkpoint
Half Life
Summary
Equation of a Line
You learned about libraries in lesson 3. We can use the scipy library to find the equation of this line. This function will return the values for the slope, the y-intercept, and a value called R^2. R^2 is always a number between zero and one. A value of zero tells you that your data doesn’t remotely follow a line while a value of 1 means your data lies on a perfect line.
What do you think the R^2 value for the data you graphed in part 2 is?
Let's test it. I've shown the code below. Remember that the slope of the line is the rate constant, which we call k.
1 import pip
2 import numpy
3 import scipy
4 from scipy import stats
5 import pandas
6
7 # We start by loading the excel file.
8 carbon_decay_2=pandas.read_csv('carbondecaywithnoise.csv')
9
10 logC_14=numpy.log(carbon_decay_2.C14_Con)
11
12 #The best fit function returns values in what is called an array. The first value is the slope, the second is the y-intercept of the best fit line, and the third is the r^2 value. It also returns some other data we will ignore for now and prints them on the screen to the right.
13
14 best_fit = scipy.stats.linregress(carbon_decay_2.Time, logC_14)
15
16 #If we want to, we can assign each of the values in the array individual variables by using square brackets with the number of the position of the value we care about. Note that computer languages start counting at zero. So the slope is position 0 of the best_fit we created above.
17
18 slope=best_fit[0]
19 intercept=best_fit[1]
20 r_square=best_fit[2]
21 print(slope)
22 print(intercept)
23 print(best_fit)
In real science, things aren’t quite this nice. Even the most careful scientists with the best instruments don’t measure exactly accurate values every time. There is some uncertainty in all measurements, and we call this noise. The third column of the cvs file (called C14_Con_noisy) has some uncertainty built into the measurements. Try repeating the steps you’ve already done for this data. What does the curve of C-14 concentration v time look like? What does the best-fit line look like? What is the new R-squared value? What about your rate constant? Make a prediction, and then try figuring it out below!
Notice how the noise gets bigger by 12,000 years. As the sample gets older, you are measuring smaller and smaller amounts of carbon-14. That makes it harder to tell how much of your measurement is "real" and how much is just noise. On samples that are too old, scientists can't use carbon dating to tell the age at all, and have to use other techniques. Next we will talk about half-lives and how they can help us carbon-date old samples.