Physics 2660: Fundamentals of Scientific Computing Lecture 8 News and Announcements • HW07 has been assigned and is due tonight J • HW08 will be assigned tonight/tomorrow and will be due Thursday 31 March at noon • Office hours reminder: – My office hours are in Room 022-­‐‑C (our computer lab) from 3:30-­‐‑4:30 on Tuesdays or by appointment – Today’s office hours: CANCELLED L – TA office hours, also in Room 022-­‐‑C • Mondays 5-­‐‑8pm • Tuesdays 5-­‐‑8pm 2 News and Announcements • Mid-­‐‑term exam will be **tonight** Tuesday 22 March at 7pm in this room – Will cover everything we have covered so far up until last week’s lecture – Format: Mix of multiple choice, matching, short answer – no in-­‐‑class coding, just need a Number 2 pencil! 3 Review and Today’s Outline • Last time: – Histograms – Making nice plots of data – Statistics: Our first entrypoint • Tonight! – Exam 1 • Today: – Structures – Libraries – More on statistics 4 Structures! 5 Example 6 Structures: User-­‐‑defined Variable Type 7 Accessing Structure Elements: The “.” Operator 8 Using Multiple Equivalent Structures 9 Using Multiple Equivalent Structures Tedious! 10 Structures and typedef 11 More Examples of typedef 12 Pointers to Structures 13 Pointers to Structures: The “-­‐‑>” Operator 14 Structure Example: Complex Numbers 15 Aside: Passing Copies or Pointers to Functions 16 Code Libraries 17 What is a Code Library? • A code library is a collection of pre-­‐‑compiled functions that one can use as needed plugging into newly developed pieces of code – Typically contain oft-­‐‑used utilities that are convenient to just simply re-­‐‑use rather than re-­‐‑code • We have been using code libraries all the time! – functions contained in stdio.h, stdlib.h, math.h, etc. • We will learn how to make our own code library here! 18 Building a Library 19 Example Using Code from a Library 20 Example Building Code from a Library 21 Example Building Code from a Library 22 Statistics: Our First Entrypoint 23 Making a Measurement: Truth • Let’s say I want to measure some physical observable. • Examples: – the acceleration due to gravity near the Earth’s surface – the speed of light – the mass of the Higgs boson N • Each such measureable has a single value – the truth: Make N repeated measurements of some quantity x. A perfect apparatus and data collection scheme would yield the true value every time! x [units] 24 Making A Measurement: Data Why do we see a range of measured values? • imperfections in our instruments • limitations in our measurements 25 Ge]ing to the Truth How do we go from to arrive at ? Use Statistics: The best we can achieve is the center distribution. Its shape depends on the measurement’s uncertainty. 26 The Story of Measurement • A measurement is not about the central value one finds • A measurement is truly about its uncertainty – The central value in fact is MEANINGLESS and OF NO USE without understanding and reporting the associated uncertainty • Two types of uncertainty: – Systematic uncertainty: Features of the measurement device or technique that shift (aka “bias”) the measured result away from the true value • Biases can often be corrected if discovered • Eg: Imagine you are measuring athletes running the 40-­‐‑yard dash. You discover however the length they run is in fact 42 yards long. This can in principle be corrected – Statistical or random uncertainty: Features of the measurement device or technique that shift the measured result by a different amount in each ajempt (hence, random) 27 Statistical or Random Uncertainty “Uncertainty” and “error” are used interchangeably, often inappropriately. I will try to use “uncertainty” universally – and you should as well. If we try to measure the value many 2mes, and have only random uncertain2es in our measurement, we might see a distribu2on of results that follows this red curve. probability distribution 28 The Gaussian Distribution µμ = “mean”, average value of the distributions σ2 = “variance”, characterizes the width σ = “standard deviation” 29 The Gaussian Distribution µμ = “mean”, average value of the distributions σ2 = “variance”, characterizes the width σ = “standard deviation” Central Limit Theorem: Sufficiently large number of randomly distributed measurements always approaches a Gaussian distribution. 30 Sample and Parent Distributions 31 What Can We Get From the Sample Distribution? Note: variance = s2 From these parameters we can make statements about the parent distribution. 32 Properties of Parent Gaussian Distribution 33 Properties of Parent Gaussian Distribution 34 Statistical vs Systematic Uncertainties 35 We’ll pick up from here next time. See you then. 36