Lecture 8. Generating a non-uniform probability distribution



Similar documents
A Simple Pseudo Random Number algorithm

Solutions to Homework 10

Notes on Continuous Random Variables

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 18. A Brief Introduction to Continuous Probability

Area and Arc Length in Polar Coordinates

Magnetic Dipoles. Magnetic Field of Current Loop. B r. PHY2061 Enriched Physics 2 Lecture Notes

Introduction to Complex Numbers in Physics/Engineering

Chapter 3 RANDOM VARIATE GENERATION

PROBLEM SET. Practice Problems for Exam #1. Math 1352, Fall Oct. 1, 2004 ANSWERS

6. Define log(z) so that π < I log(z) π. Discuss the identities e log(z) = z and log(e w ) = w.

99.37, 99.38, 99.38, 99.39, 99.39, 99.39, 99.39, 99.40, 99.41, cm

Electromagnetism - Lecture 2. Electric Fields

The sample space for a pair of die rolls is the set. The sample space for a random number between 0 and 1 is the interval [0, 1].

Solutions to old Exam 1 problems

Algebra I Vocabulary Cards

Microeconomic Theory: Basic Math Concepts

5. Continuous Random Variables

Solutions for Review Problems

Math 1B, lecture 5: area and volume

Section V.3: Dot Product

MATH 10: Elementary Statistics and Probability Chapter 5: Continuous Random Variables

Chapter 22: Electric Flux and Gauss s Law

Algebra 2 Chapter 1 Vocabulary. identity - A statement that equates two equivalent expressions.

THE COMPLEX EXPONENTIAL FUNCTION

PRACTICE FINAL. Problem 1. Find the dimensions of the isosceles triangle with largest area that can be inscribed in a circle of radius 10cm.

LINES AND PLANES IN R 3

Mechanics 1: Conservation of Energy and Momentum

Feb 28 Homework Solutions Math 151, Winter Chapter 6 Problems (pages )

2WB05 Simulation Lecture 8: Generating random variables

Computing Euler angles from a rotation matrix

Section 5.1 Continuous Random Variables: Introduction

Statistics 100A Homework 7 Solutions

CIRCLE COORDINATE GEOMETRY

= δx x + δy y. df ds = dx. ds y + xdy ds. Now multiply by ds to get the form of the equation in terms of differentials: df = y dx + x dy.

Lecture 7: Continuous Random Variables

Chapter 6 Circular Motion

AP Physics 1 and 2 Lab Investigations

1. Degenerate Pressure

Intermediate Value Theorem, Rolle s Theorem and Mean Value Theorem

The Math Circle, Spring 2004

Lecture L3 - Vectors, Matrices and Coordinate Transformations

When the fluid velocity is zero, called the hydrostatic condition, the pressure variation is due only to the weight of the fluid.

4. Continuous Random Variables, the Pareto and Normal Distributions

2 Session Two - Complex Numbers and Vectors

APPLIED MATHEMATICS ADVANCED LEVEL

Electromagnetism Laws and Equations

Chapter 15 Collision Theory

Solutions to Problems in Goldstein, Classical Mechanics, Second Edition. Chapter 7

Lecture 2: Discrete Distributions, Normal Distributions. Chapter 1

[1] Diagonal factorization

10 Polar Coordinates, Parametric Equations

The Quantum Harmonic Oscillator Stephen Webb

Lecture 6: Discrete & Continuous Probability and Random Variables

Orbits of the Lennard-Jones Potential

Inequalities of Analysis. Andrejs Treibergs. Fall 2014

Free Electron Fermi Gas (Kittel Ch. 6)

Some Comments on the Derivative of a Vector with applications to angular momentum and curvature. E. L. Lady (October 18, 2000)

MATH2210 Notebook 1 Fall Semester 2016/ MATH2210 Notebook Solving Systems of Linear Equations... 3

Normal distribution. ) 2 /2σ. 2π σ

PYTHAGOREAN TRIPLES KEITH CONRAD

Vector Notation: AB represents the vector from point A to point B on a graph. The vector can be computed by B A.

Review Sheet for Test 1

Section 6.1 Joint Distribution Functions

Review B: Coordinate Systems

Partial Fractions Examples

Vector surface area Differentials in an OCS

Differentiation of vectors

