this is my code. Python creating weird plots. My question is why at first plot the measured
No answer yet for this question.
Ask a Tutor
Question:
this is my code. Python creating weird plots. My question is why at first plot the measured data (that is in rage from 0 to 140) is squished into a line, not the curve
Transcribed Image Text:
U lightbulb.py X RadioactiveDecay.py X 1 import numpy as np NAFA979987~~*~~~NINGFFFFFF4799: 2 import matplotlib.pyplot as plt 3 5 6 10 11 16 12 data_plate = np.loadtxt("C:/Users/Trota/OneDrive/Pa60 m/UT/PHY224 LAB/radioactive decay/20: 13 (sample_plate, counts_plate)= np.loadtxt("C:/Users/Trota/OneDrive/Pa m/UT/PHY224 LAB/rad 14 sample_plate = np.array([float(i) for i in sample_plate]) 15 counts_plate = np.array( [float(i) for i in counts_plate]) 17 18 19 # Define the model functions 20 def linear_function(x, a, b): return a * x + b 21 25 22 23 def exponential_function(x, a, b): return b* np.exp(a * x) 24 26 27 28 29 delta_t = 5.0 30 Ns= counts_plate - counts_back 34 31 rates = Ns/delta_t # Calculate rates (divide by At) 35 32 u_Ns = np.full(len(counts_plate),np.sqrt(len(counts_plate) + len(counts_back))) # Uncertainty in 33 u_rates = np.sqrt(u_Ns/delta_t) # Calculate rates (divide by At) 36 from scipy.optimize import curve_fit 37 data_background = np.loadtxt("2023_10_06_AM_background.txt", delimiter='\t', skiprows=2) (sample_back, counts_back)= np.loadtxt("2023_10_06_AM_background.txt", delimiter='\t', skiprows=2, sample_back = np.array([float(i) for i in sample_back]) counts_back = np.array([float(i) for i in counts_back]) 42 43 38 39 # Perform linear regression using curve_fit 40 params_linear, covariance_linear = curve_fit(linear_function, sample_plate, np.log(rates), sigma=np. a_linear, b_linear = params_linear 41 44 # Calculate the uncertainty for each data point 45 46 # Perform nonlinear regression using curve_fit params_nonlinear, covariance_nonlinear = curve_fit (exponential_function, sample_plate, rates, sigm: a_nonlinear, b_nonlinear = params_nonlinear 16 14 12 10 0.8 0.6 0.4 0.2 0.0 le12 -Linear regression Non-linear regression Measured data 10 20 30 Time, [s] 83 % Help Variable Explorer Plots Files 50 Console 1/A X Half-life value for nonlinear regression: -0.693 + 2.402374682648461e-19 minutes Reduced Chi-Squared (Linear Fit): 111.606 Reduced Chi-Squared (Nonlinear Fit): 437834544345145671680.00 In [189]: runfile('C:/Users/Trota/OneDrive/Pa60 m/UT/PHY224 LAB/ radioactive decay/RadioactiveDecay.py', wdir='C:/Users/Trota/OneDrive/Pa60u mo/UoT/PHY224 LAB/radioactive decay') Half-life value for linear regression: 2128.2 -40652980.466 seconds Half-life value for nonlinear regression: -0.693 2.402374682648461e-19 seconds Reduced Chi-Squared (Linear Fit): 111.606 Reduced Chi-Squared (Nonlinear Fit): 437834544345145671680.00 In [190]: U lightbulb.py X RadioactiveDecay.py X 1 import numpy as np NAFA979987~~*~~~NINGFFFFFF4799: 2 import matplotlib.pyplot as plt 3 5 6 10 11 16 12 data_plate = np.loadtxt("C:/Users/Trota/OneDrive/Pa60 m/UT/PHY224 LAB/radioactive decay/20: 13 (sample_plate, counts_plate)= np.loadtxt("C:/Users/Trota/OneDrive/Pa m/UT/PHY224 LAB/rad 14 sample_plate = np.array([float(i) for i in sample_plate]) 15 counts_plate = np.array( [float(i) for i in counts_plate]) 17 18 19 # Define the model functions 20 def linear_function(x, a, b): return a * x + b 21 25 22 23 def exponential_function(x, a, b): return b* np.exp(a * x) 24 26 27 28 29 delta_t = 5.0 30 Ns= counts_plate - counts_back 34 31 rates = Ns/delta_t # Calculate rates (divide by At) 35 32 u_Ns = np.full(len(counts_plate),np.sqrt(len(counts_plate) + len(counts_back))) # Uncertainty in 33 u_rates = np.sqrt(u_Ns/delta_t) # Calculate rates (divide by At) 36 from scipy.optimize import curve_fit 37 data_background = np.loadtxt("2023_10_06_AM_background.txt", delimiter='\t', skiprows=2) (sample_back, counts_back)= np.loadtxt("2023_10_06_AM_background.txt", delimiter='\t', skiprows=2, sample_back = np.array([float(i) for i in sample_back]) counts_back = np.array([float(i) for i in counts_back]) 42 43 38 39 # Perform linear regression using curve_fit 40 params_linear, covariance_linear = curve_fit(linear_function, sample_plate, np.log(rates), sigma=np. a_linear, b_linear = params_linear 41 44 # Calculate the uncertainty for each data point 45 46 # Perform nonlinear regression using curve_fit params_nonlinear, covariance_nonlinear = curve_fit (exponential_function, sample_plate, rates, sigm: a_nonlinear, b_nonlinear = params_nonlinear 16 14 12 10 0.8 0.6 0.4 0.2 0.0 le12 -Linear regression Non-linear regression Measured data 10 20 30 Time, [s] 83 % Help Variable Explorer Plots Files 50 Console 1/A X Half-life value for nonlinear regression: -0.693 + 2.402374682648461e-19 minutes Reduced Chi-Squared (Linear Fit): 111.606 Reduced Chi-Squared (Nonlinear Fit): 437834544345145671680.00 In [189]: runfile('C:/Users/Trota/OneDrive/Pa60 m/UT/PHY224 LAB/ radioactive decay/RadioactiveDecay.py', wdir='C:/Users/Trota/OneDrive/Pa60u mo/UoT/PHY224 LAB/radioactive decay') Half-life value for linear regression: 2128.2 -40652980.466 seconds Half-life value for nonlinear regression: -0.693 2.402374682648461e-19 seconds Reduced Chi-Squared (Linear Fit): 111.606 Reduced Chi-Squared (Nonlinear Fit): 437834544345145671680.00 In [190]:
Expert Answer:
Related Book For
Intermediate Algebra
ISBN: 9780134895987
13th Edition
Authors: Margaret Lial, John Hornsby, Terry McGinnis
Posted Date:
Students also viewed these programming questions
-
Mr. Urgent is the Chief Executive Officer (CEO) of one of the stable companies. He is very passionate about corporate valuation and growth. As a mean to enhance the value of the firm he advised to...
-
The 6-month futures price on a non-dividend-paying stock is $54.42. The risk-free rate is 3.52 percent and the market rate is 12.51 percent. What's the spot rate for this stock if spot-futures parity...
-
A. Conduct keyword research for at least twenty phrases related to the client's business. Based on this research, recommend the three phrases that in your opinion should be used for the client's...
-
Pick a job/project that you are familiar with similar in nature, time, and scope to building a 20' by 20' barn that includes electrical service and concrete floor. Construct a Work Package Assignment...
-
Assume that immediate modification is used in a system. Show, by an example, how an inconsistent database state could result if log records for a transaction are not output to stable storage prior to...
-
Prepare an income statement and a balance sheet for Lippo Group from the following scrambled list of items. What is the firms net working capital and debt ratio? In addition, the firm has 12,000...
-
Pisa Pizza Parlor is investigating the purchase of a new $45,000 delivery truck that would contain specially designed warming racks. The new truck would have a six-year useful life. It would save...
-
22 22 The atomic number of an element T is 10. T shows similar properties to an element with atomic number 23. 24. A. 14 B. 16 C. 18 d. 20 The electron configurations of elements W, X, Y and Z are...
-
Using the Public MACRO BITCOIN scorecard spreadsheet (linked in its associated masterclass lesson - Long Term 32), create a COPY of it and perform a complete analysis for the date 22/2/2022....
-
Johana has a savings account at Banco del Mediterrneo for $275,000, with an interest rate of 21% annually compounded bimonthly; The investment was made 3 years ago and he hopes to maintain it for 2...
-
How is a volatility surface used in option pricing?
-
What is a minimum variance delta?
-
What is the difference between the volatility smiles that are typically observed for equities and currencies?
-
We want to compute the linear convolution of a long sequence \(x(n)\), of length \(L\), with a short sequence \(h(n)\), of length \(K\). If we use the overlap-and-save method to compute the...
-
How is the BlackScholesMerton model used to value employee stock options?
-
The following events occurred during 2011 for various audit clients of your firm. Consider each event to be independent and the effect of each event to be material. A manufacturing company recognized...
-
In each of the following independent cases, document the system using whatever technique(s) your instructor specifies. a. Dreambox Creations (www.dreamboxcreations.com/) in Diamond Bar, California,...
-
Recall that corresponding sides of similar triangles are proportional. Use this fact to find the lengths of the indicated sides of each pair of similar triangles. Check all possible solutions in both...
-
Find the slope of each line passing through the given points or having the given equation. 4x + 7y = 3
-
Graph. y
-
If you have \($2\),500 to invest and need to withdraw \($4\),430 at some time in the future, what is the minimum number of whole years to leave the money invested at 5 percent?
-
If you invest \($1\),500 today and withdraw \($2\),500 in 3 years, what interest rate was earned?
-
At what interest rate will money a. double itself in 10 years? b. triple itself in 10 years? c. quadruple itself in 10 years?
Study smarter with the SolutionInn App