Report

MAT 4830 Mathematical Modeling Section 1.4 Conditional Statements http://myhome.spu.edu/lauw Preview Review Binomial Distribution Introduce the first type of repetition statements – the for loop Allow a specific section of code to be executed a number of times Introduces simple arrays Example 0 Suppose that there are devices, each with a probability of failure during a given time period. What is the probability that exactly fail during this time period? n devices F P( failure) p Example 0 Suppose that there are devices, each with a probability of failure during a given time period. What is the probability that exactly fail during this time period? n devices F F k devices fail F P( failure) p Example 0 r.v. =no. of devices fail P( X k ) ? n devices F F k devices fail F P( failure) p P( X k ) ? Example 0 n devices n k devices k devices F F F P( X k ) ? Example 0 n devices n k devices k devices F F p k F (1 p) n k n k Example 0 n devices n k devices k devices F F F n k nk P( X k ) p (1 p) k Binomial Distribution B(n,p) X B ( n, p ) n k Prob. Mass Fun. f (k ) P( X k ) p (1 p) n k , k 0,1,..., n k n x Alternatively, f ( x) P( X x) p (1 p) n x , x 0,1,..., n x Mean EX np Std. D. np(1 p) Binomial Distribution B(n,p) X B ( n, p ) n k Prob. Mass Fun. f (k ) P( X k ) p (1 p) n k , k 0,1,..., n k n x Alternatively, f ( x) P( X x) p (1 p) n x , x 0,1,..., n x Mean EX np Std. D. np(1 p) Binomial Distribution B(n,p) X B ( n, p ) n k Prob. Mass Fun. f (k ) P( X k ) p (1 p) n k , k 0,1,..., n k n x Alternatively, f ( x) P( X x) p (1 p) n x , x 0,1,..., n x Mean EX np Std. D. np(1 p) Team HW #1 Team Homework #1 Use the definition of expected value and the binomial theorem n k nk ( a b) a b k 0 k n n Do not use the moment generating function. You may need to recall how to shift indices in a summation (see the hidden slides below for review). Team Homework #2 A campaign staff knows from experience that only one in every three volunteers called will actually show up to distribute leaflets. Team Homework #2 How many phone calls must be made to guarantee at least 20 workers with a confidence of 90%? Team Homework #2 Minimum How many phone calls must be made to guarantee at least 20 workers with a confidence of 90%? P(at least 20 workers) 0.9 Team Homework #2 Use a binomial model to solve the problem. You need to write a Maple program to help you solve the problem. You need to explain your methodologies, arguments, and conclusions carefully. Extra works are welcome – In the past, students had done more than they were asked to get bonus points. Zeng Section 1.4 Introduce the first type of repetition statements – the for loop Allow a specific section of code to be executed/repeated a number of times Introduces simple arrays Zeng Section 1.4 Please listen to the explanations before you type in the program. It takes one minute to explain. Example 1 Print the square of the first 10 positive integers What is the task being repeated? Example 1 >sq:=proc() local i; for i from 1 to 10 do print(i^2); od; end: #program to print the square #of the 1st 10 positive #integers #index #A loop to print the integers #output i^2 Example 1 >sq:=proc() #program to print the square #of the 1st 10 positive #integers #index local i; for i from 1 to 10 do print(i^2); od; end: i i i 2 #A loop to print the integers #output i^2 1 1 2 4 10 100 Example 1 >sq:=proc() local i; for i from 1 to 10 do print(i^2); od; end: #program to print the square #of the 1st 10 positive #integers #index #A loop to print the integers #output i^2 > sq(); 1 4 9 Structure of the for loop for loop_index from start_value to end_value do block of statements to be repeated od; Structure of the for loop for loop_index from start_value to end_value do block of statements to be repeated od; The loop_index increase by the default step size 1 everytime the execution of block of statements to be repeated is finished. Different step size can be used by adding “by stepsize” feature. Example 2 Print the square of the first 10 positive odd integers Example 2 Example 2 > sq2(); 1 9 25 Example 3 Print the square of the first positive integers Example 3 Print the square of the first positive integers Introduces array and seq Note that these commands are not necessary here Example 3 Example 3 x[1] x[2] x[3] x[n] Example 3 > sq3(2); 1, 4 > sq3(5); 1, 4, 9, 16, 25 Example 4 Fibonacci sequence is defined by F0 0, F1 1, Fk Fk 1 Fk 2 for k 2,3, {0, 1, 1, 2, 3, 5, } Example 4 F0 0, F1 1, Fk Fk 1 Fk 2 Write a program that generate the first + 1 terms of the Fibonacci sequence 0, 1, … , Example 4 Why there is no print statement? F0 0, F1 1, Fk Fk 1 Fk 2 Example 4 F0 0, F1 1, Fk Fk 1 Fk 2 Example 5 (1) 2 k 1 sin x x k 0 (2k 1)! k (1) 2 k 1 x k 0 (2k 1)! n k Write a program, for the input of and , to approximate the value of sin() by the first sum of the first + 1 terms in the Taylor series. Example 5 (1) 2 k 1 sin x x k 0 (2k 1)! k (1) 2 k 1 x k 0 (2k 1)! n k This is to demonstrate the basic form of “accumulation”. (1) k 2 k 1 sin x x k 0 (2 k 1)! n Example 5 (1) k 2 k 1 sin x x k 0 (2 k 1)! n Example 5 (1) k 2 k 1 sin x x k 0 (2 k 1)! n Example 5 Homework See course webpage Read • 1.3 All HW due next Monday Attempt your HW ASAP Individual HW**