Jupyter notebook CDS-102/Lab Week 08 - Statistical distribution of speed-of-light measurements/CDS-102 Lab Week 08 Workbook.ipynb
CDS-102: Lab 8 Workbook
Helena Gray
March 23, 2017
The code below imports the tidyverse package which will be used for analysis. It then reads in a comma separate value file into a variable named 'newcomb'.
Lab Task 1
The code below plots a histogram of the dataset using ggplot2.
Lab Task 2
A variable is created called 'newcomb_1' which filters out all the values of 'x' under 0.
Lab Task 3
The code below gives summary statistics for the filtered data set 'newcomb' and the unfiltered dataset 'newcomb_1'.
Lab Task 4
The code below uses the dnorm() function to calculate the probability distribution for the filtered and unfiltered datasets. It takes the 'x' values (from the distribution) as input and returns the probability (taken from the bell curve) as output.
Lab Task 5
The code below converts the histogram (unfiltered dataset only) into a probability mass function using the ggplot_build() function and stores the PMF values in a tibble.
Lab Task 6
A plot is created that overlays the normal distribution models on top of the PMF to see how well that they agree.
Lab Task 7
The code below creates a cumulative distribution function generator for both the unfiltered and filtered datasets using the ecdf() function. Two tibbles are created, each with two columns. In each tibble the first column is t that contains values running from -45 to 45 in increments of 0.1, and the second column is cdf containing values of the cdf generator evaluated at the same values of t.
Lab Task 8
The code below creates the corresponding CDF for the normal distribution models (both unfiltered and filtered) using the qnorm() function. The two CDFs are evaluated in the range from 0 to 1 in increments of 0.01. The results are stored in two tibbles, each with two columns (this includes t, which is just the 0 to 1 range in increments of 0.01, and the CDF values).
Lab Task 9###
The code below visually compares the CDFs of models and datasets to estimate the quality of agreement. 2 plots are created that overlay the two model CDFs on top of the unfiltered and filtered datasets CDFs.
Lab Task 10
The code below calculates the confidence interval for the unfiltered and filtered datasets, and then prints out the two versions of the experimental result in the format mean ± confidence interval.
The code below performs a 1 sample t-test which can tell us the probability that the confidence interval obtained contains the true mean.