AP Physics - Vector Algrebra Tutorial

Chapter 4 Lecture Notes

4. How many integers between 2004 and 4002 are perfect squares?

WEEK #22: PDFs and CDFs, Measures of Center and Spread

Department of Mathematics, Indian Institute of Technology, Kharagpur Assignment 2-3, Probability and Statistics, March Due:-March 25, 2015.

Section 9.5: Equations of Lines and Planes

Review Solutions MAT V (a) If u = 4 x, then du = dx. Hence, substitution implies 1. dx = du = 2 u + C = 2 4 x + C.

Chapter 17. Orthogonal Matrices and Symmetries of Space

11. Rotation Translational Motion: Rotational Motion:

Understanding Poles and Zeros

y cos 3 x dx y cos 2 x cos x dx y 1 sin 2 x cos x dx y 1 u 2 du u 1 3u 3 C

Least-Squares Intersection of Lines

Method of Green s Functions

Section 1.1 Linear Equations: Slope and Equations of Lines

PHY4604 Introduction to Quantum Mechanics Fall 2004 Practice Test 3 November 22, 2004

Derive 5: The Easiest... Just Got Better!

RF-Microwaves formulas - 1-port systems

II. Linear Systems of Equations

ANALYTICAL METHODS FOR ENGINEERS

Today in Physics 217: the method of images

TWO-DIMENSIONAL TRANSFORMATION

Faraday s Law of Induction

x 2 + y 2 = 1 y 1 = x 2 + 2x y = x 2 + 2x + 1

VISUALIZATION OF DENSITY FUNCTIONS WITH GEOGEBRA

AP Calculus AB 2004 Free-Response Questions

Inner Product Spaces

ST 371 (IV): Discrete Random Variables

Let s first see how precession works in quantitative detail. The system is illustrated below: ...

Maximum Likelihood Estimation

Classical Angular Momentum. The Physics of Rotational Motion.

Double Integrals in Polar Coordinates

Aim : To study how the time period of a simple pendulum changes when its amplitude is changed.

Transcription:

Discrete outcomes Lecture 8 Generating a non-uniform probability distribution Last week we discussed generating a non-uniform probability distribution for the case of finite discrete outcomes. An algorithm to carry out the non-uniform probability is to define an array A as follows: n A n = P j (1) j=1 where A 0 = 0. Note that Z N = 1. A n is just the sum of the probabilities from 1 n. Now, throw a random number r that has uniform probability between 0 and 1. Find the value of k, such that A k 1 < r < A k. Then the outcome is z k. The following code should work after initiallizing the array A[i]: i=0; r=random()/m; found=0; while(found=0) { i=i+1; if(a[i] > r) found=1; if (i=n) found=1; } outcome=a[i]; 1

Continuous Outcomes In the realm of quantum mechanics the outcome of nearly every experiment is probabilistic. Discrete outcomes might be the final spin state of a system. In the discrete case, the probability for any particular outcome is a unitless number between 0 and 1. Many outcomes are however, continuous. Examples of continuous outcomes include: a particle s position, momentum, energy, cross section, to name a few. Suppose the continuous outcome is the quantity x. Then one cannot describe the probability simply as the function P (x). Since x is continuous, there are an infinite number of possibilities no matter how close you get to x. One can only describe the randomness as the probability for the outcome x to lie in a certain range. That is, the probability for the outcome to be between x 1 and x 2 P (x 1 x 2 ) can be written as P (x 1 x 2 ) = x2 x 1 P (x) dx (2) The continuous function P (x) can be interpreted as follows: the probability that the outcome lies between x and x + x is P (x ) x (in the limit as x 0). The probability function P (x) has units of 1/length, and is refered to as a probability density. In three dimensions, the probability density will be a function of x, y, and z. One property that P (x) must satisfy is P (x)dx = 1 (3) where the integral is over all possible x. In three dimensions this becomes: P ( r)dv = 1 (4) In quantum mechanics, the absolute square of a particle s state in coordinate space, Ψ (x)ψ(x) is a probability density. The function Ψ( r) is a probability density amplitude. Likewise, the differential cross section is a probabililty density in θ, with f(θ) being a probability density amplitude. 2

