[Music] hello and welcome to this lecture so this lecture is going to be all about continuous random variables in particular something called the probability density function okay so for the discrete random variable we had the probability mass function probability that you know the random discrete random variable takes a particular value and all that when you come to the continuous case it seems a bit odd that you know you can't have the pmf anymore pmf doesn't give it gives you just zero zero zero zero it doesn't make sense okay so you need something called the density okay so the continuous random variables are will take values over an interval they'll have a certain density over that interval but not for a particular value so it's sort of continuum in that case okay and there are a lot of continuous distributions very interesting distributions different defined by different density functions so this density function plays a very very crucial role makes the calculations very easy for continuous random variables i mean i'm saying very easy but i know it's a little bit more involved than discrete but it's it's uh it's density function uh sort of like the analog of the pmf in the continuous case okay so we'll see why that is true so you might wonder i mean already we saw the cdf why not use the cdf for everything it turns out the cdf is not that easy to deal with when you when you want to do calculations okay so the density on the other hand is a much much more intuitive and natural thing to use okay okay quick refresher on integration i think you you've probably learned integration in the math 2 course if you're doing it along with this or you've done it before or you have already some background on integration it's just a quick refresher so that we are on the same page okay usually one talks uh first of all before the integral before you come to integration you will be comfortable with differentiation this is derivative of a function which represents the slope of the function at a particular point or the its or its rate of change when you focus on a very small region around a particular point how fast is increasing or decreasing is captured by the derivative and there are formulae for derivative okay given a function given a description of that function what is its derivative there are tables which tell you how to do this etcetera etcetera okay now if you have a function small f okay and there is a capital f whose derivative is small f okay so notice the inversion here okay so usually given a function you differentiate you get the answer right now here here we're doing the reverse okay you have a function small f which function when differentiated will give you a small f okay so that is sort of called the indefinite integral of that function okay so roughly something like that uh it's of course i'm being very imprecise and loose here just to get you a rough idea of what it is okay so people usually write integral f of x dx for this and they'll write capital f of x like that so it's also called the anti-derivative or something like that okay so capital f of x and small f of x are related in that fashion now once you have an anti-derivative you can do something called a definite integral for your small f okay so this notation integral from a to b f of x dx is capital f of b minus capital f of a okay so this definite integral is density under the curve so a very usual picture very common picture is supposing you have a function f of x this is a function f of x and you go from a to b this area ok this area is given by this guy ok so integral a to b f of x d x is just notation notation for that area and that is given by f of b minus f of e okay so how do you find the antiderivative there are these tables of integrals you can go and look it up this is not the only table out there there are so many other tables so given a f x of a certain form you usually you know what the anti-derivative is okay and today many computer packages can calculate the anti-derivative the definite integral for you at least numerically to whatever extent is possible you can calculate the anti the definite integral okay so just a one page refresher so so that we are clear on notation and we will use this notation a lot you can see now already ah the capital f of b minus f of a that's like the cdf so the small f is something inside when you integrate you get the cdf so you can see where where we are going with this and where the density comes sort of naturally okay so this is a quick refresher on integration okay so now this leads us to the definition of what is called the probability density function okay if you have a continuous random variable x remember what's continuous random variable random variable whose cdf is continuous at every point right so that's the continuous random variable it is said to have a probability density function which is usually denoted small f okay the cdf is denoted with capital f probability density is denoted with small f okay if for every x naught okay the cdf evaluated at x naught should be the integral from minus infinity to x naught of the pdf okay so this is the idea so if you want i can draw a picture here ok so this picture became very ugly let me draw a picture here for you ok so so let's say you have a cdf here maybe i should draw the pdf so so you have a function which is like this let us say this is f of f x of x ok so now ah so what is so let us say this is x naught ok what is uh integral from minus infinity so you know minus infinity is something way way out there okay okay so integral from minus infinity to x naught of f x of x is what is the area under this curve all the way here this guy has to be equal to capital f x of x naught ok so this is what is happening so this right hand side is actually representing this integral so if x naught as x naught moves the integral will keep changing the value of the different integral the area under the curve that you are including will keep changing so you can see as x naught increases the area under the curve only increases right so it's a non non decreasing function it's an increasing function okay and this f x of x naught has to be between zero and one it has to be a probability it has to start at zero end at one so that puts some conditions on the density but but this is the meaning of the density okay if you can express the cdf as the integral as the indefinite integral from minus infinity to x naught of some other function then that function becomes the pdf of the probability density function of your continuous random variable okay so cdf is the integral of the pdf now what do i know from my basics of integration so the derivative of the cdf is going to be the pdf right so how do i get ah see when i do the integral the indefinite integral is going to be what right so so notice so this is important the derivative of the cdf is the pdf so if you want to integrate so if you have the pdf fx of x its antiderivative is capital f x of x isn't it right derivative of the cdf is usually the pdf this is directly taken as the pdf okay so you when you you differentiate this with respect to x you are going to get the pdf okay the anti derivative is this so when you do integral from minus infinity to x naught f x of x what do you what do you what will happen from your ah relationship of ah different integral it is going to be f x of x naught minus f x of minus infinity what is f x of minus infinity this is zero so you get your you get what you want right ok so this is what this is ah this is what you will get ok so if you can you know you so this is the standard way of getting the pdf okay the definition is sort of like done in ulta fashion but you know you have a cdf the cdf is given to you you simply differentiate it wherever you have the derivative take that as your pdf okay so in most cases you will have a derivative and just have to use the table differentiate the cdf you will get your pdf okay so for just to be technically connected correct i am defining it in this fashion but usually you just take the cdf differentiate it you get your pdf okay derivative of the cdf is the pdf it is a very good rule to remember okay so that's correct okay so why pdf people might ask we already i have a cdf i'm already confused i'm computing probabilities when you want to confuse me more well that's one of the reasons why we have all these definitions isn't it we can keep asking you more and more complicated questions confuse you about it no no no that's not the reason a pdf is really really useful uh what happens is whenever you want to have a measure of some distribution right so you have a distribution of the values and you are describing it with the cdf you know whatever function you used to describe if that function is high you want the probability of x taking a value there to be high right or if it is low then probability is low notice what happens in the cdf it keeps on increasing right and just because the cdf is higher it really doesn't mean that x takes more values there right only the difference uh matters okay uh it designed it's only between zero and one it's it's a different sort of definition on the other hand the density is not like that the way the density behaves you'll see soon enough if the density is higher then x takes more values around those points okay so i'll give you clearly clear calculations to show you how that is true so the density is sort of like a true er i mean if you see the density you sort of see the distribution okay if you see the cdf you're not quite seeing the distribution you're seeing how the probability increases and all that maybe some of you can visualize but it's not so easy on the other hand the density you'll see it's very very easy to visualize i'll show you some plots you'll see it makes a lot of sense okay so for instance uh the cdf will go and saturate at one okay so it's probably the highest value of the cdf but you know once it is saturated it never takes a value there okay x will never lie there right so it it it is confusing to deal with the cdf for that reason you you would want the function distribute some function that represents a distribution if x is never going to take a value that it should be 0 there right the pdf will satisfy that because if it's flat if you differentiate you're going to get 0 right so that's why the pdf is much more intuitive and easy to deal with and many complex calculations believe me when i tell you pdf is so much easier to deal with than cdf okay so that's why pdf is used in many many computations okay so it's not just to confuse you except for this integration and differentiation you need to be able to differentiate and some integration is involved when you calculate probabilities with pdf uh that is not there in cdf but it's it's it's okay you can get used to that and pdf is very very useful yes examples okay so examples always good uh the first these are all uniform distributions by the way later on we'll see what it is look at cdf one it starts at zero and then just flat line increases to one at five and then it's flat again okay so cdf is like that but notice what the pdf is okay i have to take differentiation right so if you differentiate constant flat thing when you differentiate you get zero and then this equation is actually so supposing you call this f x of x and this is x this is actually x by 5 isn't it at 5 it hits 1 at 0 it is 0. so this is x by 5 okay and this is 1 and this is 0. so when you do derivative zero is flat it keeps on being zero x by five the derivative is one by five okay oops so this is f x of x versus x okay so x by five the derivative is one by five and notice what happens after five it goes down to zero again okay why it's one flat and then constant is differentiation is zero right there's no slope here the slope is flat okay so notice how intuitive it is like the pdf right ah the random variable takes values only between zero and five the pdf is non-zero only in zero and five it is zero outside so the pdf goes to zero you know the random variable does not take values there okay so it's a very nice property simple property the pdf has looking at the pdf i can say that okay and it's one by five so so i know you know how the probability will work out so so so we know how to do probability calculations cdf you can also do probability calculations pdf file we will look at examples later you have to do integration its a little bit different but you can do that also we will see enough examples later ok so here is another cdf so here in this case what happened is so this point is 0.5 or half so this equation is 2x okay so this is 0 and this is 1 and this again is f x of x this is x and if you look at ah small f x of x versus x for the flat it is going to be flat at zero it is flat at one it is going to be flat at zero when you take derivative you get zero and then for 2x what is the derivative of 2x if you go look at your formula it will say the slope is 2 so derivative is just 2. so the pdf goes to 2 okay so it is 0 2 and then 0 again okay so let us contrast these two pictures okay so the distribution on the left the random variable takes values between zero and five sort of uniformly the pdf is flat the density is flat so we say it's uniform okay in the right hand side picture the random variable takes value only between 0 and half it's sort of concentrated so the density is higher okay so when the random variable takes a smaller range of values the density is higher one point where everybody gets confused is the density can go above one okay so this is the probability we are dealing with probability density it's not probability itself right so probability density can go above one also the cdf will never go above one right the cdf is always between zero and one the pdf on the other hand can go above one it's sort of like density density is what amount of probability per unit length okay so that's the way you think of density that's why it's called density right density is what weight per volume or something like that is density right so likewise here probability per unit length is your density so it can go up to two okay so when density goes to 2 your length cannot be great right your length goes only up to half right so 2 into half is 1 so you are still within the probability regime ok so density can go high if the range shortens up for you ok so this is a good picture to remember so notice how once again i would say the pdf is so much more intuitive just when you look at it you know where the values are right so wherever the pdf is high the values are going to be there right if it's flat then it's equally likely sort of uniform all over that place okay ah otherwise it's you know it's it's it can take differing values okay so that's a good picture of simple cdf pdf illustration uh the derivative is very easy and all that okay let's complicate things a little bit more here are two other distributions these are called exponential normal we'll come back and look at exact formulae for this but i just want to point out that you know in every case when the cdf is smooth also the pdf ends up being smooth it has a ah you know it has a nice behavior and it always wherever the pdf is high is where the values of the random variable will be okay so look at the top the left picture here top left and bottom left from the top left maybe it's difficult to figure out when people who know enough about functions will know that this function is growing faster near zero and it is slowing down its growth as it goes up to one it's difficult to see but look at the density the density immediately tells you the picture right so it's it's high around zero and it tapers off and falls very sharply as it goes higher so you know that this random variable tends to take values between 0 and 2 most of the time it is going to go above 2 and all probability is going to be lesser okay so the density indicates where the random variables probability per unit length where it is very high in all that ok so that's the sort of picture you should keep in mind uh the the right distribution is a very very famous distribution would have thought about the bell curve so to speak right so this is uh this is an example of that normal distribution we'll see later on what the formula are once again i will argue that the cdf uh probably doesn't quite tell you immediately where the random variable is going to lie but look at the pdf it just immediately brings out that you know most of the time the values may be around zero and then it can take other values and it's sort of symmetric right around zero so it can take positive negative values equally but uh look at the pdf on the left side like it's it's only going to be positive it's never going to be negative okay so all these nice uh quick things you can come up with the pdf and it's very very useful as well for doing calculations okay so hopefully you're convinced that the pdf is a good thing okay so it is a very good thing as we will see soon enough okay so what are the properties how do you identify a pdf what are the properties that the pdf has to satisfy okay uh so here's the definition of a density function you remember we had a definition for a distribution function right cumulative distribution function which functions are valid cdfs like that which functions are valid pdfs what what functions are valid densities okay here are the three properties okay the value the function has to be non-negative it has to be greater than or equal to zero why is that it's the derivative of an increasing function right it has to be non-negative so that's how it will be okay and anyway it's a probability density you cannot go negative okay so if you go negative somewhere over interval probability cannot go negative it has to be positive so it will be positive if you integrate from minus infinity to infinity you should get one okay so that's not very difficult to see why because integral from minus infinity to infinity of f of x if you write it in terms of the cdf it becomes f of infinity minus f of minus infinity that's one minus zero that's one right so that's one thing one way to think about it the other way to think about it is the total probability has to be one right you integrate out all possible values that x can take you should get one okay and f of x has to be what's called piecewise continuous it's sort of like a technical property it cannot uh you know it it has to have in every interval sort of it has to be continuous okay so it cannot do it can have jumps right pdf can have jumps it's not that it doesn't have to have jumps but it every piece of it has to be continuous okay that's all okay here are more important properties in fact the last property is probably the most important and let's let's come to that okay the first thing is about existence is if you come up with the density function so you remember if you come up with the cdf i told you that there is a random variable with that cdf same thing is true for density okay if you come up with a density function there is a continuous random variable whose density is that function okay so you can just so cooking up a continuous random variable is like cooking up a density function you come up with any density function that satisfies this non-negative integrates to one piecewise continuous you have a continuous random variable okay now there is something called the support of a random variable a continuous random variable particularly the support is basically the points at which the density is strictly greater than zero okay so those are the possible intervals where x can take values remember this is a continuous random variable i cannot say x equal to a particular value with nonzero probability but intervals where it falls the pdf has to be strictly positive so places where strictly positive is called support of the random variable i will use this support over and over again you will see for instance a very so this minus infinity infinity looks very ugly but you know i can write like this support of x f x of x will be equal to 1. so this is a definite integral over the support of x wherever f x of x is non-zero if it is 0 of course it does not contribute to the integral so so that's an easy thing to say i have this habit of dropping things like dx and all that but it's just extra fitting in some sense but anyway it's good to write it down ah integral over the support f x of x d x is equal to one okay now come to the last point i put it as the last point it's very very that's the most crucial point okay if you have an event a defined using the random variable what how do you define events with a random variable you say x is less than or equal to something x is greater than something x is between something x is between this or x is between that okay things like that how do you find probabilities of those events using the pdf we know what to do for cdf what do you do for pdf you simply integrate the pdf over those intervals find the area under the curve over the intervals that you are interested in and that gives you the probability of that particular event okay so this is how we use the pdf directly to calculate probabilities ok so this last property is very important we will see a few examples that will be clear to you now there you go immediately we jump into examples i believe there is two or three examples before we jump into common distributions i will just do the three examples and we'll stop this lecture at that point okay so here is the function for you okay this function is three times x squared between zero and one and it is zero otherwise okay so first thing is you have to show f is a valid density function so what are the valid density function conditions f of x is greater than or equal to zero that is true okay integral minus infinity to infinity but you know it's just 0 to 1 3 x square dx okay what is the antiderivative of this what when differentiated will give you 3 x squared x cubed isn't it so it is x cubed right evaluated at 0 and 1 right so this is this is how people write it x cube evaluated 1 minus x cube at 0 so that's 1 okay and is it piecewise continuous yeah it is continuous it's usually a easy thing to check so it's a valid density function no problem so let us consider a random variable x with this density okay what's the probability that x equals 1 by 5 okay so this is the easiest thing to answer right so any random variable which has a pdf or defined using the pdf is definitely a continuous random variable and once you have a continuous random variable probability that it takes equal to one by five is actually zero what's the probability it takes two by five again zero okay it's all easy questions now what is the next thing this question is a bit interesting so what is the probability so maybe we should sketch this f of x right so let's sketch this it looks like this oops what did i do it looks like this from 0 to 1 it is 3 x squared at 1 it becomes 3 ok and 3 x squared will go something like this oops what happen it will go something like this okay it's a curve it will be like a parabola it will go like this this is your f of x okay now one by five is somewhere here two by five is somewhere here ok so at one by five and two by five ah so so if you look at f of one by five it is three times three by twenty five f of 2 by 5 is 3 times 4 is 12 by 25 okay so the density at 2 by 5 is 4 times the density at 1 by 5 okay so what i am doing here is asking for the probability that x lies within one by five minus epsilon and one by five plus epsilon some think of epsilon as something small ok notice the density at one by five is around three by twenty five at two by five is around twelve by twenty five but to compute this probability what do i need to do i have to integrate three x square ok so remember that i have to integrate between one by five minus epsilon and one by five plus epsilon my density ok and that is x cubed evaluated between one by five minus epsilon one by five plus epsilon ok and that if you do this you will get one by five plus epsilon whole cubed minus 1 by 5 minus epsilon the whole cube you can do this calculation you will get what i don't know so i hope i am right here 6 by 25 epsilon and then i would get plus 2 epsilon cubed okay so this is the i think it's the correct answer so you get 6 by 25 times epsilon plus 2 epsilon cubes let me just make sure i get that right 3 by 25 epsilon minus 3 by 25 so the other one get cancelled and this yeah i think this is correct so you get this value so you see if if you think of epsilon as something very very small this guy is probably much much smaller than epsilon so you can sort of ignore this term it's it's going to be think of point zero one right so if epsilon is point zero one this term is of the order of point zero one something this one is point zero and part three okay so it's just it's gone point zero zero zero zero zero so it just becomes very small okay so this guy maybe you can sort of not worry about so this is roughly about six by 25 epsilon the probability that x lies within a small interval of 1 by 5 is 6 by 25 times epsilon so notice at 2 by 5 the density is higher okay at 2 by 5 density is higher than at 1 by 5. so the probability that x lies within that same two epsilon interval around two by five better be a little bit higher right so is it higher let us check that so probability that two by five minus epsilon less than x less than one by 5 plus sorry 2 by 5 plus epsilon it's going to be integral the same thing again so let me cut that short it's going to be 2 by 5 plus epsilon whole cube minus 1 by 5 minus epsilon the whole cube so that's going to be 6 times so sorry this is 2 by 5 6 times 4 that's 24 by 25 epsilon plus 2 epsilon cubed once again maybe this one is much much smaller than epsilon for small values epsilon and you can see that this is four times okay and good enough i mean we saw that the you know the pdf itself is four times around two by five so now this epsilon you'll be slightly careful about i mean this is not exactly like you know what two by five at one by five four times four times yes sort of like that but to get that exact probability you'll have to account for the every possible value that comes okay i mean to get the exact probability you will have to do ah indefinite integral find the derivative anti-derivative substitute the values and subtract another okay but but you know i want to bring out this point that this pdf actually represents the probability that x takes values around that point and when the pdf is higher it is true that x takes values around that point with a higher probability than a comparatively lower point okay but this kind of trick is very important this skill is very important given a particular function identify whether it is valid pdf or not and then compute probabilities for events involving that random variable as integration this integration will come in and you should be comfortable with that we'll use simple functions mostly in this course and even otherwise in practice there is no need to be worried about integration in practice you always have tables and wikipedia to help you and all that so you can find integration without too much of a problem okay so here's another problem something very very similar just for you to get comfortable this is 2x so you once again if you want if you like sketches you can sketch it so this is the density remember 0 to 1 it goes up to 2 and stays sorry it does not stay there remember this density it can't stay there it comes down to zero so this is how the density is and this is you can calculate the area under this curve it's half into base into height so that's one right so it's a valid density okay so what's the probability that x is between point one and point three ah so remember point one and point three somewhere here the densities are like that so how do you do this so this probability probability that x is between this is s less than or equal to does not really matter point one to point three of two x d x the anti-derivative is x squared okay x squared between point three and point one point zero nine minus point zero one point zero eight right okay so you can calculate the others all of them in the same way you know just confusing you with you know open here closed here open there close there etcetera you get the same answer so so just for comparison supposing you look at see this is an interval of length point two right so let us say we look at the same point eight and one ok so same interval but situated at 0.1 so this you will get as you know 1 squared minus 0.8 squared so that is 0.36 so notice how much higher this probability is compared to that probability okay so that would uh work out in that fashion so so i'll leave the remaining things as exercise for you so being able to integrate calculate the difference of you know the the anti-derivative substitute etcetera that's very very important you can also find the cdf right so the cdf you can see so what will be the cdf here the cdf if you do the cdf ah it will start at 0 and go at 1 and then it will be x square ok so this is two and then it will sorry one ok but it will be x square ok so this function will be x squared and start at zero and end at one at one it will go flat okay so this is how it will be so notice how the cdf and the pdf you know this is the antiderivative becomes the cdf and notice how the cdf doesn't truly tell you you know how the probability is going to behave and the pdf is telling you exactly how the probability behaves so let me close with another simple type of problem this is again a very typical problem given a function like this there is this parameter k which is not specified in the problem and you have to find a k to make it a valid density function first thing you check is k has to be non-negative and it lies between 0 and 1 by 4 k it's 2 by 2 k 3 k etcetera so if you want you can sketch it zero one by four three by four and one it goes to k here and then two k here and then three k here right so this is this is the function ok so here the only thing to use is that the entire pdf the area under the curve the entire integral has to be 1. so if you look at the integral 0 to 1 in this case right so takes that takes the value there f x d x has to be equal to 1. so now 0 to 1 it splits into 3 different intervals so you have to split it like that 1 by 4 k d x plus integral 1 by 4 to 3 by 4 2 k d x plus integral 3 by 4 to 1 3 k d x so this is something you can do right this function f of x if you write zero to one you have to write zero to one by four f of x d x plus zero one by four to three by four f of x d x three by four to one by three three by four to one uh f of x d x now f of x from zero to 1 by 4 is k 1 by 4 to 3 by 4 is 2 k 3 by 4 to 1 is 3 k okay now remember k is a constant ok so you just have to multiply by x and then x takes values 1 by 4 to 0. so this is just 1 by 4 k plus this is half right so 2 k times half plus 3 k times 1 by 4 has to be equal to 1 you can solve for k so let me see k by 4 plus 3 k by 4 is k with another k so you get k equals 1 by 2 okay i hope that's correct it's k plus k 2 k k is half okay so you just solve for k so this is also a typical example so it's got to identify got to help you identify which is a valid pdf so one value of k gives you a valid pdf here okay so once again if you look at this problem for instance whereas which is the you know if you fix a small epsilon interval uh which is the area where it takes higher uh probability it's between three by four to one isn't it that's the place with the maximum pdf you can draw the cdf corresponding to this uh it will be continuously very sort of straight line three straight lines leading up to one okay all right so this is ah the definition of the density function once again the density function is probability sort of probability per unit length for small lens it can vary over the length itself so you have to integrate to find the actual probability that's very important pdf is the derivative of the cdf that's a good way to remember it that's how you find the pdf you can go back and forth by doing the differentiation and integration okay so thank you very much in the next lecture we will start looking at common distributions and common continuous distribution look at the pdf cdf exit thank you