NASSP Masters 5003F - Computational Astronomy - 2010 Lecture 4 Random variables continued. Monte Carlo Uncertainty propagation Correct presentation of.

Slides:



Advertisements
Similar presentations
Modeling of Data. Basic Bayes theorem Bayes theorem relates the conditional probabilities of two events A, and B: A might be a hypothesis and B might.
Advertisements

The Maximum Likelihood Method
Probability Distributions CSLU 2850.Lo1 Spring 2008 Cameron McInally Fordham University May contain work from the Creative Commons.
NASSP Masters 5003F - Computational Astronomy Lecture 5: source detection. Test the null hypothesis (NH). –The NH says: let’s suppose there is no.
Regression Analysis Once a linear relationship is defined, the independent variable can be used to forecast the dependent variable. Y ^ = bo + bX bo is.
Computing the Posterior Probability The posterior probability distribution contains the complete information concerning the parameters, but need often.
Maximum likelihood (ML) and likelihood ratio (LR) test
G. Cowan Lectures on Statistical Data Analysis 1 Statistical Data Analysis: Lecture 10 1Probability, Bayes’ theorem, random variables, pdfs 2Functions.
G. Cowan Lectures on Statistical Data Analysis Lecture 2 page 1 Statistical Data Analysis: Lecture 2 1Probability, Bayes’ theorem 2Random variables and.
Simulation Modeling and Analysis
Correlation 2 Computations, and the best fitting line.
Maximum likelihood (ML) and likelihood ratio (LR) test
Environmental Data Analysis with MatLab Lecture 24: Confidence Limits of Spectra; Bootstraps.
G. Cowan Lectures on Statistical Data Analysis 1 Statistical Data Analysis: Lecture 8 1Probability, Bayes’ theorem, random variables, pdfs 2Functions of.
7. Least squares 7.1 Method of least squares K. Desch – Statistical methods of data analysis SS10 Another important method to estimate parameters Connection.
Lecture 4 Probability and what it has to do with data analysis.
Linear and generalised linear models
Analysis of Individual Variables Descriptive – –Measures of Central Tendency Mean – Average score of distribution (1 st moment) Median – Middle score (50.
G. Cowan Lectures on Statistical Data Analysis Lecture 10 page 1 Statistical Data Analysis: Lecture 10 1Probability, Bayes’ theorem 2Random variables and.
Linear and generalised linear models Purpose of linear models Least-squares solution for linear models Analysis of diagnostics Exponential family and generalised.
Maximum likelihood (ML)
Lecture II-2: Probability Review
Modern Navigation Thomas Herring
Principles of the Global Positioning System Lecture 10 Prof. Thomas Herring Room A;
Physics 114: Lecture 15 Probability Tests & Linear Fitting Dale E. Gary NJIT Physics Department.
LINEAR REGRESSION Introduction Section 0 Lecture 1 Slide 1 Lecture 5 Slide 1 INTRODUCTION TO Modern Physics PHYX 2710 Fall 2004 Intermediate 3870 Fall.
CORRELATION & REGRESSION
Chapter 15 Modeling of Data. Statistics of Data Mean (or average): Variance: Median: a value x j such that half of the data are bigger than it, and half.
880.P20 Winter 2006 Richard Kass 1 Confidence Intervals and Upper Limits Confidence intervals (CI) are related to confidence limits (CL). To calculate.
G. Cowan Lectures on Statistical Data Analysis Lecture 3 page 1 Lecture 3 1 Probability (90 min.) Definition, Bayes’ theorem, probability densities and.
1 Lesson 3: Choosing from distributions Theory: LLN and Central Limit Theorem Theory: LLN and Central Limit Theorem Choosing from distributions Choosing.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Curve Fitting.
R. Kass/W03P416/Lecture 7 1 Lecture 7 Some Advanced Topics using Propagation of Errors and Least Squares Fitting Error on the mean (review from Lecture.
Lecture 3: Inference in Simple Linear Regression BMTRY 701 Biostatistical Methods II.
Physics 114: Exam 2 Review Lectures 11-16
NASSP Masters 5003F - Computational Astronomy Lecture 3 First, a bit more python. Then some noise statistics.
SUPA Advanced Data Analysis Course, Jan 6th – 7th 2009 Advanced Data Analysis for the Physical Sciences Dr Martin Hendry Dept of Physics and Astronomy.
© Copyright McGraw-Hill Correlation and Regression CHAPTER 10.
1 2 nd Pre-Lab Quiz 3 rd Pre-Lab Quiz 4 th Pre-Lab Quiz.
LECTURE 3: ANALYSIS OF EXPERIMENTAL DATA
Basic Time Series Analyzing variable star data for the amateur astronomer.
NASSP Masters 5003F - Computational Astronomy Lecture 6 Objective functions for model fitting: –Sum of squared residuals (=> the ‘method of least.
July 11, 2006Bayesian Inference and Maximum Entropy Probing the covariance matrix Kenneth M. Hanson T-16, Nuclear Physics; Theoretical Division Los.
CY1B2 Statistics1 (ii) Poisson distribution The Poisson distribution resembles the binomial distribution if the probability of an accident is very small.
Review of fundamental 1 Data mining in 1D: curve fitting by LLS Approximation-generalization tradeoff First homework assignment.
Computer simulation Sep. 9, QUIZ 2 Determine whether the following experiments have discrete or continuous out comes A fair die is tossed and the.
1 Introduction to Statistics − Day 4 Glen Cowan Lecture 1 Probability Random variables, probability densities, etc. Lecture 2 Brief catalogue of probability.
G. Cowan Lectures on Statistical Data Analysis Lecture 8 page 1 Statistical Data Analysis: Lecture 8 1Probability, Bayes’ theorem 2Random variables and.
Lecture 8 Source detection NASSP Masters 5003S - Computational Astronomy
1 Introduction to Statistics − Day 3 Glen Cowan Lecture 1 Probability Random variables, probability densities, etc. Brief catalogue of probability densities.
G. Cowan Computing and Statistical Data Analysis / Stat 9 1 Computing and Statistical Data Analysis Stat 9: Parameter Estimation, Limits London Postgraduate.
ESTIMATION METHODS We know how to calculate confidence intervals for estimates of  and  2 Now, we need procedures to calculate  and  2, themselves.
G. Cowan Lectures on Statistical Data Analysis Lecture 9 page 1 Statistical Data Analysis: Lecture 9 1Probability, Bayes’ theorem 2Random variables and.
G. Cowan Lectures on Statistical Data Analysis Lecture 5 page 1 Statistical Data Analysis: Lecture 5 1Probability, Bayes’ theorem 2Random variables and.
G. Cowan Lectures on Statistical Data Analysis Lecture 10 page 1 Statistical Data Analysis: Lecture 10 1Probability, Bayes’ theorem 2Random variables and.
R. Kass/W03 P416 Lecture 5 l Suppose we are trying to measure the true value of some quantity (x T ). u We make repeated measurements of this quantity.
R. Kass/Sp07P416/Lecture 71 More on Least Squares Fit (LSQF) In Lec 5, we discussed how we can fit our data points to a linear function (straight line)
Regression Analysis Part A Basic Linear Regression Analysis and Estimation of Parameters Read Chapters 3, 4 and 5 of Forecasting and Time Series, An Applied.
ESTIMATION METHODS We know how to calculate confidence intervals for estimates of  and 2 Now, we need procedures to calculate  and 2 , themselves.
The Maximum Likelihood Method
Physics 114: Lecture 13 Probability Tests & Linear Fitting
Chapter 4 Basic Estimation Techniques
Correlation and Regression
Statistical Methods For Engineers
6-1 Introduction To Empirical Models
Computing and Statistical Data Analysis / Stat 8
EMIS 7300 SYSTEMS ANALYSIS METHODS FALL 2005
Computing and Statistical Data Analysis / Stat 7
ESTIMATION METHODS We know how to calculate confidence intervals for estimates of  and 2 Now, we need procedures to calculate  and 2 , themselves.
Probabilistic Surrogate Models
Presentation transcript:

NASSP Masters 5003F - Computational Astronomy Lecture 4 Random variables continued. Monte Carlo Uncertainty propagation Correct presentation of data. How to obtain the ‘best-fit’ model: basic considerations. Techniques for finding minima (or maxima).

Advertisement! A simple FITS dump-to-ASCII script is available off my web page. I’ll try to get FTOOLS installed on the NASSP machines. NASSP Masters 5003F - Computational Astronomy

A python note: Sarah Blyth has a good intro manual for plotting with pylab: NASSP Masters 5003F - Computational Astronomy

NASSP Masters 5003F - Computational Astronomy Samples from the probability density function x p(x) Estimate of μ: Estimate of σ 2 : N samples x i – random numbers having the distribution p(x)

NASSP Masters 5003F - Computational Astronomy Estimating the PDF: a frequency histogram x p(x) Definition of a histogram: -Set up bins, usually (but not always) of equal width; -Count the samples which fall in each bin. Note that the bin heights have some scatter – in fact these numbers are Poisson random variables.

NASSP Masters 5003F - Computational Astronomy Estimating the PDF: mean, variance etc Estimating the three important properties of the PDF from N samples of X: –A frequency histogram serves as an estimate of p(x). –Estimate of the mean: – Estimate of the variance: Note: the result of every (non-trivial) transformation of a set of random numbers is itself a random number. (For example, the estimators for the mean and variance are themselves random numbers.) Note: the ‘hats’ here mean ‘estimate’.

Estimating the correlation between two different random variables: Suppose we have N paired samples of variables A and B. The covariance between these samples is estimated by If we have M different variables, we can define an M x M covariance matrix. NASSP Masters 5003F - Computational Astronomy

Uncertainty propagation If some random variable z is a function f(y) of other random variables y=[y 1,y 2,...y M ], then –σ 2 i,i ≡ σ 2 i is just the variance of the variable y i. –σ 2 i,j is the covariance between y i and y j. The formula looks horrible, but in practice it is often simple to evaluate...

NASSP Masters 5003F - Computational Astronomy Uncertainty propagation Often (not always!) the different y i are uncorrelated – ie, the value of one does not depend on another. In this case σ i,j 2 =0 for i≠j and so Examples (all uncorrelated):

The Monte Carlo It is often useful to be able to construct simulated data. –Perhaps to test some code designed to process real data; –Or to estimate a PDF for which you don’t have a formula. But of course, realistic data must contain random noise. A procedure which constructs a set of N random variables is called a Monte Carlo (after the famous casino). NASSP Masters 5003F - Computational Astronomy

Simulating random variables: There are routines in numpy and scipy to give you random numbers from a large library of different PDFs. –Bear in mind that these modules have essentially been written by amateurs – so be a bit wary – check them where practical! There are simple algorithms for simulating gaussian and poisson randoms. Joint randoms are a bit trickier. –The ‘rejection method’ –Markov-chain Monte Carlo NASSP Masters 5003F - Computational Astronomy

Making a frequency histogram The input information is a list of MC-generated samples from a PDF. Start by making a normal histogram of these samples: –Ie, set up bin boundaries, then count how many samples fall within each bin. –Calculate an uncertainty from each bin value from the square root of the counts in the bin. Because you want to compare to a PDF, the ‘integral’ of your FH must = 1. –To get this, divide each bin value by the bin width; and the total number of samples (summed over all bins). –NOTE! Everything you do to the bin value, also do to the uncertainty. –Histogram values are integers but FH values turn to reals (floating points). NASSP Masters 5003F - Computational Astronomy

Graphs – correct presentation of data. Distinguish between data and interpretation. –Any kind of fitted model counts as interpretation. –Usually draw data as points (or crosses, circles, etc – ie, as a discrete symbol). Joining the points up is EVIL!! …unless this is the best way to clarify a crowded plot. If you do join symbols with a line, make sure the symbols are not obscured by the line. –Include error bars where appropriate. Most often on just the Y axis but occasionally also on X. Sometimes you won’t know the errors, or the scatter in the points will indicate it anyway. –Interpretation = theory can be drawn with curves. NASSP Masters 5003F - Computational Astronomy

Error bars NASSP Masters 5003F - Computational Astronomy Is this spike significant?

Error bars NASSP Masters 5003F - Computational Astronomy Probably

Error bars NASSP Masters 5003F - Computational Astronomy Probably not.

Correct presentation of data continued. Try to find some way to transform the axes such that the points are expected to fall on a line – sometimes one with zero slope. –Why? Because there are uncounted ways not to be linear but only 1 way to be linear. –You’ll also need to transform the error bars. –A log scale is sometimes useful too if the data has information over a wide range of scales. NASSP Masters 5003F - Computational Astronomy

Axes transforms - examples For a ‘power law’, ie y(x) = Ax α : take logs (to base 10) of both x and y axes. –Gives a straight line of slope α and intercept log(A). For an exponential decay y(x) = Ae -kx : take logs of the y axis only. y(x) = Ax -2 : plot y against 1/x 2. NASSP Masters 5003F - Computational Astronomy

Example of MC, error propagation, correct presentation: NASSP Masters 5003F - Computational Astronomy samples

With more samples… NASSP Masters 5003F - Computational Astronomy samples

NASSP Masters 5003F - Computational Astronomy An example of when error bars are superfluous (also an example of axes transformation)

Another… this is a survival function histogram. Errors are not independent! NASSP Masters 5003F - Computational Astronomy From M Tajer et al (2004).

The astronomer has: Lots of (noisy) data points y = [y 1, y 2,.. y n ]; A model with a relatively small number of adjustable parameters Θ = [θ 1, θ 2,.. θ m ]. NASSP Masters 5003F - Computational Astronomy

What do we want from this? 1.We want to find a model which is in some sense the ‘best fit’ to the data. This means obtaining: –The best fit values of the parameters Θ ; –Uncertainties for these. 2.We may also want to compare competing models. –A very common example: comparing a model without any signal to a model (or rather, the whole class of models) with some signal. –The model without is known as the null hypothesis. Model-comparison will come in later lectures...

The ‘best fit’ model. 1.First construct your model. –Informed by the physics of the situation. 2.Two basic approaches: Bayesian and Frequentist. Will cover Bayesian later. Frequentist approach is to define some objective function U which, when minimized (or maximized), returns a ‘best fit’ model. –U must obviously be a function of both the data and the model parameters. –Examples: least-squares, likelihood, ‘entropy’. NASSP Masters 5003F - Computational Astronomy

A backward arrangement..? I’m going to cover techniques of minimization first, then discuss ‘best-fit’ objective functions later. A good reference for all kinds of algorithms: Press et al, “Numerical Recipes ”. –The code they provide is not always very good, but the explanations and recipes are excellent. –Older versions (still excellent) are available on the web - eg: NASSP Masters 5003F - Computational Astronomy

NASSP Masters 5003F - Computational Astronomy Minimization Nearly always in model-fitting we are trying to find the minimum in an analytic function – which is math-speak for a function which can be expanded in a Taylor series about the point of interest. ▼ U, the gradient, is a vector of 1 st derivatives of U w.r.t each parameter. H is called the Hessian and is a matrix of 2 nd derivatives of U.

NASSP Masters 5003F - Computational Astronomy Minimization The definition of a minimum in U is a place where the gradient equals 0 – ie where the partial derivatives ∂ U /∂θ i = 0 for all θ i. IF the function was a perfect paraboloid*, ie if there were no terms in the Taylor series of order > 2, then no matter where we are in the Θ space, we could go to the minimum in 1 mighty jump, because But because this is nearly always NOT true, in practice, minimization is an affair of many steps. –It’s of course desirable to keep the number of steps as small as possible. *Or if we can directly invert the equations ∂ U /∂θ i = 0.