hw6_sol - #! /usr/bin/env python # AST5765/4762 2009 HW6...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#! /usr/bin/env python # AST5765/4762 2009 HW6 Solutions # NOTE: This assignment uses Monte Carlo methods to generate datasets. # This means that you may get different numbers from those presented # here. In the elimination questions, you may eliminate all 4 bad # points right away, or have one that is within the data's range and # is never gotten rid of. Try running it more than once to get a # sense for how it behaves. import numpy as np import matplotlib.pyplot as plt import numpy.random as NR import sinexp as se # Problem 1 rng = 10. ssize = 100 a = 1.2 b = 3.2 ssig = 0.5 smean = 0. x = NR.uniform(0., rng, ssize) # Sorting helps the plots later and doesn't hurt here x = np.sort(x) e = NR.normal(loc=smean, scale=ssig, size=ssize) # These are the error estimates in ye. s = np.zeros(ssize) + ssig y = a + b*x ye = y + e # Problem 2 import linfit (af, bf, a_unc, b_unc, chisq, prob, covar, yfit) = linfit.linfit(ye, x, s) print('# a = %f +- %f' % (af, a_unc)) print('# b = %f +- %f' % (bf, b_unc)) print('# chisq = %f' % chisq) print('# prob = %f' % prob) print('# covar = ') print('# ' + str(covar)) print('# reduced chisq = %f' % (chisq / (x.size - 2))) # a = 1.302346 +- 0.101522 # b = 3.178746 +- 0.017428 # chisq = 121.792256 # prob = 0.052043 # covar = # [[ 0.01030671 -0.00153986] # [-0.00153986 0.00030374]] # reduced chisq = 1.242778 print np.abs((a-af)/a_unc) # 1.00812021102 - yes, this is less than 3 print np.abs((b-bf)/b_unc) # 1.21953783266 - yes, this is less than 3 # Problem 3 print(prob)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
# 0.052042802098, or about 5%. This is ok. This is chance, after # all, and there will be some 2-sigma outliers. If it's 0.1%, then # worry (and see below for a truly bad fit). plt.clf()
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/09/2009 for the course AST 4762 taught by Professor Harrington during the Fall '09 term at University of Central Florida.

Page1 / 5

hw6_sol - #! /usr/bin/env python # AST5765/4762 2009 HW6...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online