7.12. Example exam#

An example of a Python / data-analysis exam.

7.12.1. Task 1#

In this task you will show that you understand the basics of Python.

  1. Make an array “x_raw” running from 0 to 100 (including both 0 and 100) with an interval where all elements are integers (so [0,1,2,3…100]). (1pt)

  2. Now use x_raw to make a new array “x_even” which consists of all even numbers in the array “x_raw”. (1pt)

  3. Define a function \(f(a,x)\) that returns \(a \cdot x^2\). Use it to make an array \(y = f(2.0,x\)_\(even)\). (1pt)

  4. Now, replace \(y=f(2.0,20)\) by 2500. Note, counting to the index corresponding to \(f(2.0, 20)\) by hand is not allowed! (1pt)

We now have a distorted dataset.

  1. Use curve fitting to find the best value of \(a\) and the uncertainty in \(a\). Present the two values as an experimental physicist would do. (3pt)

  2. Make a test array from 0 to 100 with an interval of 0.1 and use this test array to graph the function fit into the data. Show the function fit as a dotted red line. (3pt)

# Your code

7.12.2. Task 2#

A physical quantity \(A\) has been measured in order to calculate a different physical quantity \(Z\). The value of \(A\) is 1.075 ± 0.003.

Calculate the physical quantity \(Z\) and its uncertainty using the calculus approach for:

  1. \(Z = 2.5 \cdot \sin(2\pi A)\) (3pt)

and the functional approach for:

  1. \(Z = \sqrt{3}\cdot A^{4}\) (3pt)

(Disregard the unit(s))

# Your code

7.12.3. Task 3#

In your final project you received a dataset stored in ‘data.csv’. You are asked to (1) investigate the pattern in the data, (2) define a function that probably fits that pattern, (3) use curve fitting to present the values of the parameters and their uncertainties, (4) plot the fit on the data and study the residuals: investigate whether this these are random noise that can be described using a Gaussian distribution and if so, what the standard deviation is of that noise.

First load the ‘data.csv’ file (data.csv). Then carry out this data-analysis. (9pt)

# Your code