Analyzing Control Structures

Similar documents
MONOPOLISTIC COMPETITION MODEL

Ruin Probability-Based Initial Capital of the Discrete-Time Surplus Process

Computational Geometry

Problems and Solutions

The Selection Problem - Variable Size Decrease/Conquer (Practice with algorithm analysis)

For combinatorial problems we might need to generate all permutations, combinations, or subsets of a set.

PTAS for Bin-Packing

A Mean- maximum Deviation Portfolio Optimization Model

Math 10 Discrete Mathematics

This lecture and the next. Why Sorting? Sorting Algorithms so far. Why Sorting? (2) Selection Sort. Heap Sort. Heapsort

Spring Ammar Abu-Hudrouss Islamic University Gaza

UNIT 2 SOLUTION OF ALGEBRAIC AND TRANSCENDENTAL EQUATIONS

Design maintenanceand reliability of engineering systems: a probability based approach

2006 Jamie Trahan, Autar Kaw, Kevin Martin University of South Florida United States of America

Econometric Methods. Review of Estimation

Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand DIS 10b

UNIVERSITY OF OSLO DEPARTMENT OF ECONOMICS

Chapter 9 Jordan Block Matrices

Lecture 7. Confidence Intervals and Hypothesis Tests in the Simple CLR Model

Mu Sequences/Series Solutions National Convention 2014

8.1 Hashing Algorithms

(This summarizes what you basically need to know about joint distributions in this course.)

The number of observed cases The number of parameters. ith case of the dichotomous dependent variable. the ith case of the jth parameter

Lecture Notes Types of economic variables

Assignment 5/MATH 247/Winter Due: Friday, February 19 in class (!) (answers will be posted right after class)

Lecture 3 Probability review (cont d)

Unsupervised Learning and Other Neural Networks

Lecture 3. Sampling, sampling distributions, and parameter estimation

Homework 1: Solutions Sid Banerjee Problem 1: (Practice with Asymptotic Notation) ORIE 4520: Stochastics at Scale Fall 2015

Assignment 7/MATH 247/Winter, 2010 Due: Friday, March 19. Powers of a square matrix

ENGI 3423 Simple Linear Regression Page 12-01

Chapter 4 Multiple Random Variables

Lecture 9: Tolerant Testing

MA 524 Homework 6 Solutions

COMP26120: Introducing Complexity Analysis (2018/19) Lucas Cordeiro

Bounds on the expected entropy and KL-divergence of sampled multinomial distributions. Brandon C. Roy

best estimate (mean) for X uncertainty or error in the measurement (systematic, random or statistical) best

III-16 G. Brief Review of Grand Orthogonality Theorem and impact on Representations (Γ i ) l i = h n = number of irreducible representations.

Simple Linear Regression

Chapter 1 Counting Methods

Chapter 14 Logistic Regression Models

7.0 Equality Contraints: Lagrange Multipliers

Chapter 5 Properties of a Random Sample

L5 Polynomial / Spline Curves

Multiple Regression. More than 2 variables! Grade on Final. Multiple Regression 11/21/2012. Exam 2 Grades. Exam 2 Re-grades

Algorithms Theory, Solution for Assignment 2

F. Inequalities. HKAL Pure Mathematics. 進佳數學團隊 Dr. Herbert Lam 林康榮博士. [Solution] Example Basic properties

All-Pairs shortest paths via fast matrix multiplication

1. A real number x is represented approximately by , and we are told that the relative error is 0.1 %. What is x? Note: There are two answers.

( ) 2 2. Multi-Layer Refraction Problem Rafael Espericueta, Bakersfield College, November, 2006

MEASURES OF DISPERSION

Log1 Contest Round 2 Theta Complex Numbers. 4 points each. 5 points each

Tail Factor Convergence in Sherman s Inverse Power Curve Loss Development Factor Model

Ideal multigrades with trigonometric coefficients

On the Nonlinear Difference Equation

Mathematical Statistics

Introduction to local (nonparametric) density estimation. methods

MOLECULAR VIBRATIONS

Some Different Perspectives on Linear Least Squares

ON THE LAWS OF LARGE NUMBERS FOR DEPENDENT RANDOM VARIABLES

