[Music] [Music] [Applause] [Music] [Applause] [Music] dear students in the last lecture we have seen probability distributions in this lecture with the help of Python we solve some problems from probability distributions the problem is taken from a book written by Ken Black the title of the book is applied statistics so we will see the problems now okay now I am importing si by importing numpy SNP from sci-fi Syfy dot stats import by num Bynum is for doing binomial operations and one more thing you can import picture also for example this picture that is that empirical distribution picture I have taken from this source that is exclamation symbol square bracket that link and that link should be in square bracket then you will when you do that link we can get that picture directly okay I am executing this yes now we will see the problem a survey found that sixty five percentage of all financial consumers were very satisfied with their primary financial institution suppose that 25 financial consumers are sampled and if the survey result still hold the true today what is the probability that exactly 90 are very satisfied with their primary finance institutions by looking at the problem we have to see what kind of distribution we are going to use here there are two possibilities satisfied or not satisfied so there are two possibilities there so then we can go for binomial distributions okay print by NAMM dot P PMF probability mass function k equal to 19 that is V Z in the probability distribution current context X n equal to number of sample P is probability of success now we can see that the answer is 0. 09 so there is an O point 0 9 the probability that exactly nine are satisfied with a primary financial institutions you go to the next problem this Booker this problem also taken from that book according to US Census Bureau approximately six percentage of all workers in Jackson Mississippi are unemployed in conducting a random telephone survey in Jackson what is the probability of getting two or fewer unemployed workers in a sample of 20 here we want to know two are less so Z the probability of 0 plus probability of 1 plus probability of 2 so we were to do the cumulative density function so here for doing that one you have to enter type Bynum dot CDF 2 xx 0 point 6 the two represents less than or equal to 220 represents the sample the P represents the probability so when you run this you are getting community probability of 80 8. 5% age we'll take another problem solve the binomial probability n equal to 20 sample size is 20 P equal to 0.
4 X equal to 10 so by num dot PMF you'll get the answer for 0. 1 1 7 well go to the next distribution poisson distribution so in the Poisson distribution for doing Poisson distribution you have to import the library Poisson distribution from Sify dot stats import poison first we will find out Poisson probability mass function so Python dot PMF 3 comma 2 3 represents the X to represent the mean we'll see another problem suppose Bank customers are a randomly any weekday afternoon at an average of 3. 2 customers every 4 minutes what is the probability of exactly 5 customers arriving in a four-minute interval on a weekday afternoon by looking at the problem you say that we know that the arrival pattern follow Poisson distribution and you have to be very careful on the unit of mean and the unit of X both are in four minutes then no problems they simply can PI Sun dot PMF is five five is your x value 500 PMF so 3.
2 is the arrival rate so five comma three point that is the eleven point three nine percent age you'll see one more problem Bank customers arrive randomly and weekday afternoon at an average of 3. 2 customers every four minutes what is the probability of having more than seven customers in you four minute interval Anya big day afternoon so here we have to find out the probability of X greater than seven okay so what we'll do first we will find up to seven with the help of this world that we will save any object krob equal to pi sun dot CD of seven and lambda three point two so when you subtract one minus of this one then we will get probability of more than that yes so I am finding up to seven when you substrate one minus that up to seven he will get to more than seven okay we will see another problem on Pais on a bank has an average random arrival rate of three point two customers every four minutes what is the probability of getting exactly ten customers during eight minutes interval now it should be very careful here the unit of X and unit of lambda are different because it's a four minutes it is eight minutes so you have to convert into same units so multiply by three point two by two you will get six point four so lambda equal to ten so 500 PM of ten comma six point four will give you the answer four point zero five to seven we'll go to uniform distribution next suppose the amount of time it takes you see that the amount of time it takes to assembly a plastic module ranges from 27 to 39 seconds and the assembly time are uniformly distributed describe the distribution what is the probability that a given assembly will take between 30 to 35 first we will develop that array so here u equal to NP dot a range there are two function 1 is range another one is a range a range means its array array function if you type if you type simply range that is a list so 27 is the starting value say 40 because it is n minus 1 40 not 40 39 will be the last value in the diary in the increment is by 1 we got this one now this is our uniform distribution okay now from scipy dot start import uniform so we will find out the mean of this distribution so for that purpose uniform dot mean elbow see is the starting point 27 scale is how much plus 12 so it is a 27 plus 12 is 39 so that is a syntax for so the mean is 33 otherwise in the uniform distribution finding the mean is not a very complicated formula simply you have to find out the a plus B by 2 okay then we'll do the cumulative distribution CDF cumulative function so uniform dot CDF n P dot a arrange 30 what the question was asked is 30 to 35 okay so in P dot array 30 because it is a 35 you have to go out to 36 the increment is 1 starting starting point is 27 this scale is 12 so this will give you the probability between 30 to 35 so when you run this so the probability of 30 is 0. 25 31 is 0.
33 32 is 0. 4 1 and so on suppose we want between 30 and 35 for 30 the probability is 0. 25 for 35 it is 0.
6 so if you substrate 0. 66 minus 0. 25 you will get the and so far that probability that the given assembly will take between 30 to 35 seconds okay you'll see one more problem according to the National Association of Insurance Commissioners the average annual cost of automobile insurance in the United States in a recent year was 691 dollar suppose the automobile insurance cost are uniformly distributed in the United States with an average of from $200 to 1182 dollar what is the standard deviation of this Vinnie form distribution so we have to find out standard deviation of this distribution before that will check the mean the mean is given 691 dollar so we'll verify this uniform dot mean elbow see starting point is 200 the difference is the scale is 982 that is 1182 - mm sorry $200 this is 1 so it is the extra 691 dollar if you want to know the standard deviation of the uniform distribution because this formula is different it is not simple standard deviation so uniform dot STD elmo's a 200 comma scale is 982 you'll get the standard deviation of 280 three point four seven okay next we will move to the normal distribution here also I have inserted a picture of normal distribution you see that I the picture is taken from this link actual exclamation Square break here that link okay okay when you execute this you will get here picture of probability distribution that picture first we will have to import a library norm that is imported from Sify so from Sify dot starts import now that is the value mean comma standard deviation sixty eight sixty point five two point five suppose if X equal to sixty eight the mean of that normal distribution is sixty five point five standard deviation is two point five what does the problem so we'll run that first you have to run this also yes the probability is 0.
8 for 1/3 if you want to X less than that value suppose if you want to know cumulative distribution of X greater than value you have to substrate from 1 suppose if we want to move the value 68 and double so already known we know up to 68 to this much value so the remaining area is because we know the area of the normal normal distribution is 1 so 1 minus remaining that value will give you the right side area suppose if you want to know the value between X 1 and X 2 for example value 1 less than or equal to X less than or equal to value 2 so it's a very simple printout NAM dot CDF you'll find out the upper limit and the lower menu type the lower limit because the value ms already I have declared now suppose the between 68 and 63 X values 60 863 if we want to know the area that it plays a very simple reason to receive a lot of our time suppose what is the probability of obtaining a score greater than 700 on your GMAT test that has mean 494 and standard deviation of hundred assume GMAT score are normally distributed there is another example what is the probability of X greater than 700 when mean equal to 494 and standard deviation is 100 so because we want to know X greater than equal to 700 so we have to find out X equal to 700 then subtract from 1 so print 1 minus norm dot CDF surrendered the 494 come a hundred will give you the answer for what is the probability that randomly drawing his core the 550 or less so we have to need X value less than or equal to 550 so 515 comma 494 come on hundred will be the answer what is the probability of randomly obtaining a score between 300 to 600 the GMAT examination actually this problem is taken from statistics for management Levin and Reuben okay now you see that the upper limit is 600 lower limit is 300 between 600 and 300 what is the probability so print norm dot CDF 600 comma 494 common 100 - this was upper limit - norm dot CD of 300 - 4 94 come 100 is the lower limit what is the probability of getting a score between 350 and 450 on the same GMAT exam okay 450 350 there is another example what is similar to previous one into this one now we are going to do the reverse of that now if they're so far be able to find the CDF cumulative probability now suppose the area is given if the area is given we want to know the x value if it is a standard normal distribution we want to know the z value because the default function a is the standard normal distribution where the mean equal to zero standard deviation 1 so area under point 9 file the corresponding Z value is 1. 645 this value you can read it from the table the same way which I have explained in the in my Theory lecture suppose if you want to know most importantly here norm dot PPF that is a probability function so now I'm not PPF 1 minus 0. 67 7/2 will give you the the left side area so we will see what is the corresponding let's say it is Z value is yeah here we are going in the left hand side so the Z value is minus 0.
45 9 now we will see an example of hyper geometric distribution the example says suppose 18 major computer companies operate in the United States and that Tola are located in California's Silicon Valley if three computer companies are selected randomly from their entire list what is the probability that one or more of the selected companies are located in the Silicon Valley what things you have to notice here is one are so for that means we have to see what is the probability of getting one or more selected companies so from Sify dot stats import hyperjump p value equal to hyper john dot s of s of means survival function so here if it is one or more means that one minus 1 so 0 0 comma 18 represents the population size 3 means we are three we're switch choosing that is the number of sample 312 means the number of success in the population that is a capital e the same notation what you are used in our theory so here the p value is point nine seven five four we'll see another example a western city has 18 police officers eligible for promotion 11 of 18 are hispanic suppose only five of the police officers are chosen for promotion if the officer chosen for promotion had been selected by chance alone what is the probability that one or fewer of the five promote promoter officers would have been his money so what we need to know here one are fewer so here we have to find out the cumulative probability so the formula for finding the cumulative probability for a hyper geometric function is the p-value I am going to save in the name of P value equal to hyperjump dot CDF one so 18 depresses the population size 5 represents because choosing 511 represents the number of success in the population so when you run this getting point 0 4 7 3 8 now we will go for next example on exponential distribution we will take a sample problem a manufacturing firm has involved in statistical quality control for several years as part of the production process parts are randomly selected and tested from the records of these tests it has been established that the defective part occur in a pattern that is a Poisson distributed on the average of one point three eight defects every 20 minutes story children's use the information to determine the probability of less than 15 minutes will elapse between any two defects here how to look at the two things in this problem one is the mean of your Poisson distributions given mu and second thing is the between any two defects now when as I told you in that Lanthier itself whenever the between two things you have to go for exponential distribution now first we do find the mean mean of your exponential distribution so the mean of your exponential distribution is 1 by a mean of the Poisson distribution so here is our knitted distribution mean is one point three eight so the lambda we can call it as mu one that is me one is for the mean of here exponential distribution mu 1 equal to 1 to two by one point three eight okay so that value is this much okay suppose what was asked probability that is less than 15 minutes from Sify we have to import exponential function so we have to find out the cumulative probability further to exponent dot CD F so the 0. 75 represents because we got 0. 75 by dividing 15 to 2 by 20 because that is the mean was in the Poisson distribution mean was for 20 minutes now the problem for the exponential issue is asked for 15 minutes so we are dividing 15 by 20 so that the units are matching so we need to find out the cumulative function of exponential distribution the lower limit of that x is 0 the upper limit is 0.
75 so exponent our CDF upper limit 0. 75 comma lower limit and the lambda value so you will get the 0.