diff --git a/HW6/.~lock.Primary_Energy_monthly.csv# b/HW6/.~lock.Primary_Energy_monthly.csv#
new file mode 100644
index 0000000..eef216f
--- /dev/null
+++ b/HW6/.~lock.Primary_Energy_monthly.csv#
@@ -0,0 +1 @@
+,ryan,fermi,31.03.2017 16:47,file:///home/ryan/.config/libreoffice/4;
\ No newline at end of file
diff --git a/HW6/README.md b/HW6/README.md
new file mode 100644
index 0000000..1f3c86c
--- /dev/null
+++ b/HW6/README.md
@@ -0,0 +1,86 @@
+# Homework #6
+## due 4/14 by 11:59pm
+
+
+0. Create a new github repository called 'curve_fitting'.
+
+ a. Add rcc02007 and pez16103 as collaborators.
+
+ b. Clone the repository to your computer.
+
+
+1. Create a least-squares function called `least_squares.m` that accepts a Z-matrix and
+dependent variable y as input and returns the vector of best-fit constants, a, the
+best-fit function evaluated at each point $f(x_{i})$, and the coefficient of
+determination, r2.
+
+```matlab
+[a,fx,r2]=least_squares(Z,y);
+```
+
+ Test your function on the sets of data in script `problem_1_data.m` and show that the
+ following functions are the best fit lines:
+
+ a. y=0.3745+0.98644x+0.84564/x
+
+ b. y=-11.4887+7.143817x-1.04121 x^2+0.046676 x^3
+
+ c. y=4.0046e^(-1.5x)+2.9213e^(-0.3x)+1.5647e^(-0.05x)
+
+
+2. Use the Temperature and failure data from the Challenger O-rings in lecture_18
+(challenger_oring.csv). Your independent variable is temerature and your dependent
+variable is failure (1=fail, 0=pass). Create a function called `cost_logistic.m` that
+takes the vector `a`, and independent variable `x` and dependent variable `y`. Use the
+function, $\sigma(t)=\frac{1}{1+e^{-t}}$ where $t=a_{0}+a_{1}x$. Use the cost function,
+
+ $J(a_{0},a_{1})=\sum_{i=1}^{n}\left[-y_{i}\log(\sigma(t_{i}))-(1-y_{i})\log((1-\sigma(t_{i})))\right]$
+
+ and gradient
+
+ $\frac{\partial J}{\partial a_{i}}=
+ 1/m\sum_{k=1}^{N}\left(\sigma(t_{k})-y_{k}\right)t_{k}$
+
+ a. edit `cost_logistic.m` so that the output is `[J,grad]` or [cost, gradient]
+
+ b. use the following code to solve for a0 and a1
+
+```matlab
+% Set options for fminunc
+options = optimset('GradObj', 'on', 'MaxIter', 400);
+% Run fminunc to obtain the optimal theta
+% This function will return theta and the cost
+[theta, cost] = ...
+fminunc(@(a)(costFunction(a, x, y)), initial_a, options);
+```
+
+ c. plot the data and the best-fit logistic regression model
+
+```matlab
+plot(x,y, x, sigma(a(1)+a(2)*x))
+```
+
+3. The vertical stress under a corner of a rectangular area subjected to a uniform load of
+intensity $q$ is given by the solution of the Boussinesq's equation:
+
+ $\sigma_{z} =
+ \frac{q}{4\pi}\left(\frac{2mn\sqrt{m^{2}+n^{2}+1}}{m^{2}+n^{2}+1+m^{2}n^{2}}\frac{m^{2}+n^{2}+2}{m^{2}+n^{2}+1}+sin^{-1}\left(\frac{2mn\sqrt{m^{2}+n^{2}+1}}{m^{2}+n^{2}+1+m^{2}n^{2}}\right)\right)$
+
+ Typically, this equation is solved as a table of values where:
+
+ $\sigma_{z}=q f(m,n)$
+
+ where $f(m,n)$ is the influence value, q is the uniform load, m=a/z, n=b/z, a and b are
+ width and length of the rectangular area and z is the depth below the area.
+
+ a. Finish the function `boussinesq_lookup.m` so that when you enter a force, q,
+ dimensions of rectangular area a, b, and depth, z, it uses a third-order polynomial
+ interpolation of the four closest values of m to determine the stress in the vertical
+ direction, sigma_z=$\sigma_{z}$. Use a $0^{th}$-order, polynomial interpolation for
+ the value of n (i.e. round to the closest value of n).
+
+ b. Copy the `boussinesq_lookup.m` to a file called `boussinesq_spline.m` and use a
+ cubic spline to interpolate in two dimensions, both m and n, that returns sigma_z.
+
+
+
diff --git a/HW6/README.pdf b/HW6/README.pdf
new file mode 100644
index 0000000..3cc8991
Binary files /dev/null and b/HW6/README.pdf differ
diff --git a/HW6/boussinesq_lookup.m b/HW6/boussinesq_lookup.m
new file mode 100644
index 0000000..004c91c
--- /dev/null
+++ b/HW6/boussinesq_lookup.m
@@ -0,0 +1,22 @@
+function sigma_z=boussinesq_lookup(q,a,b,z)
+ % function that determines stress under corner of an a by b rectangular platform
+ % z-meters below the platform. The calculated solutions are in the fmn data
+ % m=fmn(:,1)
+ % in column 2, fmn(:,2), n=1.2
+ % in column 3, fmn(:,2), n=1.4
+ % in column 4, fmn(:,2), n=1.6
+
+ fmn= [0.1,0.02926,0.03007,0.03058
+ 0.2,0.05733,0.05894,0.05994
+ 0.3,0.08323,0.08561,0.08709
+ 0.4,0.10631,0.10941,0.11135
+ 0.5,0.12626,0.13003,0.13241
+ 0.6,0.14309,0.14749,0.15027
+ 0.7,0.15703,0.16199,0.16515
+ 0.8,0.16843,0.17389,0.17739];
+
+ m=a/z;
+ n=b/z;
+
+ %...
+end
diff --git a/HW6/cost_logistic.m b/HW6/cost_logistic.m
new file mode 100644
index 0000000..169718f
--- /dev/null
+++ b/HW6/cost_logistic.m
@@ -0,0 +1,27 @@
+function [J, grad] = cost_logistic(a, x, y)
+% cost_logistic Compute cost and gradient for logistic regression
+% J = cost_logistic(theta, X, y) computes the cost of using theta as the
+% parameter for logistic regression and the gradient of the cost
+% w.r.t. to the parameters.
+
+% Initialize some useful values
+N = length(y); % number of training examples
+
+% You need to return the following variables correctly
+J = 0;
+grad = zeros(size(theta));
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Compute the cost of a particular choice of a.
+% Compute the partial derivatives and set grad to the partial
+% derivatives of the cost w.r.t. each parameter in theta
+%
+% Note: grad should have the same dimensions as theta
+%
+
+
+
+% =============================================================
+
+end
+
diff --git a/HW6/problem_1_data.m b/HW6/problem_1_data.m
new file mode 100644
index 0000000..6af2956
--- /dev/null
+++ b/HW6/problem_1_data.m
@@ -0,0 +1,15 @@
+
+% part a
+xa=[1 2 3 4 5]';
+yb=[2.2 2.8 3.6 4.5 5.5]';
+
+% part b
+
+xb=[3 4 5 7 8 9 11 12]';
+yb=[1.6 3.6 4.4 3.4 2.2 2.8 3.8 4.6]';
+
+% part c
+
+xc=[0.5 1 2 3 4 5 6 7 9];
+yc=[6 4.4 3.2 2.7 2.2 1.9 1.7 1.4 1.1];
+
diff --git a/README.md b/README.md
index 8145faf..134beea 100644
--- a/README.md
+++ b/README.md
@@ -49,7 +49,7 @@ Jupiter notebook (with matlab or octave kernel)
### Note on Homework and online forms
-The Homeworks are graded based upon effort and completeness. The forms are not graded at
+The Homeworks are graded based upon effort, correctness, and completeness. The forms are not graded at
all, if they are completed you get credit. It is *your* responsibility to make sure your
answers are correct. Use the homeworks and forms as a study guide for the exams. In
general, I will not post homework solutions.
diff --git a/lecture_16/lecture_16.ipynb b/lecture_16/lecture_16.ipynb
index be266b3..206e84c 100644
--- a/lecture_16/lecture_16.ipynb
+++ b/lecture_16/lecture_16.ipynb
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 171,
"metadata": {
"collapsed": true
},
@@ -13,7 +13,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 172,
"metadata": {
"collapsed": true
},
@@ -119,7 +119,7 @@
},
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": 173,
"metadata": {
"collapsed": false
},
@@ -773,7 +773,7 @@
},
{
"cell_type": "code",
- "execution_count": 25,
+ "execution_count": 174,
"metadata": {
"collapsed": false
},
@@ -811,7 +811,7 @@
},
{
"cell_type": "code",
- "execution_count": 27,
+ "execution_count": 175,
"metadata": {
"collapsed": false
},
@@ -830,7 +830,7 @@
},
{
"cell_type": "code",
- "execution_count": 28,
+ "execution_count": 177,
"metadata": {
"collapsed": false
},
@@ -849,7 +849,7 @@
},
{
"cell_type": "code",
- "execution_count": 83,
+ "execution_count": 180,
"metadata": {
"collapsed": false
},
@@ -896,561 +896,539 @@
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
"\n",
"\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t0\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
- "\t\t0.05\n",
+ "\t\t\n",
+ "\t\t5\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
- "\t\t0.1\n",
+ "\t\t\n",
+ "\t\t10\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
- "\t\t0.15\n",
+ "\t\t\n",
+ "\t\t15\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
- "\t\t0.2\n",
+ "\t\t\n",
+ "\t\t20\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t-20\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t-15\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t-10\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t-5\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t0\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t5\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t10\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t15\n",
"\t\n",
"\n",
"\n",
"\n",
"\n",
- "\t\n",
- "\n",
- "\t\n",
- "\t\trelative counts\n",
- "\t\n",
- "\n",
- "\n",
- "\t\n",
- "\t\tx position (cm)\n",
- "\t\n",
- "\n",
+ "\t\n",
"\n",
"\n",
"\tgnuplot_plot_1a\n",
- "\n",
+ "\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_2a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_3a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_4a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_5a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_6a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_7a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_8a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_9a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_10a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_11a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_12a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_13a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_14a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_15a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_16a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_17a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_18a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_19a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_20a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_21a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_22a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_23a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_24a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_25a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_26a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_27a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_28a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_29a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_30a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_31a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_32a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_33a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_34a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_35a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_36a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_37a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_38a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_39a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_40a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_41a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_42a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_43a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_44a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_45a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_46a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_47a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_48a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_49a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_50a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_51a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_52a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_53a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_54a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_55a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_56a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_57a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_58a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_59a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_60a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_61a\n",
"\n",
"\n",
"\n",
- "\t\n",
- "\t\n",
- "\tgnuplot_plot_62a\n",
- "\n",
- "\t\n",
- "\t\n",
- "\tgnuplot_plot_63a\n",
- "\n",
- "\t\n",
- "\t\n",
- "\tgnuplot_plot_64a\n",
- "\n",
- "\t\n",
+ "\t\n",
"\t\n",
- "\n",
+ "\n",
"\n",
"\n",
"\n",
@@ -1470,27 +1448,12 @@
}
],
"source": [
- "x_vals=linspace(-15,20,30);\n",
- "hist(x_darts,x_vals,1);\n",
- "[histFreq, histXout] = hist(x_darts, 30);\n",
- "binWidth = histXout(2)-histXout(1);\n",
- "bar(histXout, histFreq/binWidth/sum(histFreq));\n",
- "pdfnorm = @(x) 1/sqrt(2*s_x^2*pi).*exp(-(x-mu_x).^2/2/s_x^2);\n",
- "%cdfnorm = @(x) 1/2*(1+erf((x-mu_x)./sqrt(2*s_x^2)));\n",
- "%hist(x_darts,x_vals,trapz(x,f))%,cdfnorm(max(x_darts))/2)\n",
- "hold on;\n",
- "plot(x_vals,pdfnorm(x_vals))\n",
- "n=2; % n=1, 68% confidence, n=2, 95% confidence, n=3, 99% conf\n",
- " plot([mu_x+n*s_x,mu_x+n*s_x],[0,0.1],'r-')\n",
- " plot([mu_x-n*s_x,mu_x-n*s_x],[0,0.1],'r-')\n",
- "\n",
- "xlabel('x position (cm)')\n",
- "ylabel('relative counts')"
+ "hist(x_darts,30,100)"
]
},
{
"cell_type": "code",
- "execution_count": 84,
+ "execution_count": 182,
"metadata": {
"collapsed": false
},
@@ -1628,450 +1591,450 @@
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_2a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_3a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_4a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_5a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_6a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_7a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_8a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_9a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_10a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_11a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_12a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_13a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_14a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_15a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_16a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_17a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_18a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_19a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_20a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_21a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_22a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_23a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_24a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_25a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_26a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_27a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_28a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_29a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_30a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_31a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_32a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_33a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_34a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_35a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_36a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_37a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_38a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_39a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_40a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_41a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_42a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_43a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_44a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_45a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_46a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_47a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_48a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_49a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_50a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_51a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_52a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_53a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_54a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_55a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_56a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_57a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_58a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_59a\n",
"\n",
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_60a\n",
"\n",
"\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_61a\n",
"\n",
@@ -2081,15 +2044,15 @@
"\t\n",
"\tgnuplot_plot_62a\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_63a\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\tgnuplot_plot_64a\n",
"\n",
- "\t\n",
+ "\t\n",
"\t\n",
"\n",
"\n",
@@ -2111,19 +2074,19 @@
}
],
"source": [
- "y_vals=linspace(-15,20,30);\n",
- "hist(y_darts,y_vals,1);\n",
- "[histFreq, histXout] = hist(y_darts, 30);\n",
+ "x_vals=linspace(-15,20,30);\n",
+ "hist(x_darts,x_vals,1);\n",
+ "[histFreq, histXout] = hist(x_darts, 30);\n",
"binWidth = histXout(2)-histXout(1);\n",
"bar(histXout, histFreq/binWidth/sum(histFreq));\n",
- "pdfnorm = @(x) 1/sqrt(2*s_y^2*pi).*exp(-(x-mu_y).^2/2/s_y^2);\n",
+ "pdfnorm = @(x) 1/sqrt(2*s_x^2*pi).*exp(-(x-mu_x).^2/2/s_x^2);\n",
"%cdfnorm = @(x) 1/2*(1+erf((x-mu_x)./sqrt(2*s_x^2)));\n",
"%hist(x_darts,x_vals,trapz(x,f))%,cdfnorm(max(x_darts))/2)\n",
"hold on;\n",
- "plot(y_vals,pdfnorm(y_vals))\n",
+ "plot(x_vals,pdfnorm(x_vals))\n",
"n=2; % n=1, 68% confidence, n=2, 95% confidence, n=3, 99% conf\n",
- " plot([mu_y+n*s_y,mu_y+n*s_y],[0,0.1],'r-')\n",
- " plot([mu_y-n*s_y,mu_y-n*s_y],[0,0.1],'r-')\n",
+ " plot([mu_x+n*s_x,mu_x+n*s_x],[0,0.1],'r-')\n",
+ " plot([mu_x-n*s_x,mu_x-n*s_x],[0,0.1],'r-')\n",
"\n",
"xlabel('x position (cm)')\n",
"ylabel('relative counts')"
@@ -2131,7 +2094,7 @@
},
{
"cell_type": "code",
- "execution_count": 76,
+ "execution_count": 183,
"metadata": {
"collapsed": false
},
@@ -2178,5238 +2141,17319 @@
"\n",
"\n",
"\t\n",
- "\t\t\n",
+ "\t\t\n",
"\t\n",
"\n",
"\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t0\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
- "\t\t0.2\n",
+ "\t\t\n",
+ "\t\t0.05\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
- "\t\t0.4\n",
+ "\t\t\n",
+ "\t\t0.1\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
- "\t\t0.6\n",
+ "\t\t\n",
+ "\t\t0.15\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
- "\t\t0.8\n",
+ "\t\t\n",
+ "\t\t0.2\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
- "\t\t1\n",
+ "\t\t\n",
+ "\t\t-20\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t-15\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t-10\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t-5\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t0\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t5\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t10\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
+ "\t\t\n",
"\t\t15\n",
"\t\n",
"\n",
"\n",
- "\t\t\n",
- "\t\t20\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\t\trelative counts\n",
"\t\n",
"\n",
"\n",
+ "\t\n",
+ "\t\tx position (cm)\n",
+ "\t\n",
"\n",
"\n",
- "\t\n",
+ "\n",
+ "\tgnuplot_plot_1a\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_2a\n",
+ "\n",
+ "\n",
"\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_3a\n",
+ "\n",
"\n",
- "\n",
+ "\n",
+ "\t\n",
+ "\t\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_4a\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_5a\n",
+ "\n",
"\n",
"\n",
- "\t\n",
- "\texperimental CDF\n",
- "\n",
+ "\t\n",
+ "\t\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_6a\n",
+ "\n",
"\n",
- "\n",
- "\t\n",
- "\t\texperimental CDF\n",
+ "\n",
+ "\t\n",
"\t\n",
+ "\tgnuplot_plot_7a\n",
+ "\n",
"\n",
- "\n",
- "\t\n",
+ "\n",
+ "\t\n",
+ "\t\t\n",
"\t\n",
- "\tNormal CDF\n",
- "\n",
- "\t\n",
- "\t\tNormal CDF\n",
+ "\t\n",
"\t\n",
+ "\tgnuplot_plot_8a\n",
+ "\n",
"\n",
- "\n",
- "\t\n",
+ "\n",
+ "\t\n",
"\t\n",
- "\n",
+ "\tgnuplot_plot_9a\n",
+ "\n",
"\n",
- "\n",
+ "\n",
+ "\t\n",
+ "\t\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_10a\n",
+ "\n",
"\n",
- "\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_11a\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_12a\n",
+ "\n",
"\n",
"\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_13a\n",
+ "\n",
"\n",
+ "\n",
+ "\t\n",
+ "\t\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_14a\n",
+ "\n",
"\n",
- ""
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "x_exp=empirical_cdf(x_vals,x_darts);\n",
- "plot(x_vals,x_exp)\n",
- "hold on;\n",
- "plot(x_vals,normcdf(x_vals,mu_x,s_x),'k-')\n",
- "legend('experimental CDF','Normal CDF','Location','SouthEast')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 170,
- "metadata": {
- "collapsed": false
- },
- "outputs": [
- {
- "data": {
- "image/svg+xml": [
- ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "y_vals=linspace(-15,20,30);\n",
+ "hist(y_darts,y_vals,1);\n",
+ "[histFreq, histXout] = hist(y_darts, 30);\n",
+ "binWidth = histXout(2)-histXout(1);\n",
+ "bar(histXout, histFreq/binWidth/sum(histFreq));\n",
+ "pdfnorm = @(x) 1/sqrt(2*s_y^2*pi).*exp(-(x-mu_y).^2/2/s_y^2);\n",
+ "%cdfnorm = @(x) 1/2*(1+erf((x-mu_x)./sqrt(2*s_x^2)));\n",
+ "%hist(x_darts,x_vals,trapz(x,f))%,cdfnorm(max(x_darts))/2)\n",
+ "hold on;\n",
+ "plot(y_vals,pdfnorm(y_vals))\n",
+ "n=2; % n=1, 68% confidence, n=2, 95% confidence, n=3, 99% conf\n",
+ " plot([mu_y+n*s_y,mu_y+n*s_y],[0,0.1],'r-')\n",
+ " plot([mu_y-n*s_y,mu_y-n*s_y],[0,0.1],'r-')\n",
+ "\n",
+ "xlabel('x position (cm)')\n",
+ "ylabel('relative counts')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 76,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "image/svg+xml": [
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "x_exp=empirical_cdf(x_vals,x_darts);\n",
+ "plot(x_vals,x_exp)\n",
+ "hold on;\n",
+ "plot(x_vals,normcdf(x_vals,mu_x,s_x),'k-')\n",
+ "legend('experimental CDF','Normal CDF','Location','SouthEast')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 185,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "image/svg+xml": [
+ "