PHYSICS 115/242 Homework 5, Solutions X = and the mean and variance of X are N times the mean and variance of 12/N y, so

Size: px
Start display at page:

Download "PHYSICS 115/242 Homework 5, Solutions X = and the mean and variance of X are N times the mean and variance of 12/N y, so"

Transcription

1 PHYSICS 5/242 Homework 5, Solutions. Central limit theorem. (a) Let y i = x i /2. The distribution of y i is equal to for /2 y /2 and zero otherwise. Hence We consider µ y y i = /2 /2 σ 2 y y 2 i y i 2 = X = ydy = 0 /2 /2y 2 dy = 3 2 ( 2 2 N N y i, i= ) 3 = 2. and the mean and variance of X are N times the mean and variance of 2/N y, so µ X X = N 2 N µ y = 0, σ 2 X X 2 X 2 = N 2 N σ2 y =. (b) SOURCE CODE double sum, sum2, sum3, sum4, sum5, sum6, x, xadd; int i, j, m, seed; printf ("sample size =?, seed =? "); scanf("%d %d", &m, &seed); srand(seed); sum = 0; sum2 = 0; sum3 = 0; sum4 = 0; sum5 = 0; sum6 = 0; for (i = 0; i < m; i++)

2 x = 0; for (j = 0; j < 2; j++) x = x + rand() / (RAND_MAX +.0); x = x - 6; xadd = x; sum += xadd; xadd *= x; sum2 += xadd; xadd *= x; sum3 += xadd; xadd *= x; sum4 += xadd; xadd *= x; sum5 += xadd; xadd *= x; sum6 += xadd; sum = sum /m; sum2 = sum2 /m; sum3 = sum3 /m; sum4 = sum4 /m; sum5 = sum5 /m; sum6 = sum6 /m; printf (" Took N = 2\n "); printf ("sample size = %8d \n", m) ; printf (" k= %8.4f\n k=2 %8.4f\n k=3 %8.4f\n k=4 %8.4f\n k=5 %8.4f\n k=6 %8 sum, sum2, sum3, sum4, sum5, sum6); OUTPUT sample size =?, seed =? Took N = 2 sample size = 0000 k= k= k= k= k= k= Note that this is basically correct except that the 6th moment, and to a lesser extent the 4th moment, are a bit small. This is because I only took N=2 numbers in the sum, which does not give quite enough weight in the tail to be a true Gaussian, and the higher moments need the tail to be correct. Taking N = 00, still with a sample size of 0000, I got the following results: 2

3 Took N = 00 sample size = 0000 k= k= k= k= k= k= which is better. (c) 242 students We can understand better the results in the previous part by explicitly calculating the moments on the distribution for finite N. It is convenient to define y i = 2(x i 2 ) so y i = 0, yi 2 =. For the 4-th moment we have X 4 = N (y 2 +y 2 + +y N ) 4 = ( N y4 +3 ) y 2 2, N where we used that the only non-zero terms are those where all four indices are equal and those where two of the indices are equal and the other two are both equal to a different value. There are N terms where all indices are equal, and 3N(N ) terms where there are two equal pairs (this comes from their being N(N )/2 ways of choosing two distinct indices and there are 4 C 2 = 4!/(2!) 2 = 6 arrangements for these indices). Now y 2 =, and y 4 = 9 5 σ4. Hence we have X 4 = 9 5 ( N +3 ) N = 3 6 5N. For N = 2 this gives 2.9, in better agreement with the numerics. For the sixth moment, similar combinatorical arguments give X 6 = N (y 3 +y 2 + +y N ) 6 = N 2 y6 + 5 ( ) ( y 4 y 2 +5 )( 2 ) y 2 3 N N N N = ( 27 5 N N 5 ) N 2 5 N + 30 N 2 = 5 8 N N, 2 where we used that y 6 = 27/7. For N = 2 this gives , rather than 5, which agrees much better with the numerics. 2. Lorentzian Distribution 3

4 (a) To generate random numbers with the distribution P(x) = π, ( < x < ), +x2 as discussed in class we generate a uniform random number r in the integral from 0 to and compute x as a function of r, i.e. x(r), where the inverse function is given by x r(x) = P(x )dx = [ ( tan x π )], π 2 so x = tan [ π ( r 2)]. Note that, in the algorithm, we have to make sure that the values r = 0 and are excluded since the tan will blow up for these values. (b) In the numerics I took N = SOURCE CODE int N = 0000, i, nless; double t, x; srand(time(null)); printf (" N = %d\n ", N); nless = 0; for (i = 0; i < N; i++) while() t = rand() / (RAND_MAX +.0); if (t!= 0 && t!= ) break; // exclude t exactly 0 or x = tan(m_pi * (t - 0.5)); if (fabs(x) < ) nless += ; printf (" Fraction with x < = %0.4f\n", (float) nless / (float) N); 4

5 OUTPUT N = 0000 Fraction with x < = The exact answer is π +x 2 dx = π [ tan x ] = π ( π 4 + π = 4) 2. The numerical result agrees to that within about %. (This error is reasonable since it is of order / N.) (c) The variance is infinite since x 2 P(x) const. for x ±. Furthermore, the mean is also not well defined. To see this note that to define integrals to infinity we have to ensure that the integral tends to a well defined value as the limit tends to infinity. Here, both the upper and lower limits are infinite, and we have to take do a limiting procedure for both of them, i.e. x = lim L M π L M x dx = lim +x2 L M [ ln(+x 2 ) ] L 2π = M lim L M π ln(l/m), so the answer depends on how the limits L,M are taken. For the central limit theorem to apply, the distribution of the individual random variables must have a well-defined mean and variance. Hence it is does not apply to the Lorentzian distribution. 3. Monte Carlo Integral with Error Bars. (a) I estimated the integral from an average over N values of x. To get the error bar on this estimate I computed the standard deviation of the N function values and divided by N as discussed in class. SOURCE CODE double f(double x) return log(x); double a =, b = 2, x, fun, ans_av, ans_err, exact; 5

6 int N = 0000, i; srand(time(null)); for (i = 0; i < N; i++) // Sum over the N x-values x = a + (b - a) * rand() / (RAND_MAX +.0); // get x-value fun = f(x); ans_av += fun; ans_err += + fun*fun; ans_av = ans_av / N; // Normalize ans_err = ans_err / N; ans_err = sqrt(fabs(ans_err - ans_av*ans_av)/(n - )); exact = * log(2.0); // error printf (" %d points \n", N); printf (" ans = %0.5f +/- %0.5f\n", ans_av, ans_err); printf (" exact = %0.5f \n", exact); OUTPUT 0000 points ans = / exact = (b) The exact result is given by I = 2 ln(x)dx = [xlnx x] 2 = 2ln2 2 (ln ) = 2ln2 = The above answer agrees within the exact value to within about one standard deviation, as expected. 4. Multi-dimensional Monte Carlo Integral (a) Clearly 0 x2 i dx = /3 and, for i j, x 0 0 ix j dx i dx j = /4. Hence, expanding out the square of the integrand in the question we have, for N variables, I = N 3 +N(N ) 4. Setting N = 0 gives I = =

7 (b) SOURCE CODE double a = 0, b =, x, term, term2, ans_av, ans_err, exact; int N = 0000, i, j; srand(time(null)); for (i = 0; i < N; i++) // Sum over the N x-values term = 0; for (j = 0; j < 0; j++) x = a + (b - a) * rand() / (RAND_MAX +.0); // get x-value term += x; term2 = term * term; ans_av += term2; ans_err += term2 * term2; ans_av = ans_av / N; // Normalize ans_err = ans_err / N; ans_err = sqrt(fabs(ans_err - ans_av*ans_av)/(n - )); exact = 55.0/6.0; // error printf (" %d points \n", N); printf (" ans = %0.5f +/- %0.5f\n", ans_av, ans_err); printf (" exact = %0.5f \n", exact); OUTPUT ~/courses/5/homework debussy.ucsc.edu => a.out 0000 points ans = / exact = Here N is the number of points in the Monte Carlo average. The Monte Carlo answer 7

8 agrees with the exact result to within the error computed from the Monte Carlo calcuation. 5. Random Walk SOURCE CODE int tmax, t, TSTORE=000, N, irun; double x, xav[tstore], xav2[tstore]; float r; printf (" tmax =? No. of runs =? " ); scanf("%d %d", &tmax, &N); if (tmax > TSTORE) exit; srand(time(null)); for (t = 0; t < tmax; t++) xav[t] = 0; xav2[t] = 0; for (irun =0; irun < N; irun++) x = 0; for (t = 0; t < tmax; t++) r = rand() / (RAND_MAX +.0); if (r < 0.5) x = x + ; else x = x - ; xav[t] += x; xav2[t] += x*x; for (t = 9; t < tmax; t+=0) xav[t] /= N; xav2[t] /= N; 8

9 printf (" %5i %0.4f %0.4f \n", t+, xav[t], xav2[t]); OUTPUT These results are obtained by averaging over 0000 walks each of length 200 t <x(t)> <x^2(t)> i.e. the mean is close to zero and the mean square is close to t as expected. 9

Random Numbers and Monte Carlo Methods

Random Numbers and Monte Carlo Methods Random Numbers and Monte Carlo Methods Methods which make use of random numbers are often called Monte Carlo Methods after the Monte Carlo Casino in Monaco which has long been famous for games of chance.

More information

C Functions. CS 2060 Week 4. Prof. Jonathan Ventura

C Functions. CS 2060 Week 4. Prof. Jonathan Ventura CS 2060 Week 4 1 Modularizing Programs Modularizing programs in C Writing custom functions Header files 2 Function Call Stack The function call stack Stack frames 3 Pass-by-value Pass-by-value and pass-by-reference

More information

Lab 5 Monte Carlo integration

Lab 5 Monte Carlo integration Lab 5 Monte Carlo integration Edvin Listo Zec 9065-976 edvinli@student.chalmers.se October 0, 014 Co-worker: Jessica Fredby Introduction In this computer assignment we will discuss a technique for solving

More information

Monte Carlo Integration and Random Numbers

Monte Carlo Integration and Random Numbers Monte Carlo Integration and Random Numbers Higher dimensional integration u Simpson rule with M evaluations in u one dimension the error is order M -4! u d dimensions the error is order M -4/d u In general

More information

Physics 736. Experimental Methods in Nuclear-, Particle-, and Astrophysics. - Statistical Methods -

Physics 736. Experimental Methods in Nuclear-, Particle-, and Astrophysics. - Statistical Methods - Physics 736 Experimental Methods in Nuclear-, Particle-, and Astrophysics - Statistical Methods - Karsten Heeger heeger@wisc.edu Course Schedule and Reading course website http://neutrino.physics.wisc.edu/teaching/phys736/

More information

Integration. Volume Estimation

Integration. Volume Estimation Monte Carlo Integration Lab Objective: Many important integrals cannot be evaluated symbolically because the integrand has no antiderivative. Traditional numerical integration techniques like Newton-Cotes

More information

Monte Carlo Simula/on and Copula Func/on. by Gerardo Ferrara

Monte Carlo Simula/on and Copula Func/on. by Gerardo Ferrara Monte Carlo Simula/on and Copula Func/on by Gerardo Ferrara Introduc)on A Monte Carlo method is a computational algorithm that relies on repeated random sampling to compute its results. In a nutshell,