Feature Selection: Part 2. 1 Greedy Algorithms (continued from the last lecture)

ρ < 1 be five real numbers. The

r 1,2 = a 1 (a 2 2 4a 2 a 0 )

X X X E[ ] E X E X. is the ()m n where the ( i,)th. j element is the mean of the ( i,)th., then

QR Factorization and Singular Value Decomposition COS 323

KLT Tracker. Alignment. 1. Detect Harris corners in the first frame. 2. For each Harris corner compute motion between consecutive frames

ECONOMETRIC THEORY. MODULE VIII Lecture - 26 Heteroskedasticity

MA/CSSE 473 Day 27. Dynamic programming

2.28 The Wall Street Journal is probably referring to the average number of cubes used per glass measured for some population that they have chosen.

Numerical Analysis Formulae Booklet

THE COMPLETE ENUMERATION OF FINITE GROUPS OF THE FORM R 2 i ={R i R j ) k -i=i

{ }{ ( )} (, ) = ( ) ( ) ( ) Chapter 14 Exercises in Sampling Theory. Exercise 1 (Simple random sampling): Solution:

1 0, x? x x. 1 Root finding. 1.1 Introduction. Solve[x^2-1 0,x] {{x -1},{x 1}} Plot[x^2-1,{x,-2,2}] 3

hp calculators HP 30S Statistics Averages and Standard Deviations Average and Standard Deviation Practice Finding Averages and Standard Deviations

To use adaptive cluster sampling we must first make some definitions of the sampling universe:

CS286.2 Lecture 4: Dinur s Proof of the PCP Theorem

Random Variables and Probability Distributions

18.413: Error Correcting Codes Lab March 2, Lecture 8

PPCP: The Proofs. 1 Notations and Assumptions. Maxim Likhachev Computer and Information Science University of Pennsylvania Philadelphia, PA 19104

Generalized Linear Regression with Regularization

Algorithms Design & Analysis. Hash Tables

THE ROYAL STATISTICAL SOCIETY HIGHER CERTIFICATE

Newton s Power Flow algorithm

AN UPPER BOUND FOR THE PERMANENT VERSUS DETERMINANT PROBLEM BRUNO GRENET

Q-analogue of a Linear Transformation Preserving Log-concavity

Section 2:00 ~ 2:50 pm Thursday in Maryland 202 Sep. 29, 2005

Simulation Output Analysis

CHAPTER 4 RADICAL EXPRESSIONS

CIS 800/002 The Algorithmic Foundations of Data Privacy October 13, Lecture 9. Database Update Algorithms: Multiplicative Weights

Supervised learning: Linear regression Logistic regression

1 Onto functions and bijections Applications to Counting

Solving Constrained Flow-Shop Scheduling. Problems with Three Machines

Logistic regression (continued)

Algorithms. Elementary Sorting. Dong Kyue Kim Hanyang University

Lecture Notes 2. The ability to manipulate matrices is critical in economics.

CHAPTER VI Statistical Analysis of Experimental Data

Ordinary Least Squares Regression. Simple Regression. Algebra and Assumptions.

ESS Line Fitting

Analysis of Variance with Weibull Data

2. Higher Order Consensus

Transcription:

Aalyzg Cotrol Strutures sequeg P, P : two fragmets of a algo. t, t : the tme they tae the tme requred to ompute P ;P s t t Θmaxt,t For loops for to m do P t: the tme requred to ompute P total tme requred by the loop s smply mt? Cosder loop otrol? whle m do P

Aalyss of For Loops Whe the tme t requred for P vares as a futo of the tme taes s Ex: Fboa sequee f the strutos sde the for loop tae ostat tme, what does the algorthm tae? Is t reasoable to out the addtos at ut ost? m t futo Fboa ; j for to do j j j - retur j

Example: Computg Fboa Sequee It s ot reasoable to out the addtos at ut ost uless s vary small assume the tme eeded s the exat order of the umber of fgures the operads the values of ad j at the ed of -th terato are f - ad f, respetvely Movre s: the sze of f s Θ the -th terato taes Θ- Θ Θ the tme tae by the algorthm O

