$34.99
• Reading Data Files:
• Fitting Regression Lines to data
(1) Write a function readDatFile(inFile) to read in the coffee cooling data. The function should take a filename as a parameter (input by the user) and should return the numpy arrays x, y containing the data.
(2) Using Regression to Determine Model Parameters:
(a) The file coffeeCooling.txt alongside, holds the time, Temp data for coffee cooling. Create a program that reads the data from the file and using matplotlib.pyplot To scatter-plot the data. Use the pyplot functions xlabel( ), ylabel( ) to label the axes approriately.
(b) A model of coffee cooling in a room at T0 = 22oC is:
∆T = Tn+1−Tn = −k(Tn−T0). Use the function scipy.stats.linregress(x,y)
(usage: slope, intercept, r value, p value, std err = stats.linregress(x,y)), to make a fit of the coffee data given above. Make a plot of the regression line fit, superposed on a scatter plot of ∆Tn v/s Tn − T0.
(3) Fitting a Power Law Function Small nanoparticles of soot suspended in water start to aggregate when salt is added. The average radius r of the aggregates is predicted to grow as a power law in time t according to the equation r = r0tn. (The data is in the file sootAggregation.txt. The columns are: time (mins), Avg. Radius (nm), Uncertainty in Radius (nm)). Taking the logarithm of this equation gives lnr = nlnt+lnr0. Thus the data should fall on a straight line if lnr is plotted vs lnt. Fit a regression line to the data using lnr = nlnt + lnr0 and find values for n and r0.
1