More information

Chapter 1. Introduction

Chapter 1. Introduction Chapter 1 Introduction A Monte Carlo method is a compuational method that uses random numbers to compute (estimate) some quantity of interest. Very often the quantity we want to compute is the mean of

More information

Random Numbers Random Walk

Random Numbers Random Walk Random Numbers Random Walk Computational Physics Random Numbers Random Walk Outline Random Systems Random Numbers Monte Carlo Integration Example Random Walk Exercise 7 Introduction Random Systems Deterministic

More information

6-1 (Function). (Function) !*+!"#!, Function Description Example. natural logarithm of x (base e) rounds x to smallest integer not less than x

6-1 (Function). (Function) !*+!#!, Function Description Example. natural logarithm of x (base e) rounds x to smallest integer not less than x (Function) -1.1 Math Library Function!"#! $%&!'(#) preprocessor directive #include !*+!"#!, Function Description Example sqrt(x) square root of x sqrt(900.0) is 30.0 sqrt(9.0) is 3.0 exp(x) log(x)

More information

Numerical Integration

Numerical Integration Lecture 12: Numerical Integration (with a focus on Monte Carlo integration) Computer Graphics CMU 15-462/15-662, Fall 2015 Review: fundamental theorem of calculus Z b f(x)dx = F (b) F (a) a f(x) = d dx