Aalyss of Reursve Algorthms futo Fbre f < the retur else retur Fbre- Fbre- Let T be the tme tae by a all o Fbre f <, the algorthm taes some ostat tme a otherwse, t taes T- T- h a T T T h f or otherwse solvg ths reurree relato, we have T Θf, o matter h s bouded by a ostat or h Θ 4

Whle ad Repeat Loops futo Bary_SearhT[..], x ; j ; whle < j do j ; ase x < T[]: j - ; ase x T[]:, j {retur }; ase x > T[]: ; retur No obvous way to ow how may tmes the loop wll terate two approahes fd a futo of the varables volved whose value dereases eah tme aroud treat whle le reursve algorthms 5

6 Aalyss of Bary_Searh Fd a futo of the varables volved whose value dereases eah tme roud the loop osder d j - ; x < T[] x T[] x > T[] / / ˆ ˆ ˆ ; - ] [ ˆ ; ˆ d j j j d j j < / / ˆ ˆ ˆ ; ˆ ; ] [ ˆ d j j j j j d j j j s at least / ˆ d d d The value of d s at least halved eah tme roud the loop the loop s etered at most tmes lg lg log

The Alteratve Approah Th of the whle loop as f t were mplemeted reursvely let td deote the maxmum tme eeded to termate the whle loop whe there are at most d elemets : the tme to determe that the loop s fshed b: the tme requred to go roud the loop oe t d b t d f d otherwse d s at least halved eah tme roud the loop 7

Usg a Barometer Barometer struto exeuted at least as ofte as ay other struto the algorthm o harm f some strutos are exeuted up to a ostat umber of tmes more ofte tha barometer Whe a algorthm volves several ested loops ay struto of the er most loop a usually be used as barometer ths should be doe arefully 8

Usg a Barometer: A Example pgeo T[] T[] T[] T[] T[] pgeo hole 4 s U[] Pgeo-hole sortg for to s do whle U [] do T [] U [] U [] - hoose ay of the strutos the er loop as a barometer? ths taes a tme the exat order of? 9

Pgeo-Hole Sortg: The Corret Aalyss for to s do whle U [] do T [] U [] U [] - Let a be the tme eeded for U[] eah tme roud the loop Let b be the tme tae by oe struto exeuto the loop for a gve, t U[]a U[]b, d: ostat tme eeded to talze ad otrol the outer loop the omplete tme s d t a d s a b Θ s

Example: Seleto Sort proedure selett [..] for to - do mj ; mx T [] for j to do f T [j] < mx the mj j mx T [j] T [mj] T [] T [] mx For eah, the strutos the er loop are exeuted - tmes b O j

Example: Iserto Sort proedure sertt [..] for to do x T []; j - whle j > ad x < T[j] do T[j] T[j] j j - T [j ] x For a gve the whle test s performed tmes the worst ase the barometer test s performed / tmes, whh s Θ j

Average-Case Aalyss should assume a pror prob. dstrbuto of the staes Example: serto sort T [..]: subarray of T [..], the partal ra of T []: the posto t would oupy f subarray T [..] were sorted f all! permutatos of T[..] are equally lely, the partal ra of T[] s equally lely to tae ay value [,] let be the partal ra of T [] the test s performed - tmes the avg. um the test s performed total avg. Σ

Solvg Reurrees: Itellget Guesswor T T f otherwse Restrt to beg eve? Restrt to beg power of? T 5 4 9 8 65 6 665 T 4 4 4 5 5 4 4 5 4

5 Itellget Guesswor Se, t follows that lg T lg - lg T lg - T Θ lg What happes f s ot a power of? Se T s a o-dereasg futo T Θ lg / T L a b b a lg lg Q

6 Homogeeous Reurrees a t a t - a t - lear homogeeous: equal to zero wth ostat oeffets f f - f - f - f - - f - ay lear ombato of solutos s tself a soluto f ad g satsfy a t a t - a t - ad set t f d g f a g a d g a g a g a d f a f a f a dg f a dg f a dg f a t a t a t a L L L L

The Charaterst Polyomal tellget guesswor suggests loog for solutos as t x a x a x - a x - a x a x - a the haraterst polyomal px a x a x - a p x x f x r s a soluto to the haraterst equato r haraterst equato r s a soluto to the reurree a lear t r ombatos r : roots of px satsfes the reurree for ay hoe of ostats,,, 7

8 Example: Fboa f - f - - f - haraterst polyomal x - x - roots geeral soluto f r r determe ad otherwse or f f f f 5 ad 5 r r 5 ad 5 r r f f

Example 4.7.. t - t - - 4t - haraterst polyomal x - x -4 x x - 4 roots t 5 t 4t r - ad r 4 geeral soluto t - 4 f f otherwse determe ad 4 5 t 4 ad 9

Whe Roots Are Not All Dstt a t a t - a t - has oly solutos of the form provded all r are dstt whe the roots are ot all dstt ths s o loger the most geeral soluto f the t r m m p x x r x r L x rl t l m j j r j m l

Example 4.7.. t 5t t - 5t - 8t - - 4t - haraterst polyomal x - 5x 8x - 4 x - x - roots - 8t 4t r, m, r, m geeral soluto t f,, or otherwse determe,, ad 4 8 -,, -/

Ihomogeeous Reurree The lear ombato s o loger zero Example 4.7.4: t - t - frst step: redue to the homogeeous ase multply by : t - 6t - replae by - t - - 6t - substrate from t - 5t - 6t - d step: get the geeral form x - 5x 6 x - x - t

Ihomogeeous Reurrees ot. rd step: determe ostats some equatos are obtaed from the tal odto some equatos are obtaed from the reurree tself o eed to solve all ostats substtute to >, therefore t Θ ad t t t t t t t

Example 4.7.5 t - t - 5 replae by - ad multply by -6-6t - t - -6 4 - replae by - ad multply by 9 9t - - 8t - 9 - t - 8t - t - - 8t - haraterst polyomal x - 8x x - 8 x - x - geeral-form soluto t solve ostats t 4 9 8 t t -9 Θ t 8 4t 99 4

Smple Ihomogeeous Reurrees a t a t - a t - b p b s a ostat p s a polyomal of degree d the haraterst polyomal a x a x - a x - b d Example 4.7.4: t - t - x - x - Example 4.7.5: t - t - 5 x - x - Example 4.7.6: t t - x - x - Example 4.7.7: t t - x - x - 5

Geeralzed Ihomogeeous Reurrees a t a t - a t - b p b p b p b are dstt ostats p are polyomals respetvely of degree d the haraterst polyomal a x a x - a x - b d x - b d x - b d Example 4.7.9 t t otherwse haraterst polyomal x - x - x - f 6

Chage of Varables T: the term of a geeral reurree t : the term of the ew reurree Example 4.7.. T T / Let t T f f s a power of, > t T T - t - t - t - har. polyomal: x -x - t whe, T t lg ad thus T lg lg lg lg T O lg? depeds o 7

8 Example 4.7. T l T/b > T: N R, l, b, ad are tegers s a strtly postve real whe / s a exat power of b T l T/b > > Θ Θ < Θ l b l b l b l T b f f log f log > Ο Ο < Ο l b l b l b l T b f f log f log

Rage Trasformato / f T T / otherwse let t T t T T - t - let u lg t u lg t lg t - u - u - u - har. polyomal: x - x - u substtuteto - - -, - t u -- T t lg -lg- /4 by the talzato odto: -lg 9

Asymptot Reurrees Whe reurrees our the aalyss of algorthms, we usually have to deal wth T 4T f f s the exat order of tal odto uow T s postve for all geeral tehque: to sadwh T betwee two reurrees defe a Ta, b 4Ta, b b f f > T a,b a b - b Θ regardless of the values of a ad b

To aheve our goal prove the exstee of four postve real ostats r, s, u ad v suh that T r,s T T u,v Kow T a,a a T, T a,b T a,b whe a a ad b b let ad d be postve real ostats ad let be a teger suffetly large that f d ad T 4T f for all > hoose rmt/t,, smr,, umaxt/t, ad vmaxu,d T r T, T r,r T r,s T u T, T u,u T u,v