Multidimensional Optimizations Single Dimensional and Biostatistics - - PowerPoint PPT Presentation

multidimensional optimizations single dimensional and
SMART_READER_LITE
LIVE PREVIEW

Multidimensional Optimizations Single Dimensional and Biostatistics - - PowerPoint PPT Presentation

. . March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang March 21th, 2011 Hyun Min Kang Multidimensional Optimizations Single Dimensional and Biostatistics 615/815 Lecture 18: . . . . . . Summary . Introduction . .


slide-1
SLIDE 1

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

. . . . . . .

Biostatistics 615/815 Lecture 18: Single Dimensional and Multidimensional Optimizations

Hyun Min Kang March 21th, 2011

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 1 / 39

slide-2
SLIDE 2

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Annoucements

.

Homework and Grading

. . . . . . . .

  • Homework #5 annouced
  • Homework grading is still pending

.

Thursday March 24th

. . . . . . . .

  • Mary Kate Trost will introduce us a very useful C++ library

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 2 / 39

slide-3
SLIDE 3

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Recap : Root Finding with C++

double binaryZero(myFunc foo, double lo, double hi, double e) { for (int i=0;; ++i) { double d = hi - lo; // f(lo) < 0, f(hi) > 0, d can be positive or negative double point = lo + d * 0.5; // d is + for increasing func, - for decreasing func. double fpoint = foo(point); // evaluate the value of the function if (fpoint < 0.0) { d = lo - point; lo = point; // } else { d = point - hi; hi = point; } // e is tolerance level (higher e makes it faster but less accruate) if (fabs(d) < e || fpoint == 0.0) { std::cout << "Iteration " << i << ", point = " << point << ", d = " << d << std::endl; return point; } } }

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 3 / 39

slide-4
SLIDE 4

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Recap : Improvements to Root Finding

.

Approximation using linear interpolation

. . . . . . . . f∗(x) = f(a) + (x − a)f(b) − f(a) b − a .

Root Finding Strategy

. . . . . . . .

  • Select a new trial point such that f∗(x) = 0

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 4 / 39

slide-5
SLIDE 5

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Recap : Detailed Minimization Strategy

. . 1 Find 3 points such that

  • a < b < c
  • f(b) < f(a) and f(b) < f(c)

. . 2 Then search for minimum by

  • Selecting trial point in the interval
  • Keep minimum and flanking points

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 5 / 39

slide-6
SLIDE 6

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Recap : The Golden Search

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 6 / 39

slide-7
SLIDE 7

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Recap : Golden Search

double goldenSearch(myFunc foo, double a, double b, double c, double e) { int i = 0; double fb = foo(b); while ( fabs(c-a) > fabs(b*e) ) { double x = b + goldenStep(a, b, c); double fx = foo(x); if ( fx < fb ) { (x > b) ? ( a = b ) : ( c = b); b = x; fb = fx; } else { (x < b) ? ( a = x ) : ( c = x ); } ++i; } std::cout << "i = " << i << ", b = " << b << ", f(b) = " << foo(b) << std::endl; return b; }

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 7 / 39

slide-8
SLIDE 8

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Today

.

A better single-dimensional optimization

. . . . . . . .

  • Parabolic interpolation
  • Adaptive method

.

Multi-dimensional optimization

. . . . . . . .

  • Simplex algorithm

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 8 / 39

slide-9
SLIDE 9

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Better optimization using local approximation

  • Root finding example
  • Binary search reduces the search space by constant factor 1/2
  • Linear approximation may reduce the search space more rapidly for

most well-defined functions

  • Minimization problem
  • Golden search reduces the search space by 38%
  • Using a quadratic approximation of the function may achieve better
  • ptimization results

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 9 / 39

slide-10
SLIDE 10

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Approximation using parabola

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 10 / 39

slide-11
SLIDE 11

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Parabolic Approximation

f∗(x) = Ax + Bx + C The value minimizes f∗(x) is xmin = − B 2A This strategy is called ”inverse parabolic interpolation”

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 11 / 39

slide-12
SLIDE 12

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Fitting a parabola

  • Can be fitted with three points
  • Points must not be co-linear
  • f∗(x1) = f(x1), f∗(x2) = f(x2), f∗(x3) = f(x3).

C = f(x1) − Ax2

1 − Bx1

B = A(x2

2 − x2 1) + f(x1) − f(x2)

x1 − x2 A = f(x3) − f(x2) (x3 − x2)(x3 − x1) − f(x1) − f(x2) (x1 − x2)(x3 − x1)

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 12 / 39

slide-13
SLIDE 13

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Minimum for a Parabola

  • General expression for finding minimum of a parabola fitted through

three points xmin = x2 − 1 2 (x2 − x1)2(f(x2) − f(x1)) − (x2 − x3)2(f(x2) − f(x1)) (x2 − x1)(f(x2) − f(x1)) − (x2 − x3)(f(x2) − f(x1))

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 13 / 39

slide-14
SLIDE 14

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Fitting a Parabola

// Returns the distance between b and the abscissa for the // fitted minimum using parabolic interpolation double parabola_step (double a, double fa, double b, double fb, double c, double fc) { // Quantities for placing minimum of fitted parabola double p = (b - a) * (fb - fc); double q = (b - c) * (fb - fa); double x = (b - c) * q - (b - a) * p; double y = 2.0 * (p - q); // Check that q is not zero if (fabs(y) < ZEPS) return golden_step (a, b, c); else return x / y; }

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 14 / 39

slide-15
SLIDE 15

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Avoiding degenerate case

  • Fitted minimum could overlap with one of original points
  • Ensure that each new point is distinct from previously examined

points

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 15 / 39

slide-16
SLIDE 16

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Avoiding degenerate steps

double adjust_step(double a, double b, double c, double step, double e) { double min_step = fabs(e * b) + ZEPS; if (fabs(step) < min_step) return step > 0 ? min_step : 0-min_step; // If the step ends up to close to previous points, // return zero to force a golden ratio step ... if (fabs(b + step - a) <= e || fabs(b + step - c) <= e) return 0.0; return step; }

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 16 / 39

slide-17
SLIDE 17

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Generating New Points

  • Use parabolic interpolation by default
  • Check whether improvement is slow
  • If step sizes are not decreasing rapidly enough, switch to golden

section

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 17 / 39

slide-18
SLIDE 18

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Adaptive calculation of step size

double calculate_step(double a, double fa, double b, double fb, double c, double fc, double last_step, double e) { double step = parabola_step(a, fa, b, fb, c, fc); step = adjust_step(a, b, c, step, e); if (fabs(step) > fabs(0.5 * last_step) || step == 0.0) step = golden_step(a, b, c); return step; }

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 18 / 39

slide-19
SLIDE 19

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Overall

The main function simply has to

  • Generate new points using building blocks
  • Update the triplet bracketing the minimum
  • Check for convergence

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 19 / 39

slide-20
SLIDE 20

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Overall Minimization Routine

double find_minimum(myFunc foo, double a, double b, double c, double e) { double fa = foo(a), fb = foo(b), fc = foo(c); double step1 = (c - a) * 0.5, step2 = (c - a) * 0.5; while ( fabs(c - a) > fabs(b * e) + ZEPS) { double step = calculate_step (a, fa, b, fb, c, fc, step2, e); double x = b + step; double fx = foo(x); if (fx < fb) { if (x > b) { a = b; fa = fb; } else { c = b; fc = fb; } b = x; fb = fx; } else { if (x < b) { a = x; fa = fx; } else { c = x; fc = fx; } step2 = step1; step1 = step; } } return b; }

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 20 / 39

slide-21
SLIDE 21

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Important Characteristics

  • Parabolic interpolation often converges faster
  • The preferred algorithm
  • Golden search provides worst-cast performance guarantee
  • A fall-back for uncooperative functions
  • Switch algorithms when convergence is slow
  • Avoid testing points that are too close

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 21 / 39

slide-22
SLIDE 22

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

More advanced strategy : Brent’s algorithm

  • Track 6 points (not all distinct)
  • The bracket boundaries (a, b)
  • The current minimum x
  • The second and third smallest value (w, v)
  • The new points to be examined u
  • Parabolic interpolation
  • Using (x, w, v) to propose new value for u.
  • Additional care is required to ensure u falls between a and b.

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 22 / 39

slide-23
SLIDE 23

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Recommended Reading

  • Numerical Recipes in C++
  • Chapter 10.0 - 10.3

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 23 / 39

slide-24
SLIDE 24

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Multidimensional Optimization : A mixture distribution

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 24 / 39

slide-25
SLIDE 25

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

A general mixture distribution

p(x; π, φ, η) =

k

i=1

πif(x; φi, η) x observed data π mixture proportion of each component f the probability density function φ parameters specific to each component η parameters shared among components k numer of mixture components

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 25 / 39

slide-26
SLIDE 26

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Problem : Maximum Likelihood Estimation

.

Finding Maximum-likelihood

. . . . . . . . Find parameters that maximizes the likelihood of the entire sample L = ∏

i

p(xi|π, φ, η) .

Calculating in log-space

. . . . . . . . Or equivalently, consider log-likelihood to avoid underflow l = ∑

i

log p(xi|π, φ, η)

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 26 / 39

slide-27
SLIDE 27

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Gaussian MLE in single-dimensional space

p(x; µ, σ2) = N(x; µ, σ2) Given x, what is the MLE parameters of µ and σ2? Analytical solution does exist

n i

xi n

n i

xi n

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 27 / 39

slide-28
SLIDE 28

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Gaussian MLE in single-dimensional space

p(x; µ, σ2) = N(x; µ, σ2) Given x, what is the MLE parameters of µ and σ2?

  • Analytical solution does exist
  • ˆ

µ = ∑n

i=1 xi/n

  • ˆ

σ2 = ∑n

i=1(xi − ˆ

µ)2/n

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 27 / 39

slide-29
SLIDE 29

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

MLE in Gaussian mixture

.

Parameter estimation in Gaussian mixture

. . . . . . . .

  • No analytical solution
  • Numerical optimization required
  • Multi-dimensional optimization problem
  • µ1, µ2, · · · , µk
  • σ2

1, σ2 2, · · · , σ2 k

.

Possible approaches

. . . . . . . .

  • Simplex Method
  • Expectation Maximization
  • Markov-Chain Monte Carlo

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 28 / 39

slide-30
SLIDE 30

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

The Simplex Method

  • Calculate likelihoods at simplex vetices
  • Geomtric shape with k + 1 corners
  • A triangle in k = 2 dimensions
  • Simplex crawls
  • Towards minimum
  • Away from maximum
  • Probably the most widely used optimization method

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 29 / 39

slide-31
SLIDE 31

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

How the Simplex Method Works

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 30 / 39

slide-32
SLIDE 32

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Simplex Method in Two Dimensions

  • Evaluate functions at three vertices
  • The highest (worst) point
  • The next highest point
  • The lowest (best) point
  • Intuition
  • Move away from high point, towards low point

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 31 / 39

slide-33
SLIDE 33

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Direction for Optimization

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 32 / 39

slide-34
SLIDE 34

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Reflection

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 33 / 39

slide-35
SLIDE 35

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Reflection and Expansion

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 34 / 39

slide-36
SLIDE 36

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Contaction (1-dimension)

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 35 / 39

slide-37
SLIDE 37

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Contaction

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 36 / 39

slide-38
SLIDE 38

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Summary : The Simplex Method

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 37 / 39

slide-39
SLIDE 39

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Today

  • Single-dimensional minimization
  • Minimization using Parabola
  • Adaptive minimization using parabola and golden search
  • A taste of Brent’s method
  • Multi-dimensional optimization
  • Gaussian mixture example
  • Simplex algorithm

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 38 / 39

slide-40
SLIDE 40

. . . . . .

. . . . . . . Introduction . . . . . . . . . . . . . Parabola . . Brent . . . . Mixture . . . . . . . . . . Simplex . . Summary

Upcoming lectures

.

Next Lecture

. . . . . . . .

  • Special lecturer : Mary Kate Trost
  • Practical lessons in C++

.

Next week

. . . . . . . .

  • Details of simplex algorithm
  • Expectation-Maximization algorithm

Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 39 / 39