Practicals

 Session 1

Exercise 1

  1. Simulate a number N of random points uniformly distributed inside a square.
  2. Count the fraction of these points that fall within the inscribed circle and use the result to estimate π. How does the accuracy of the evaluation depend on N?
  3. Plot the points in a graph, using different colors for those inside and outside the circle.
  4. Refine the plot by adding a title and axis labels, choosing the appropriate aspect ratio etc.

Exercise 2

  1. Load the data in file histogram.dat.
  2. Compute and plot the histogram of these values. How did you choose the range and bin size?
  3. Refine the plot as above.

Solutions

In Python: Solution_1.py

Session 2

Exercise 1

  1. Generate a number N of random values uniformly distributed in the interval [0 , 2].
  2. Plot their histogram.
  3. For each value k from 2 to 10 generate N values, each of them being the sum of k random values uniformly distributed in the interval [0 , 2].
  4. Plot the histogram of these values for each k.

Exercise 2

  1. Load the data in file Anscombe.txt. It contains four pairs of columns (xi, yi), for i ranging from 1 to 4.
  2. Compute the mean and standard deviation for each column. Compare these values for the x and y columns, respectively.
  3. Compute Pearson’s correlation coefficient r(xi, yi) for each pair. Compare these values.
  4. Plot the four graphs yi vs xi. How would you describe the data in each graph?

Solutions

In Python: Solution_2.py

Session 3

No practicals

Session 4

Exercise 1

  1. A sample of 100 individuals from a given population contains 56 women and 44 men.
  2. What can one say about the null hypothesis: "The (total) population is evenly distributed by gender"?

Exercise 2

Solve the dice fairness problem available here.

Exercise 3

Solve Exercice 7.8 in [Barlow, 1993].

Exercise 4

  1. You are given a small set of (<10) measurements of a physical parameter. Estimate the value of the parameter with 95% confidence. You will need Student's t distribution.
  2. What happens if you approximate Student's t distribution by the normal distribution?

Solutions

In Python: Solution_4.py

Session 5

  1. Load and plot the data (x, y, σ) from file Tofit.txt.
  2. Perform a straight-line fit: y = a + bx
  3. Estimate the fit parameters a and b with 95% confidence. Compute the covariance Cov(a,b).
  4. Compute and display the confidence band at the same 95% level.
  5. Plot the scale residuals (use a common x axis with the graph at point 1.).
  6. Redo points 2. and 3. explicitly (using the weighted sums Sx, Sxx, Sxy, etc.)

Solutions

In Python: Solution_5.py

Session 6

We will use two standard nonlinear regression datasets from the NIST. In both cases, the background is zero (the ε in the models represents the error).

Exercise 1

  1. Load and plot the data for set Eckerle 4. Implement the fitting function given with the data (a non-standard Gaussian with parameters β1, β2, and β3).
  2. Do the fit and give the best parameter values with 68% confidence. Display the residuals and compute the covariance matrix between the coefficients.
  3. Do you obtain the certified coefficients? How did your software deal with the lack of error bars?
  4. Normalize the covariance matrix to obtain the correlation matrix. Discuss the correlation between width and amplitude.
  5. [Homework] Plot the χ2 function for a range of ±2σ around the minimum for the amplitude and width (β1 and β2).

Exercise 2

  1. Load and plot the data for set Gauss 3. Implement the fitting function given with the data (Two Gaussians and an exponential background).
  2. Do the fit and give the best parameter values with 68% confidence. Display the residuals and compute the covariance matrix between the coefficients.
  3. Do you obtain the certified coefficients?
  4. Compute the histogram of the residuals. Choose the bin width carefully.
  5. Do a lag plot of the residues (with a 1-point lag). Display it in a “square” graph (x and y units should be equal). 
  6. Normalize the covariance matrix to obtain the correlation matrix. Are there strong correlations between some coefficients? Why is that?
  7. [Homework] What is your confidence that the residuals are only due to Gaussian noise?

Solutions

In Python: Solution_6.py

 

No comments:

Post a Comment

Introduction

Performing research in experimental physics involves acquiring, processing, analyzing and interpreting data with much higher proficiency tha...