How does one produce a non-uniform probability for a continuous outcome from a random number generator that has a uniform probability distribution? We can use the same approach that we did for the discrete case. For the discrete case it was most useful to define A n : n A n = P j (5) j=1 Taking the limit to the continuous case, P j P (x )dx, and A n A(x). Suppose x lies between a and b, (a x b). Then we have A(x) = x Note that A(a) = 0 and A(b) = 1 as before. a P (x )dx (6) We can throw a random number with non-uniform probability density P (x) as follows. First throw a random number r between zero and one with uniform probability. Then solve the following equation r = A(x) (7) for x. x will be random with the probability density P (x). This was the same method we used before in the case of discrete outcomes. After throwing r, the random outcome was the first value n (for A n ) above r. Another way of understanding this method for the case when a x b is to start with the graph of P (x), which goes from a to b. Then divide the a b segment on the x-axis up into N equal pieces of length x = (b a)/n. Now we have N discrete outcomes, x j = a + jδx, where j is an integer and goes from one to N. The probability of each outcome equals the area under the curve in between x and x+ x: P j = P (x j ) x. Now we define A n as before: n n A n = P j = P (x j ) x (8) j=1 j=1 which is the equation we used in the discrete case. Taking the limit as N yields the continuous case. 3

Let s do an example. Suppose we want to throw a random number x between zero and two that has a probability that is proportional to x. That is, P (x) x, or P (x) = Cx. First we need to normalize P (x), that is to find the constant C such that 2 0 P (x)dx = 1. 2 0 Cxdx = 1 C = 1 2 Now we determine A(x): A(x) = x 0 A(x) = x2 4 1 2 x dx Now we throw a random number r between zero and one with uniform probability. Then set r = x 2 /4 and solve for x in terms of r: x = 2 r (9) If r has a uniform probability between zero and one, then x will have a (non-uniform) probability density of x/2. The following computer code could be used to generate this non-uniform probability distribution for x: r=random()/m; x=2*sqrt(r); 4

Throwing a Gaussian Probability distribution A Gaussian probability distribution in one dimension is the following function for P (x): P (x) = 1 σ 2π e (x µ)2 /(2σ2 ) This probability density distribution is important in physics, because often experimental data will have random errors that follow this normal distribution. The average value of x is µ, with a standard deviation about this value of σ. Note, that here, x ranges from to +. To throw a Gaussian probability distribution in x, one would have to solve the following integral (10) A(x) = 1 x σ e (x µ) 2 /(2σ 2) dx (11) 2π for A(x). As far as I know, there is no analytic solution to this integral. However, there is a nice trick to produce a Gaussian probability. If one throws a two-dimensional Gaussian probability distribution, the integral can be solved analytically. I ll show you the result first, then show you how it is derived. To throw a Gaussian distribution in x, with mean µ and standard deviation σ, do the following. Throw two random numbers, r 1 and r 2, each with a uniform probability distribution between zero and one. The random number x equals x = µ + s 2 ln(1 r 1 ) sin(2πr 2 ). A simple code to carry this algorithm out is: r1 = random()/m; r2 = random()/m; r = s * sqrt(-2*ln(1-r1)) ; theta = 2*pi*r2; x = mu + r * sin(theta); 5

This algorithm is derived by tossing a two dimensional Gaussian probability in the x-y plane. If we toss a random point in the x-y plane that has a Gaussian probability density in x and y about the origin with standard deviation for both x and y as σ, the probability density is P (x, y) = 1 σ 2π e (x µ)2 /(2σ2 ) 1 σ 2π e (y µ)2 /(2σ2 ) The expression P (x, y) is an area density, with units of 1/area. The complete expression for probability is (12) P (x, y) dxdy = 1 σ 2π e (x µ)2 /(2σ2 ) 1 σ 2π e (y µ)2 /(2σ2) dxdy (13) We can toss the point with the same probability density using the polar coordinates r and θ. The relationship in polar coordinates between (x, y) and r and θ is x = r cos(θ) y = r sin(θ) and dx dy = rdr dθ Using these equations to transform to polar coordinates yields P (x, y) dxdy = 1 σ 2 2π e r2 /(2σ2) rdr dθ = 1 σ 2 e r2 /(2σ 2) rdr dθ 2π So if we throw r with the probability density (in r) of P (r) = (r/σ 2 )e r2 /(2σ 2) and θ with a uniform probability density between 0 and 2π, then the point (r, θ) in the x-y plane will have an x-coordinate that has a Gaussian probability distribution. The y-coordinate will also have a Gaussian probability distribution as well. However, you can not use both the x and y points in the same simulation. One does not get two indendent Gaussian probability distributions from the r θ toss. 6

