Physics 506, Numerical Methods & Statistics
This class had mainly coding assignments, and many of them are below. All are in python - feel free to do with them what you will, but please give credit where credit is due!
Final Project
- Final.pdf
In this project I first began playing with the fitting of supernova light curves. As big projects tend to go, it shifted directions and became focused on some of the details of preparing the data. The code is below:
Curve Fitting
- AnalyticFit.py:
Contains functions to implement chi2 minimization fourier fits to 1D and 2D data - mathfuncs.py:
Contains function smooth, used to implement the physics-based fitting algorithm described in the paper. Also contains a spline fitting algorithm. - LeastSq.py:
Contains Χ2 minimization algorithms adopted from Press et al, Numerical Recipies in C
Object Architecture
- Function1D.py:
Function1D class holds the x and y components of a regularly sampled function. Provides convolution, addition, integration, maximization, etc. - Function2D.py:
Function2D class holds the x,y,z components of a regularly sampled 2D function. Provides similar methods to Function1D. - Filter.py:
Filter class inherits the properties of Function1D, and is used to hold filter/passband information - FilterSet.py:
FilterSet class contains a set of Filter objects - Header.py:
Header file contains many of the global variables and functions used by multiple modules - Spectrum.py:
Spectrum class inherits the properties of Function1D, and provides a holder for spectral data - Spectrum2D.py:
Spectrum2D class inherits the properties of Function2D, and provides a holder for flux-wavelength-time spectral surfaces - Data1D.py:
Data1D class inherits the properties of Function1D, and adds error bars - Data2D.py:
Data2D class inherits the properties of Data2D, and adds error bars - LightCurve.py:
LightCurve class contains a FilterSet object, as well as a Data1D object corresponding to each Filter object in FilterSet. The Data1D objects contain the measured flux-time light curves within each passband. - LCfit.py:
Contains code used to test and graph various fitting schemes
Numerical Integration
- Romberg.py:
the Romberg method of numerical integration - TrapInt.py:
the Trapezoidal method of numerical integration - SampleMean.py:
the Sample Mean Monte Carlo method of numerical integration - HitOrMiss.py:
the Hit-or-Miss Monte Carlo method of numerical integration - ImpSamp.py:
the Importance Sampling Monte Carlo method of numerical integration
Distributions
- Distributions.py:
Poisson, Binomial, Gaussian...fun with distributions! - Gaussian.py:
Four different Monte-Carlo methods for generating a gaussian distribution: Box-Muller, von Neumann, Metropolis, and central-limit theorem
Linear Algebra
- Lanczos.py:
the lanczos algorithm for diagonalizing a matrix
Optimization
- simplex.py:
a simplex algorithm for the minimization - simplex_debug.py:
a module I used to debug the above algorithm, using Rosenbrock's function (a common 2n dimensional test-case for minimization schemes)