More information

MULTI-DIMENSIONAL MONTE CARLO INTEGRATION

MULTI-DIMENSIONAL MONTE CARLO INTEGRATION CS580: Computer Graphics KAIST School of Computing Chapter 3 MULTI-DIMENSIONAL MONTE CARLO INTEGRATION 2 1 Monte Carlo Integration This describes a simple technique for the numerical evaluation of integrals

More information

Chapter 4 Functions By C.K. Liang

Chapter 4 Functions By C.K. Liang 1 Chapter 4 Functions By C.K. Liang What you should learn? 2 To construct programs modularly from small pieces called functions Math functions in C standard library Create new functions Pass information

More information

Will Monroe July 21, with materials by Mehran Sahami and Chris Piech. Joint Distributions

Will Monroe July 21, with materials by Mehran Sahami and Chris Piech. Joint Distributions Will Monroe July 1, 017 with materials by Mehran Sahami and Chris Piech Joint Distributions Review: Normal random variable An normal (= Gaussian) random variable is a good approximation to many other distributions.

More information

Page 129 Exercise 5: Suppose that the joint p.d.f. of two random variables X and Y is as follows: { c(x. 0 otherwise. ( 1 = c. = c

Page 129 Exercise 5: Suppose that the joint p.d.f. of two random variables X and Y is as follows: { c(x. 0 otherwise. ( 1 = c. = c Stat Solutions for Homework Set Page 9 Exercise : Suppose that the joint p.d.f. of two random variables X and Y is as follows: { cx fx, y + y for y x, < x < otherwise. Determine a the value of the constant

More information

= f (a, b) + (hf x + kf y ) (a,b) +

= f (a, b) + (hf x + kf y ) (a,b) + Chapter 14 Multiple Integrals 1 Double Integrals, Iterated Integrals, Cross-sections 2 Double Integrals over more general regions, Definition, Evaluation of Double Integrals, Properties of Double Integrals

More information

MATHEMATICS 191, FALL 2004 MATHEMATICAL PROBABILITY Outline #1 (Countability and Uncountability)

MATHEMATICS 191, FALL 2004 MATHEMATICAL PROBABILITY Outline #1 (Countability and Uncountability) MATHEMATICS 191, FALL 2004 MATHEMATICAL PROBABILITY Outline #1 (Countability and Uncountability) Last modified: September 16, 2004 Reference: Apostol, Calculus, Vol. 2, section 13.19 (attached). The aim

More information

Lecture 14. Daily Puzzle. Math in C. Rearrange the letters of eleven plus two to make this mathematical statement true. Eleven plus two =?

Lecture 14. Daily Puzzle. Math in C. Rearrange the letters of eleven plus two to make this mathematical statement true. Eleven plus two =? Lecture 14 Math in C Daily Puzzle Rearrange the letters of eleven plus two to make this mathematical statement true. Eleven plus two =? Daily Puzzle SOLUTION Eleven plus two = twelve plus one Announcements

More information

nag 1d quad gauss 1 (d01tac)

nag 1d quad gauss 1 (d01tac) 1. Purpose nag 1d quad gauss 1 () nag 1d quad gauss 1 () computes an estimate of the definite integral of a function of known analytical form, using a Gaussian quadrature formula with a specified number

More information

Exercises Lecture III: Random numbers with non uniform distributions; simulations of simple random processes

Exercises Lecture III: Random numbers with non uniform distributions; simulations of simple random processes Exercises Lecture III: Random numbers with non uniform distributions; simulations of simple random processes 1. Random numbers with non uniform distributions: Inverse Transformation Method (a) With the

More information

VARIANCE REDUCTION TECHNIQUES IN MONTE CARLO SIMULATIONS K. Ming Leung

VARIANCE REDUCTION TECHNIQUES IN MONTE CARLO SIMULATIONS K. Ming Leung POLYTECHNIC UNIVERSITY Department of Computer and Information Science VARIANCE REDUCTION TECHNIQUES IN MONTE CARLO SIMULATIONS K. Ming Leung Abstract: Techniques for reducing the variance in Monte Carlo

More information

The Plan: Basic statistics: Random and pseudorandom numbers and their generation: Chapter 16.

The Plan: Basic statistics: Random and pseudorandom numbers and their generation: Chapter 16. Scientific Computing with Case Studies SIAM Press, 29 http://www.cs.umd.edu/users/oleary/sccswebpage Lecture Notes for Unit IV Monte Carlo Computations Dianne P. O Leary c 28 What is a Monte-Carlo method?

More information

nag 1d quad gauss (d01bac)

nag 1d quad gauss (d01bac) 1. Purpose nag 1d quad gauss () nag 1d quad gauss () computes an estimate of the definite integral of a function of known analytical form, using a Gaussian quadrature formula with a specified number of

More information

Scientific Computing with Case Studies SIAM Press, Lecture Notes for Unit IV Monte Carlo

Scientific Computing with Case Studies SIAM Press, Lecture Notes for Unit IV Monte Carlo Scientific Computing with Case Studies SIAM Press, 2009 http://www.cs.umd.edu/users/oleary/sccswebpage Lecture Notes for Unit IV Monte Carlo Computations Dianne P. O Leary c 2008 1 What is a Monte-Carlo

More information

Programming & Data Structure Laboratory. Day 2, July 24, 2014

Programming & Data Structure Laboratory. Day 2, July 24, 2014 Programming & Data Structure Laboratory Day 2, July 24, 2014 Loops Pre and post test loops for while do-while switch-case Pre-test loop and post-test loop Condition checking True Loop Body False Loop Body

More information

Note Set 4: Finite Mixture Models and the EM Algorithm

Note Set 4: Finite Mixture Models and the EM Algorithm Note Set 4: Finite Mixture Models and the EM Algorithm Padhraic Smyth, Department of Computer Science University of California, Irvine Finite Mixture Models A finite mixture model with K components, for

More information

MATRIX INTEGRALS AND MAP ENUMERATION 1

MATRIX INTEGRALS AND MAP ENUMERATION 1 MATRIX INTEGRALS AND MAP ENUMERATION 1 IVAN CORWIN Abstract. We explore the connection between integration with respect to the GUE and enumeration of maps. This connection is faciliated by the Wick Formula.

More information

A Proof of Pythagorian s Theorem

A Proof of Pythagorian s Theorem A Proof of Pythagorian s Theorem Pythagorian s theorem expresses an equality about the lengths of the sides of a right triangle It says that if the length of the hypothinus is c and lengths of the other

More information

CS 563 Advanced Topics in Computer Graphics Monte Carlo Integration: Basic Concepts. by Emmanuel Agu

CS 563 Advanced Topics in Computer Graphics Monte Carlo Integration: Basic Concepts. by Emmanuel Agu CS 563 Advanced Topics in Computer Graphics Monte Carlo Integration: Basic Concepts by Emmanuel Agu Introduction The integral equations generally don t have analytic solutions, so we must turn to numerical

More information

Random Number Generator of STMC and simple Monte Carlo Integration

Random Number Generator of STMC and simple Monte Carlo Integration Random Number Generator of STMC and simple Monte Carlo Integration Bernd Berg FSU MCMC Course, August 26, September 2, 2008 Random Numbers and Fortran Code According to Marsaglia and collaborators a list

More information

Exam Issued: May 29, 2017, 13:00 Hand in: May 29, 2017, 16:00

Exam Issued: May 29, 2017, 13:00 Hand in: May 29, 2017, 16:00 P. Hadjidoukas, C. Papadimitriou ETH Zentrum, CTL E 13 CH-8092 Zürich High Performance Computing for Science and Engineering II Exam Issued: May 29, 2017, 13:00 Hand in: May 29, 2017, 16:00 Spring semester

More information

Beginning C Programming for Engineers

Beginning C Programming for Engineers Beginning Programming for Engineers R. Lindsay Todd Lecture 2: onditionals, Logic, and Repetition R. Lindsay Todd () Beginning Programming for Engineers Beg 2 1 / 50 Outline Outline 1 Math Operators 2

More information

Numerical Simulation of Space Plasmas (I) [AP-4036] Lecture 4 by Ling-Hsiao Lyu April 2017

Numerical Simulation of Space Plasmas (I) [AP-4036] Lecture 4 by Ling-Hsiao Lyu April 2017 Lecture 4: Random Number Generators Random number generators are commonly used in particle-code simulations and in Monte Carlo simulations (e.g., Snell, 1975). 4.1. Uniform Random Number Generator Uniform

More information

Basic C Programming: Examples. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Basic C Programming: Examples. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Basic C Programming: Examples Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Selection Sort 12 6 12 6 22 14 8 17 6 12 8 22 14 12 8 17 Given

More information

Definition 3.1 The partial derivatives of a function f(x, y) defined on an open domain containing (x, y) are denoted by f

Definition 3.1 The partial derivatives of a function f(x, y) defined on an open domain containing (x, y) are denoted by f Chapter 3 Draft October 3, 009 3. Partial Derivatives Overview: Partial derivatives are defined by differentiation in one variable, viewing all others as constant (frozen at some value). The reduction

More information

LECTURE 8: Random numbers

LECTURE 8: Random numbers LECTURE 8: Random numbers November 2, 22 Introduction. Background What is a random number? Is 58935 "more random" than 2345?.8.6.4.2.2.4.6.8.5.5 Figure : Randomly distributed points. Randomness (uncorrelatedness)

More information

INTRODUCTION TO MONTE CARLO METHODS. Roger Martz

INTRODUCTION TO MONTE CARLO METHODS. Roger Martz INTRODUCTION TO MONTE CARLO METHODS Roger Martz 1 Introduction The Monte Carlo method solves problems through the use of random sampling. Otherwise know as the random walk method. A statistical method.

More information

PHYSICS 115/242 Homework 2, Solutions

PHYSICS 115/242 Homework 2, Solutions PHYSICS 115/242 Homework 2, Solutions 1. Trapezium Rule I wrote a function trap to do the trapezoidal rule, and put it in a separate file, trap.c. This is as follows: /******************************************************************

More information

Programming Assignment #3 Event Driven Simulation

Programming Assignment #3 Event Driven Simulation CS-2303, System Programming Concepts, A-term 2012 Project 3 (45 points) Assigned: Friday, September 7, 2012 Due: Friday, September 14, 2012, 11:59 PM Abstract Programming Assignment #3 Event Driven Simulation

More information

Parallel Techniques. Embarrassingly Parallel Computations. Partitioning and Divide-and-Conquer Strategies

Parallel Techniques. Embarrassingly Parallel Computations. Partitioning and Divide-and-Conquer Strategies slides3-1 Parallel Techniques Embarrassingly Parallel Computations Partitioning and Divide-and-Conquer Strategies Pipelined Computations Synchronous Computations Asynchronous Computations Load Balancing

More information

Section 6.2: Generating Discrete Random Variates

Section 6.2: Generating Discrete Random Variates Section 6.2: Generating Discrete Random Variates Discrete-Event Simulation: A First Course c 2006 Pearson Ed., Inc. 0-13-142917-5 Discrete-Event Simulation: A First Course Section 6.2: Generating Discrete

More information

Questions Q1. (a) Find the values of the constants A, B and C. (4) b) Hence find

Questions Q1. (a) Find the values of the constants A, B and C. (4) b) Hence find Questions Q1. (a) Find the values of the constants A, B and C. (4) b) Hence find (ii) Find, leaving your answer in the form a + ln b, where a and b are constants. (6) (Total 10 marks) Q2. (a) Find the

More information

What is Monte Carlo Modeling*?

What is Monte Carlo Modeling*? What is Monte Carlo Modeling*? Monte Carlo Modeling is a statisitcal method used here to simulate radiative transfer by simulating photon (or more exactly light rays/beams) interaction with a medium. MC

More information

Monte Carlo Integration

Monte Carlo Integration Lab 18 Monte Carlo Integration Lab Objective: Implement Monte Carlo integration to estimate integrals. Use Monte Carlo Integration to calculate the integral of the joint normal distribution. Some multivariable

More information

Continuity and Tangent Lines for functions of two variables

Continuity and Tangent Lines for functions of two variables Continuity and Tangent Lines for functions of two variables James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University April 4, 2014 Outline 1 Continuity

More information

Distribution of tree parameters

Distribution of tree parameters Distribution of tree parameters Stephan Wagner Stellenbosch University Strathmore conference, 23 June 2017 Trees Trees are one of the simplest and best-studied classes of graphs. They are characterised

More information

MATH 417 Homework 8 Instructor: D. Cabrera Due August 4. e i(2z) (z 2 +1) 2 C R. z 1 C 1. 2 (z 2 + 1) dz 2. φ(z) = ei(2z) (z i) 2

MATH 417 Homework 8 Instructor: D. Cabrera Due August 4. e i(2z) (z 2 +1) 2 C R. z 1 C 1. 2 (z 2 + 1) dz 2. φ(z) = ei(2z) (z i) 2 MATH 47 Homework 8 Instructor: D. abrera Due August 4. ompute the improper integral cos x (x + ) dx Solution: To evaluate the integral consider the complex integral e i(z) (z + ) dz where is the union

More information

13 Distribution Ray Tracing

13 Distribution Ray Tracing 13 In (hereafter abbreviated as DRT ), our goal is to render a scene as accurately as possible. Whereas Basic Ray Tracing computed a very crude approximation to radiance at a point, in DRT we will attempt

More information

Lecture 2: Introduction to Numerical Simulation

Lecture 2: Introduction to Numerical Simulation Lecture 2: Introduction to Numerical Simulation Ahmed Kebaier kebaier@math.univ-paris13.fr HEC, Paris Outline of The Talk 1 Simulation of Random variables Outline 1 Simulation of Random variables Random

More information

Calculus I Review Handout 1.3 Introduction to Calculus - Limits. by Kevin M. Chevalier

Calculus I Review Handout 1.3 Introduction to Calculus - Limits. by Kevin M. Chevalier Calculus I Review Handout 1.3 Introduction to Calculus - Limits by Kevin M. Chevalier We are now going to dive into Calculus I as we take a look at the it process. While precalculus covered more static

More information

Sorting. There exist sorting algorithms which have shown to be more efficient in practice.

Sorting. There exist sorting algorithms which have shown to be more efficient in practice. Sorting Next to storing and retrieving data, sorting of data is one of the more common algorithmic tasks, with many different ways to perform it. Whenever we perform a web search and/or view statistics

More information

Homework: Study 6.1 # 1, 5, 7, 13, 25, 19; 3, 17, 27, 53

Homework: Study 6.1 # 1, 5, 7, 13, 25, 19; 3, 17, 27, 53 January, 7 Goals:. Remember that the area under a curve is the sum of the areas of an infinite number of rectangles. Understand the approach to finding the area between curves.. Be able to identify the

More information

UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 2 Solution. Examiner : Ritu Chaturvedi Dated :November 27th, Student Name: Student Number:

UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 2 Solution. Examiner : Ritu Chaturvedi Dated :November 27th, Student Name: Student Number: UNIVERSITY OF WINDSOR 60-106-01 Fall 2007 QUIZ # 2 Solution Examiner : Ritu Chaturvedi Dated :November 27th, 2007. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed.

More information

2.9 Linear Approximations and Differentials

2.9 Linear Approximations and Differentials 2.9 Linear Approximations and Differentials 2.9.1 Linear Approximation Consider the following graph, Recall that this is the tangent line at x = a. We had the following definition, f (a) = lim x a f(x)

More information

Designing Loops and General Debug Pre-Defined Functions in C++ CS 16: Solving Problems with Computers I Lecture #6

Designing Loops and General Debug Pre-Defined Functions in C++ CS 16: Solving Problems with Computers I Lecture #6 Designing Loops and General Debug Pre-Defined Functions in C++ CS 16: Solving Problems with Computers I Lecture #6 Ziad Matni Dept. of Computer Science, UCSB Announcements Homework #5 due today Lab #3

More information

Floating-point numbers. Phys 420/580 Lecture 6

Floating-point numbers. Phys 420/580 Lecture 6 Floating-point numbers Phys 420/580 Lecture 6 Random walk CA Activate a single cell at site i = 0 For all subsequent times steps, let the active site wander to i := i ± 1 with equal probability Random

More information

What is the Monte Carlo Method?

What is the Monte Carlo Method? Program What is the Monte Carlo Method? A bit of history Applications The core of Monte Carlo: Random realizations 1st example: Initial conditions for N-body simulations 2nd example: Simulating a proper

More information

Chapter 3. Bootstrap. 3.1 Introduction. 3.2 The general idea

Chapter 3. Bootstrap. 3.1 Introduction. 3.2 The general idea Chapter 3 Bootstrap 3.1 Introduction The estimation of parameters in probability distributions is a basic problem in statistics that one tends to encounter already during the very first course on the subject.

More information

Lecture VII : Random systems and random walk

Lecture VII : Random systems and random walk Lecture VII : Random systems and random walk I. RANDOM PROCESSES In nature, no processes are truly deterministic. However, while dealing with many physical processes such as calculating trajectories of

More information

Assoc. Prof. Dr. Tansu FİLİK

Assoc. Prof. Dr. Tansu FİLİK Assoc. Prof. Dr. Tansu FİLİK Computer Programming Previously on Bil 200 Midterm Exam - 1 Midterm Exam - 1 126 students Curve: 49,78 Computer Programming Arrays Arrays List of variables: [ ] Computer Programming

More information

Three Different Algorithms for Generating Uniformly Distributed Random Points on the N-Sphere

Three Different Algorithms for Generating Uniformly Distributed Random Points on the N-Sphere Three Different Algorithms for Generating Uniformly Distributed Random Points on the N-Sphere Jan Poland Oct 4, 000 Abstract We present and compare three different approaches to generate random points

More information

Sec 6.3. Bluman, Chapter 6 1

Sec 6.3. Bluman, Chapter 6 1 Sec 6.3 Bluman, Chapter 6 1 Bluman, Chapter 6 2 Review: Find the z values; the graph is symmetrical. z = ±1. 96 z 0 z the total area of the shaded regions=5% Bluman, Chapter 6 3 Review: Find the z values;

More information

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #06

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #06 Department of Computer Science & Engineering Indian Institute of Technology Kharagpur Practice Sheet #06 Topic: Recursion in C 1. What string does the following program print? #include #include

More information

Computational Physics Adaptive, Multi-Dimensional, & Monte Carlo Integration Feb 21, 2019

Computational Physics Adaptive, Multi-Dimensional, & Monte Carlo Integration Feb 21, 2019 Computational Physics Adaptive, Multi-Dimensional, & Monte Carlo Integration Feb 21, 219 http://hadron.physics.fsu.edu/~eugenio/comphy/ eugenio@fsu.edu f(x) trapezoidal rule Series Integration review from

More information

Introduction to Computer Programming with MATLAB Calculation and Programming Errors. Selis Önel, PhD

Introduction to Computer Programming with MATLAB Calculation and Programming Errors. Selis Önel, PhD Introduction to Computer Programming with MATLAB Calculation and Programming Errors Selis Önel, PhD Today you will learn Numbers, Significant figures Error analysis Absolute error Relative error Chopping

More information

Random Number Generation. Biostatistics 615/815 Lecture 16

Random Number Generation. Biostatistics 615/815 Lecture 16 Random Number Generation Biostatistics 615/815 Lecture 16 Some Uses of Random Numbers Simulating data Evaluate statistical procedures Evaluate study designs Evaluate program implementations Controlling

More information

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring Instructions:

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring Instructions: VIRG INIA POLYTECHNIC INSTITUTE AND STATE U T PROSI M UNI VERSI TY Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted

More information

L20 MPI Example, Numerical Integration. Let s now consider a real problem to write a parallel code for. Let s take the case of numerical integration.

L20 MPI Example, Numerical Integration. Let s now consider a real problem to write a parallel code for. Let s take the case of numerical integration. Geophysical Computing L20-1 L20 MPI Example, Numerical Integration 1. Numerical Integration Let s now consider a real problem to write a parallel code for. Let s take the case of numerical integration.

More information

Sampling and Monte-Carlo Integration

Sampling and Monte-Carlo Integration Sampling and Monte-Carlo Integration Sampling and Monte-Carlo Integration Last Time Pixels are samples Sampling theorem Convolution & multiplication Aliasing: spectrum replication Ideal filter And its

More information

Fall Recursion and induction. Stephen Brookes. Lecture 4

Fall Recursion and induction. Stephen Brookes. Lecture 4 15-150 Fall 2018 Stephen Brookes Lecture 4 Recursion and induction Last time Specification format for a function F type assumption guarantee (REQUIRES) (ENSURES) For all (properly typed) x satisfying the

More information

Math 214 Introductory Statistics Summer Class Notes Sections 3.2, : 1-21 odd 3.3: 7-13, Measures of Central Tendency

Math 214 Introductory Statistics Summer Class Notes Sections 3.2, : 1-21 odd 3.3: 7-13, Measures of Central Tendency Math 14 Introductory Statistics Summer 008 6-9-08 Class Notes Sections 3, 33 3: 1-1 odd 33: 7-13, 35-39 Measures of Central Tendency odd Notation: Let N be the size of the population, n the size of the

More information

Quantitative Biology II!

Quantitative Biology II! Quantitative Biology II! Lecture 3: Markov Chain Monte Carlo! March 9, 2015! 2! Plan for Today!! Introduction to Sampling!! Introduction to MCMC!! Metropolis Algorithm!! Metropolis-Hastings Algorithm!!

More information

Computer Programming 5th Week loops (do-while, for), Arrays, array operations, C libraries

Computer Programming 5th Week loops (do-while, for), Arrays, array operations, C libraries Computer Programming 5th Week loops (do-while, for), Arrays, array operations, C libraries Hazırlayan Asst. Prof. Dr. Tansu Filik Computer Programming Previously on Bil 200 Low-Level I/O getchar, putchar,

More information

Interpolation. Most straightforward (never dramatically fails) and safe method is linear interpolation:

Interpolation. Most straightforward (never dramatically fails) and safe method is linear interpolation: Interpolation The objective is to find value of the function at any point x if one has values f i tabulated at certain points x i. Most straightforward (never dramatically fails) and safe method is linear

More information

M1-R4: Programing and Problem Solving using C (JAN 2019)

M1-R4: Programing and Problem Solving using C (JAN 2019) M1-R4: Programing and Problem Solving using C (JAN 2019) Max Marks: 100 M1-R4-07-18 DURATION: 03 Hrs 1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter

More information

MA651 Topology. Lecture 4. Topological spaces 2

MA651 Topology. Lecture 4. Topological spaces 2 MA651 Topology. Lecture 4. Topological spaces 2 This text is based on the following books: Linear Algebra and Analysis by Marc Zamansky Topology by James Dugundgji Fundamental concepts of topology by Peter

More information

Biostatistics 615/815 Lecture 16: Importance sampling Single dimensional optimization

Biostatistics 615/815 Lecture 16: Importance sampling Single dimensional optimization Biostatistics 615/815 Lecture 16: Single dimensional optimization Hyun Min Kang November 1st, 2012 Hyun Min Kang Biostatistics 615/815 - Lecture 16 November 1st, 2012 1 / 59 The crude Monte-Carlo Methods

More information

CORDIC Fixed Point Simulation. Young Won Lim 2/28/12

CORDIC Fixed Point Simulation. Young Won Lim 2/28/12 CORDIC Fixed Point Simulation Copyright (c) 2012 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or

More information

Chapter 5 C Functions

Chapter 5 C Functions Chapter 5 C Functions Objectives of this chapter: To construct programs from small pieces called functions. Common math functions in math.h the C Standard Library. sin( ), cos( ), tan( ), atan( ), sqrt(

More information

Lecture 8: Jointly distributed random variables

Lecture 8: Jointly distributed random variables Lecture : Jointly distributed random variables Random Vectors and Joint Probability Distributions Definition: Random Vector. An n-dimensional random vector, denoted as Z = (Z, Z,, Z n ), is a function

More information

There are algorithms, however, that need to execute statements in some other kind of ordering depending on certain conditions.

There are algorithms, however, that need to execute statements in some other kind of ordering depending on certain conditions. Introduction In the programs that we have dealt with so far, all statements inside the main function were executed in sequence as they appeared, one after the other. This type of sequencing is adequate

More information

Programming for Engineers Functions

Programming for Engineers Functions Programming for Engineers Functions ICEN 200 Spring 2018 Prof. Dola Saha 1 Introduction Real world problems are larger, more complex Top down approach Modularize divide and control Easier to track smaller

More information

NAG Library Routine Document D01BAF.1

NAG Library Routine Document D01BAF.1 NAG Library Routine Document Note: before using this routine, please read the Users Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent

More information

Computational Methods. Randomness and Monte Carlo Methods

Computational Methods. Randomness and Monte Carlo Methods Computational Methods Randomness and Monte Carlo Methods Manfred Huber 2010 1 Randomness and Monte Carlo Methods Introducing randomness in an algorithm can lead to improved efficiencies Random sampling

More information

Floating Point Arithmetic

Floating Point Arithmetic Floating Point Arithmetic Computer Systems, Section 2.4 Abstraction Anything that is not an integer can be thought of as . e.g. 391.1356 Or can be thought of as + /

More information

Standard Library Functions Outline

Standard Library Functions Outline Standard Library Functions Outline 1. Standard Library Functions Outline 2. Functions in Mathematics #1 3. Functions in Mathematics #2 4. Functions in Mathematics #3 5. Function Argument 6. Absolute Value

More information

Math 467 Homework Set 1: some solutions > with(detools): with(plots): Warning, the name changecoords has been redefined

Math 467 Homework Set 1: some solutions > with(detools): with(plots): Warning, the name changecoords has been redefined Math 467 Homework Set : some solutions > with(detools): with(plots): Warning, the name changecoords has been redefined Problem : 2.2.7 Find the fixed points, determine their stability, for d x( t ) = cos

More information

16.216: ECE Application Programming Fall 2011

16.216: ECE Application Programming Fall 2011 16.216: ECE Application Programming Fall 2011 Exam 2 Solution 1. (24 points, 6 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling

More information

Interpolation and Splines

Interpolation and Splines Interpolation and Splines Anna Gryboś October 23, 27 1 Problem setting Many of physical phenomenona are described by the functions that we don t know exactly. Often we can calculate or measure the values

More information

Chapter 1. Math review. 1.1 Some sets

Chapter 1. Math review. 1.1 Some sets Chapter 1 Math review This book assumes that you understood precalculus when you took it. So you used to know how to do things like factoring polynomials, solving high school geometry problems, using trigonometric

More information

Two Dimensional Array - An array with a multiple indexs.

Two Dimensional Array - An array with a multiple indexs. LAB5 : Arrays Objectives: 1. To learn how to use C array as a counter. 2. To learn how to add an element to the array. 3. To learn how to delete an element from the array. 4. To learn how to declare two

More information

MAT 3271: Selected Solutions to the Assignment 6

MAT 3271: Selected Solutions to the Assignment 6 Chapter 2: Major Exercises MAT 3271: Selected Solutions to the Assignment 6 1. Since a projective plan is a model of incidence geometry, Incidence Axioms 1-3 and Propositions 2.1-2.5 (which follow logically

More information

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage:

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage: Discussion 1H Notes (Week 3, April 14) TA: Brian Choi (schoi@cs.ucla.edu) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 More on Arithmetic Expressions The following two are equivalent:! x = x + 5;

More information

SF1901 Probability Theory and Statistics: Autumn 2016 Lab 0 for TCOMK

SF1901 Probability Theory and Statistics: Autumn 2016 Lab 0 for TCOMK Mathematical Statistics SF1901 Probability Theory and Statistics: Autumn 2016 Lab 0 for TCOMK 1 Preparation This computer exercise is a bit different from the other two, and has some overlap with computer

More information

METROPOLIS MONTE CARLO SIMULATION

METROPOLIS MONTE CARLO SIMULATION POLYTECHNIC UNIVERSITY Department of Computer and Information Science METROPOLIS MONTE CARLO SIMULATION K. Ming Leung Abstract: The Metropolis method is another method of generating random deviates that

More information

Monte Carlo Integration

Monte Carlo Integration Lecture 11: Monte Carlo Integration Computer Graphics and Imaging UC Berkeley CS184/284A, Spring 2016 Reminder: Quadrature-Based Numerical Integration f(x) Z b a f(x)dx x 0 = a x 1 x 2 x 3 x 4 = b E.g.

More information

Functions. Computer System and programming in C Prentice Hall, Inc. All rights reserved.

Functions. Computer System and programming in C Prentice Hall, Inc. All rights reserved. Functions In general, functions are blocks of code that perform a number of pre-defined commands to accomplish something productive. You can either use the built-in library functions or you can create

More information

In the real world, light sources emit light particles, which travel in space, reflect at objects or scatter in volumetric media (potentially multiple

In the real world, light sources emit light particles, which travel in space, reflect at objects or scatter in volumetric media (potentially multiple 1 In the real world, light sources emit light particles, which travel in space, reflect at objects or scatter in volumetric media (potentially multiple times) until they are absorbed. On their way, they

More information

Lecture 14. December 19, Department of Biostatistics Johns Hopkins Bloomberg School of Public Health Johns Hopkins University.

Lecture 14. December 19, Department of Biostatistics Johns Hopkins Bloomberg School of Public Health Johns Hopkins University. geometric Lecture 14 Department of Biostatistics Johns Hopkins Bloomberg School of Public Health Johns Hopkins University December 19, 2007 geometric 1 2 3 4 geometric 5 6 7 geometric 1 Review about logs

More information