To obtain r, first throw r 1 with uniform probability between zero and 1. Then r is found by solving r 1 = 1 r e r 2 /(2σ 2) r dr σ 2 0 = 1 e r2 /(2σ 2 ) or r = σ 2 ln(1 r 1 ) θ is obtained by throwing r 2 with uniform probability between zero and 1. θ = 2πr 2. Now that you see the derivation, you can understand why the code: Then r1 = random()/m; r2 = random()/m; r = s * sqrt(-2*ln(1-r1)) ; theta = 2*pi*r2; x = mu + r * sin(theta); works. The mean µ is added to the Gaussian spread in the last line. Random Numbers in ROOT For those of you using ROOT, it is easy to throw a random number with a Gaussian distribution. There is a special function, rand.gaus(mean,sigma). The following code should work: TRandom3 rand(0); //set seed for random variable x= rand.gaus(mu, sigma); Most likely the rand.gauss function uses the method we described. 7

More on Scattering, Phase Shifts, and coding In the last lecture we came up with the formula for the scattering amplitude in terms of the phase shifts. The result for elastic scattering is where f(θ) = (2l + 1)f l P l (cos(θ)) (14) l=0 f l = eiδ l sin(δl ) k (15) where δ l are the phase shifts, and k = p/ h. For the case of elastic scattering the δ l are real. In our assignment, we only sum up to l = 1 since the momentum of the pion is small. In this case, the formula for f(θ) is f(θ) = 1 k (eiδ 0 sin(δ 0 ) + 3e iδ 1 sin(δ 1 )cos(θ)) (16) Before we go over coding with complex numbers let me discuss where the name phase shift comes from. The δ l are the shift in phase from the free particle solutions of the Schroedinger equation. In the absence of the potential V (r) (V (r) = 0), the solutions to the Schroedinger equation for orbital angular momentum l are the spherical Bessel functions, j l (kr). In fact, a plane wave traveling in the z-direction expressed in spherical coordinates is given by: e ikz = (2l + 1)i l j l (kr)p l (cos(θ)) (17) l=0 where θ is the angle with respect to the z-axis. For large r, the spherical Bessel function j l (kr) sin(kr lπ/2)/(kr). The effect of a real potential V (r) is to cause a phase shift in this large r limit: sin(kr lπ/2 + δ l )/(kr). To solve for the phase shifts δ l, one just iterates the Schroedinger equation to large r, like we did for the bound state assignment. However for the scattering calculation, the energy is greater than zero, and the solution oscillates. One can obtain the phase shifts by examining the large r solution to the discrete Schroedinger equation. We will not solve the Schroedinger equation for the δ l in our assignment 4. I ll give you δ 0 and δ 1 for a particular energy, and you will generate simulated data. 8

The sign of the phase shift for elastic scattering at low momentum depends on whether the interaction is attractive or repulsive. For an attractive interaction, the wave function curves more than in the absence of an interaction. The result is that the phase of the wave function ends up ahead of the free particle case. Thus, a positive phase shift means that the interaction (for the particular value of l) is attractive. For a repulsive interaction, the wave function curves less than the free particle case, and the phase shift lags. A negative phase shift indicates that the interaction is repulsive. I ll demonstrate this on the board for the l = 0 partial wave. The amplitude is complex, so in your code you will need to use complex numbers where needed. In gcc, one need to include <complex.h>: #include <complex.h> #include <math.h> You will need to declare any complex variables as complex: complex f; Some commands that you might need are cexp(), which is the complex exponential function, and cabs(), which is the complex absolute value squared. For example: cexp(x) e x cabs(f) f f Also, you will need to find the center of mass momentum, since k = p cm / h. Now you are ready to write your code for assignment 4. I ll go over any questions you might have during the Wednesday office hours. I d recommend to first produce the data without any Gaussian scatter. Then throw the Gaussian dice to simulate the statistical error in a real experiment for each data point. 9