Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
General-purpose computing on graphics processing units wikipedia , lookup
BSAVE (bitmap format) wikipedia , lookup
Free and open-source graphics device driver wikipedia , lookup
Computer vision wikipedia , lookup
Apple II graphics wikipedia , lookup
Waveform graphics wikipedia , lookup
Framebuffer wikipedia , lookup
Tektronix 4010 wikipedia , lookup
Monte Carlo integration computer graphics • Monte Carlo integration © 2006 fabio pellacini • 1 integrals and averages integral of a function over a domain “size” of a domain average of a function over a domain computer graphics • Monte Carlo integration © 2006 fabio pellacini • 2 integrals and averages examples • average “daily” snowfall in Hanover last year – domain: year - time interval (1D) – integration variable: “day” of the year – function: snowfall of “day” computer graphics • Monte Carlo integration © 2006 fabio pellacini • 3 integrals and averages examples • “today” average snowfall in New Hampshire – domain: New Hamshire - surface (2D) – integration variable: “location” in New Hampshire – function: snowfall of “location” computer graphics • Monte Carlo integration © 2006 fabio pellacini • 4 integrals and averages examples • “today” average snowfall in New Hampshire – domain: New Hamshire x year – area x time (3D) – integration variables: “location” and “day” in New Hampshire this year – function: snowfall of “location” and “day” computer graphics • Monte Carlo integration © 2006 fabio pellacini • 5 discreet random variable • random variable: • values: • probabilities: • example: tossing a die – values: – probabilities: computer graphics • Monte Carlo integration © 2006 fabio pellacini • 6 expected value and variance • expected value: – average value of the variable • variance: – how much different from the average – property: • example: tossing a die – expected value: – variance: computer graphics • Monte Carlo integration © 2006 fabio pellacini • 7 estimating expected values • to estimate the expected value of a variable – choose a set of random values based on the prob. – average their results • larger N give better estimate • example: rolling a die – roll 3 times: – roll 9 times: computer graphics • Monte Carlo integration © 2006 fabio pellacini • 8 law of large numbers • by taking infinitely many samples, the error between the estimate and the expected value is statistically zero – the estimate will converge to the right value computer graphics • Monte Carlo integration © 2006 fabio pellacini • 9 continuous random variable • random variable: • values: • probability density function: – property: • probability that var. has value x: computer graphics • Monte Carlo integration © 2006 fabio pellacini • 10 uniformly distributed random variable • p is the same everywhere in the interval implies [Bala] and computer graphics • Monte Carlo integration © 2006 fabio pellacini • 11 expected value and variance • expected value: • variance: • estimating expected values: computer graphics • Monte Carlo integration © 2006 fabio pellacini • 12 multidimensional random variables • everything works fine in multiple dimensions – but it is often hard to precisely define domain • except in simple cases computer graphics • Monte Carlo integration © 2006 fabio pellacini • 13 deterministic numerical integration [Bala] • split domain in set of fixed segments • sum function values times size of segments computer graphics • Monte Carlo integration © 2006 fabio pellacini • 14 Monte Carlo numerical integration • need to evaluate • by definition • can be estimated as • by substituting computer graphics • Monte Carlo integration © 2006 fabio pellacini • 15 Monte Carlo numerical integration [Bala] • intuition: compute the area randomly and average the results computer graphics • Monte Carlo integration © 2006 fabio pellacini • 16 Monte Carlo numerical integration • formally, we can prove that • meaning that if we were to try multiple times to evaluate the integral using our new procedure, we would get, on average, the same result • variance of the estimate: computer graphics • Monte Carlo integration © 2006 fabio pellacini • 17 example: integral of constant function • analytic integration • Monte Carlo integration computer graphics • Monte Carlo integration © 2006 fabio pellacini • 18 example: computing pi [MIT OpenCourseWare] • take the square [0,1]2, with a quarter-circle in it computer graphics • Monte Carlo integration © 2006 fabio pellacini • 19 example: computing pi [MIT OpenCourseWare] • estimate area of circle by tossing point in the plane and evaluating f computer graphics • Monte Carlo integration © 2006 fabio pellacini • 20 example: computing pi • by definition • numerical estimation of pi computer graphics • Monte Carlo integration © 2006 fabio pellacini • 21 Monte Carlo numerical integration • works in any dimension! – need to carefully pick the points – need to properly define the pdf • hard for complex domain shapes • e.g. how to uniformly sample a sphere? • works for badly-behaving functions! computer graphics • Monte Carlo integration © 2006 fabio pellacini • 22 Monte Carlo numerical integration • expected value of the error is [Bala] – convergence does not depend on dimensionality – deterministic integration is hard in high dimensions computer graphics • Monte Carlo integration © 2006 fabio pellacini • 23 importance sampling principle • how to minimize the noise? • pick samples in area where function is large • pick a distribution similar to the function computer graphics • Monte Carlo integration © 2006 fabio pellacini • 24 1D interval - uniform sampling • call random function in [0,1), rescale if necessary – in reality only pseudorandom • relies on good generator computer graphics • Monte Carlo integration © 2006 fabio pellacini • 25 2D square – uniform sampling [Shirley] • pick two independent random values in [0,1) computer graphics • Monte Carlo integration © 2006 fabio pellacini • 26 2D square – stratified sampling • divide domain in smaller domains, then pick random points in each [Shirley] – better variance than normal sampling computer graphics • Monte Carlo integration © 2006 fabio pellacini • 27 2D circle – rejection sampling [Shirley] • pick random points in the uniform square and discard the ones outside the domain computer graphics • Monte Carlo integration © 2006 fabio pellacini • 28 2D circle – remapping from square [Shirley] • pick random points in the uniform square and remap them on the circle using polar coords. computer graphics • Monte Carlo integration © 2006 fabio pellacini • 29 2D circle – remapping from square • make sampling uniform by computing proper pdf [Shirley] – Sh. 14.4.1 computer graphics • Monte Carlo integration © 2006 fabio pellacini • 30 3D direction – uniform distribution • uniformly distribution with respect to solid angle computer graphics • Monte Carlo integration © 2006 fabio pellacini • 31 3D direction – cosine distribution • cosine distribution with respect to solid angle computer graphics • Monte Carlo integration © 2006 fabio pellacini • 32 3D direction – cosine power distribution • cosine power distribution wrt solid angle computer graphics • Monte Carlo integration © 2006 fabio pellacini • 33