So it's my turn to tell you about something new in JavaScript land or in the web land, actually. And I have a proposal. I had restarted, by the way. I thought so. Oh, sorry. I didn't realize that you were still just like, oh my. Just start soon. So. So. We're trying this once more. Another episode. I love the side there. Here we are again. I'm having a talk to Jake. And this time, I have to present something.  This is YouTube. You know, people don't watch anything for more than five minutes, unless you're like, oh my god, this is the most amazing thing that's ever happened to JavaScript. This is going to be incredible. You know, you're going to learn so much in this episode.  It's just this is going to be the best part of your day. If not, isn't it how you die?  I think the idea is the skull would have to also inflate. Oh.  Yes. So now we need to put a disclaimer on the show. Might make your skull grow if you watch too much of this. It's like. That's the new tagline for the show. HTTP 203 might break your skull. Great. So I found a new JavaScript thing that intrigued me, mostly in my role as the the maintainer of Comlink, where, you know, values in workers and main thread that pretend to be in both places, but they're actually not.  There's being references being held. And so I have learned more about this new proposal that is now shipped to Chrome Stable, which is weak reps. And I thought, you know what? Let's make a little episode about all this weak stuff that JavaScript has anyway. Oh, so we're not just covering weak references. This is going to be the. Well, we have a short intro bit about what's been there so far and why it is the way it is because there are some weird rough edges. Well, stop teasing me and just give me the information. Let's do it, shall we? OK, so I thought we start with what actually is a weak reference because it's been thrown around a lot and just want to make sure everybody knows what we're talking about. Really, what it means is whenever you have an object and you save quote unquote, say it's an object variable, that variable is a strong reference to that object. And as long as there's any variable in your code that, you know, has this object, this object will not get garbage collected because that would be bad if the stuff you have in variables suddenly disappeared.  So if there was a way to have a variable being a weak reference to an object, if there is no references to an object or only weak references, basically no strong references, that object is free to get garbage collected at any point in time and you might see your value actually disappear. OK, so a weak reference is kind of like if your weak reference is actually pointing to the object, then that's your way of you kind of know there's probably something else that's using this right now. Maybe.  That's pretty much as much you can deduce from that. And there's already one little difference that you mentioned there because just because you give up all strong references to an object doesn't necessarily imply that it will be immediately garbage collected. So a weak reference could theoretically still give you an object even though there is no strong references to it anymore. And that's a detail that we're going to get more into a little bit later because it's an important distinction to make. It was, I heard that because I'm glad you're doing this talk because I did read the article on weak references and I came away still being quite confused. And it was some of the uncertainty that was a bit like, I don't know, this uncertainty sounds bad. So we're going to have a lot of that because basically we have had two weak data types in JavaScript for actually quite a while. And those are the weak map and the weak set. And some might be surprised that these are fairly old. They were in IE 11. So they've been around for a long time. And what these two do is basically in the weak map, the key is weak, meaning you can only get to the value when you have the key. But the key itself is not prevented from being garbage collected just by the fact that it's being used in the map. So if you use a DOM node as the key in the weak map and don't save this DOM node anywhere else, if it gets garbage collected, your key and your value can disappear from that map. And that can be incredibly helpful. I often get to see questions on Twitter, sometimes directed at me, sometimes at others, what the use cases for weak map and weak set are. And so one of the primary uses for me is that for the longest time in JavaScript, expandos, as they're called, have been fairly common. You just take an object and you throw new properties on it. Like you put just an underscore my stuff and put your stuff in there. And that's JavaScript. It works. But one of the downsides is that it's bad etiquette, basically, to transform objects that you don't own, also because that can cause the JavaScript runtime to de-optimize because you're changing the shape, as it called, of an object. And so generated binary code might not work anymore. And they would have to regenerate it. And so mutating objects you don't own is often a bad practice. And there's an ownership issue here as well, isn't there? Because now anything else that gets that profile node can see that internal data. Yeah, because it's not really private. And you can never be 100% sure that you're not creating a name clash. Maybe in this case, some library code actually does use underscore internal. Who knows? And so what you should be doing instead is you create a week map. So in this case, we're getting something from the DOM. And instead of putting something on the DOM node itself, we use the DOM node as a key in our week map and put our extra data into the value of the week map. And that means as long as the DOM node exists, the value will continue to exist. But when the DOM node gets garbage collected, so will the value. And that's really useful. And for a week set, it's basically for the use case. Whenever you find yourself doing a week map where you store true in the value, that's like my prime example, where you just want to remember, have you visited a certain object? Have you already seen it? Has it already been processed? Those kind of things, that's where a week set comes in. However, and that is something that trips some people up or raises question marks, at least, is that neither of these are iterable. You cannot iterate over the keys in the week map. You cannot iterate over the entries in a week set. Weak stuff in general was never iterable. And that kind of comes from the fact that one of the fundamental principles, I think by the W3C was, you should never expose garbage collection. And the reason for it is actually from security. Because exposing garbage collection is what I learned when I researched this, is called a covert channel. Because now two pieces of JavaScript can communicate without ever knowing really of each other's existence. You can think about it a little bit that if you bundle two libraries and you pass just an object from one library to another, now the one library might be able to track when the other library stops using that. And that could actually, if those two libraries do it in coordination, you can communicate a lot through that without ever accessing each other's data. And that's, I mean, if you think about cookies, that's how tracking happens. And I think something like this could be exploited the same way. And so they never wanted to open this can of worms, basically. However, over time, there were more and more demands and use cases for actual weak references and exposing garbage collection. And so over time, they spent a lot of design work and collaboration between the engine authors to figure out how they can make this happen without making this covert channel an actual problem. And so the weak rest proposal was born. Before we move on to that, like one of the, like this model with weak sets and weak references where you can't iterate on the keys, that in some ways, it almost makes more sense to me because like it's that idea of like, you can only open the door with a key, right? And if you lose the key, you can no longer open the door. The equivalents here with like, because we don't just have weak map and weak set, there's also map and set, which can iterate. And that seems like a kind of model where I've lost my keys. I better go and ask the door for them back, you know? Which? Fair. It would be problematic in general, wouldn't it? So. Yeah, let's not let real doors be inspired by computer science in maps that, no, I don't think that's a good idea. So yeah, so this is where we now can talk about WeGraph. This is marked as advanced because it can be fairly hard to reason about the second garbage collection is involved. It becomes undeterministic, unpredictable, but also because whenever you use it, think really, really hard. If there isn't a way you can solve the problem without it because this will be likely to introduce more bugs than it fixes because it is a fairly hand wavy spec almost. And we'll talk about that a bit more. Well, when the garbage collection happens, isn't spec at all. Isn't spec. And that's one of the underlying problems for this entire thing.  Like, the spec doesn't say they must. We'll get to that because that is actually, basically we have WeGraphs now. And in the end, they do violate a principle of exposing garbage collection. They do create that covert channel, but they did spend a lot of time in the design to make sure that on the one hand, engines are still able to optimize and iterate on their internal architecture freely without being constrained by this WeGraph existing and also to limit the bandwidth of this covert channel to such an extent that the risks are extremely low to that actually being a real problem. What are these actual problems? Why is this actually such an quote unquote advanced topic? Well, the first problem is that garbage collection is non-obvious or non-deterministic. For example, if two values become unreachable at the same time, like you give up your strong references at the same time, that does not mean they will get garbage collected at the same time. Or, and that is also something that you might notice, like it might look like you made something unreachable, but it is in fact not because the way that internal data structures work or they like a native data structures to JavaScript or closures, there might still be a reference you're just not aware of. And so your reasoning might just be flawed and really hard to figure out where it is going wrong. Engines will garbage collect differently from each other. So something that might work in one browser or when something gets garbage collected in one browser, it might not in another. It actually might get garbage collected in one previous release of your browser, but not in the current one. Or it might get actually garbage in the first run, but not in the second run of the same code on the same website because there's so many factors that the engine incorporates when to run garbage collection that it is inherently unpredictable. And this is what I brought up earlier. Garbage collection and something being unreachable are inherently separate things. Something being unreachable is a requirement for getting garbage collected, but they basically can be an arbitrary and infinitely long time in between. Most browsers run their garbage collector when they feel like the browser has downtime and only when it's under memory pressure.  And so that's just something to really keep in mind also for the rest of the discussion that when we talk about garbage collection, we mean the moment in time when a value is being deleted from memory and the memory is being freed up, not the point where it's becoming unreachable for your code. Yeah, it's an optimization pass. Like garbage collection is optimization. It was weird when I heard that, yeah, browsers aren't required to garbage collect or JavaScript engines aren't required to garbage collect because it's like, but all the code everywhere would break if they didn't garbage collect. It's like, well, yeah, but never mind. It is something they all do. It's just when they do it and how they do it is completely unspecified. Yeah, and just to give it a separate point, it GC will happen late or sometimes all that can happen. And actually there is a little detail to this that this, well, I will talk about a bit later. All right, let's look at the actual week ref API. It is a very, very tiny slim API, which is nice.  Things like numbers, strings, the primitives don't get garbage collected and just put it in a week ref and now you have a week ref to the value. Wait, no, wait, wait, wait, wait, I'm confused. No, no, no, no, no, no, no. Okay, strings do get garbage collected, right?  I think the difference is that you can recreate that exact string later. Whereas you can't, once you lose access to an object, you can't recreate that exact object again. It would be a different instance of that object. I'm not 100% sure on strings. Now you say that. I think strings are special in that they're not objects and that two strings you create separately will be considered identical. And I think strings are shared in like a string pool because of this identity, reference identity that they have. And so I think they will probably be removed from that pool, especially large strings, but I think that's not considered garbage collection. I'm not sure on this one. So we'll probably add something in the notes of this video. Pretty sure you cannot create a weak ref to a string. Yeah, it's probably similar to how it can't be the key to a weak map or a weak set because you can recreate them again. So the same goes for numbers and symbols and null and undefined, that kind of thing. So this is now a weak ref. The weak ref is a weak reference to the value that I create above. Even if we didn't put the value in its own variable, which is a strong reference, if we didn't have a single strong reference, we would be guaranteed that this value would continue to exist until the next task. So that way we can make sure it doesn't get garbage immediately, we might have a promised chain where we want to use this value in the next microtask. That much is guaranteed. And this is not only for code to work as you expect, but also one of these mitigations for the bandwidth in that the lifetime of the value is elongated so that you can't communicate it as much through garbage collection just because now it's delayed until the next task. And now we could basically call dot deref on the weak reference to see if the value is still there at some point later. And then this maybe value will be undefined if the value had been G seed at some point between these calls, or it will be the actual value if it hasn't. And if we call deref and get the value, again, that's a new point in time where we say, okay, now the value will continue to exist until the next task at the very least. Again, for this guarantee, enter limit the amount of communication that you can do. So when you've called deref, like, all right, two questions, can you call deref multiple times? Yes, as many times as you like. And then the thing you've got is now a strong reference. Dref gives you a strong reference. Yes, it gives, yeah, basically. And so I want until that variable ceases to exist, but even then the value will not be garbage-collected at the very least until the next task. This is actually one of the consistency guarantees, so you can have multiple weak refs to the same value and calling deref on all of them will always yield the same result. There's no way that one weak ref will still have it and the other one won't. Those will always be consistent. So with this, we can have weak reference and hold onto a value without preventing it from being garbage-collected. But actually, sometimes it's more helpful to have it the other way around where we get informed when something has been garbage-collected. Because this way we don't. We just have to check, I guess, every frame or something. Like, it's really hard to, you would have to do polling and that's bad. You wanna have the inversion where you get notified when something gets garbage-collected. And that's the other part, the other half of this proposal. And that is called the finalization registry. The finalization registry takes a callback that will be called whenever a value that you have registered with the registry gets garbage-collected. And you basically registered that value with a held value. And now this is something that might be confusing to some people at first because the value that you wait to, that will be called whenever it's not the value that gets passed into the callback. And that's simply because at the time the callback is called, the value has already been garbage-collected. Doing it the other way around where you pass the value in just before it gets garbage-collected. It could allow you to store a new strong reference. Then the garbage collector would have to undo its thing and it would be way more complicated. So what you do instead, you get a separate value that you can pass in and that can be something for your internal bookkeeping to know which value it originally was or maybe it's the underlying resource you want to free up, whatever. Can you pass the same object in twice? No, that's not gonna work because it has to have a strong reference then. Yeah, so the held value is called held value because it is strongly held.  So this is your optimization step. So if you've got like, if you've vented an object and you've got some sort of system where I want to keep this WebSocket open while this object is still being used, this is the pattern you would use because you get that callback and you go, oh, that object's gone now. Now I can do my related optimizations like close the WebSocket. Yeah. And it is also important to note that the callback will be called at the same time the value gets garbage collected or at some point later in time. So, and again, this is up for interpretation by the engine. It can be very, very long between the actual garbage collection and when this callback will actually be invoked. But what about the weak ref then? Is there guarantees there? Like, could there be a situation where if I deref the weak reference, it returns like undefined or whatever, but this callback fires like an hour later or something? Yes, I think that is a possibility. So I think if the callback has been called, DRF will definitely return undefined. DRF returning undefined doesn't require that this callback has been called because it isn't required to get called at all. And this is what I want to talk about, Dex, because there is no guarantee the callback will run. And that's why it's so important that this callback isn't used for critical work. This callback should be used if a value being garbage collected means you can free up even more memory internally. It is supposed to allow you to reduce memory pressure further. It is not supposed to be used to actually do business logic cleanup work because it might not ever get called. And so in that case, you might actually be more wasteful with these resources than necessary. Yeah, you couldn't build like an analytic system that tells you how many objects are around using this because it doesn't come with those guarantees. Yes, so that's one of the reasons, for example, why this has been tailored with WebAssembly in mind because WebAssembly often passes values to JavaScript that represent something is actually in WebAssembly memory. And so in that case, it makes sense because if the representation in JavaScript gets garbage collected, meaning the engine thinks it's under memory pressure, then code can run to free up even more memory in WebAssembly lands. But if that memory doesn't get freed, it doesn't inhibit the functionality of the app or waste user resources to an unnecessary extent. So yeah, as I said, there is no guarantee that this will run. And there's some two things that they point out makes things especially unlikely for them to run. One is if you close the tab or if you kill the process, there is no need for the engine or no requirement for the engine to run all the registered callbacks if you just kill the process. So it shouldn't be used to like do cleanup work when somebody leaves the page. And it's also very unlikely for these callbacks to run if the registry itself becomes unreachable by a code. So I guess if the registry gets garbage collected unreachable, there is no guarantee that these callbacks will ever be called in the future. Now that we've registered something to get cleaned up, sometimes we might discover later on, actually we don't want this callback handler to run ever and we want to unregister a certain value. For that to work, the function register takes a third parameter, which is the unregistered token. It's similar to the held value and that is symbolizes what you need to have to unregister this one value. In this case, however, unregistered token could be the same thing as some value because it is not strongly held. But sometimes it might be easier if you use a different value altogether just for bookkeeping purposes or keeping it simple or something like that. And then you can just call it unregistered with this unregistered token and that will remove your value from the registry. And now one last method on the finalization registry, which actually I found really interesting because it's the first time that I have seen a normative optional API. That means this API is in the spec, is specced out, but implementers are not required to implement it. I think the only other API on the web that has a similar fate currently are shared array buffers in that they are specced, they're agreed upon, they're merged and everything, but they're not required to be implemented to be fully spec-compliance. Is this the same reason? Is it a security timing thing? Yes, I mean, shared array, we all know that, you know, or we have probably heard of the history shared array buffer that was removed because of spec that meltdown and now it's slowly being incorporated, but they still leave it up to the engine to decide whether they wanna enable them if they don't. Basically, browse who hadn't shipped any mitigation or found a good mitigation shouldn't be considered spec-uncompliance, incompliance? Incompliant, I think it is. I don't know. Whatever it is, don't say that about the browser, that doesn't have shared array buffer because it's a very tough problem. That's basically thinking behind it. And this apparently had a long discussion behind it, which I'm not gonna try to summarize, but some browsers didn't wanna ship this, other browsers didn't wanna ship this, there were basically a big contention around should this ever be, because it's a synchronous API that runs callbacks on amount of values that might have been garbage collected. Oh, sorry, I should explain what this function does first. So the function is called clean up sum and that is basically you saying, hey, if you have a chance, call all the callbacks for the values that have been garbage collected, but you haven't called the callback on just yet. So you're kind of opting like, I would like to process these things now. I actually kind of surprised they made it optional because it would just be just a spec-unpliant to make it a know-up because you don't have to run the callbacks. You can just say like, nah, not running anything. It's just a little, it's a little poke, isn't it? It's just like, please, please, please. But there were browser vendors just agreeing on whether this is good for the main thread or not. And so in the end, they just made it normative optional to implement this. And it currently looks like that at least on the web, we will only be shipping it in workers, not on the main thread, which I thought is quite interesting. So you do have to check whether this method exists before calling it. And this is where optional chaining comes in super handy where you just select the question mark dot parentheses and then it will be called only if that function actually exists. And that's not the first thing that that's happened with in JavaScript, right? Because we've got, it's the atomic stuff, right? There's methods on the Tomics that are only in workers as well. Yeah. And so, yeah, just keep in mind, need to check before it's there. And again, this method is just a request to run these callbacks. There is no requirement from the browser to actually process, call any callbacks or process any values. And that's what I mean, like this entire API is very much trying to leave this freedom for the engine implementers to allow them to implement better garbage collection algorithms in the future, so that they're not constrained by weak graphs and finalization registry. And so it is very, it is, you need to be very careful when working with this. One thing I want to close with, that with this, you can now actually build an iterable week map. And interestingly enough, there's an entire implementation of this in the explainer that is, I have a link here, bit.ly slash iterable week map. If you want to look at that, I'm not going to go through it here because a lot of things to track to make sure that everything is garbage correctly and so on and so forth. But if you're curious, take a look, the weak graphs implementation has shipped in current stable Chrome. I have actually merged it into comlink. So if your browser supports weak graphs, I will automatically garbage collect stuff across the worker boundary now, which I think is kind of cool. So yeah, build, try it out, play around with it, but remain careful to... Do we have enough time for you to quickly describe how you used it in comlink? Comlink, what it does is you have a value in a worker and you basically create a proxy on a main thread, saying like you proxy behave like that object in the worker. And then under the hood, I use a message passing protocol to say, this person wants to access property A, send me the value of property A please. And then this round trip happens. And what I'm doing now is basically have a simple reference counting algorithm. Whenever a proxy is created, I increment that counter and previously I had an explicit release function. I still have that an explicit release function like I don't need this proxy anymore that decreases the counter. And when the counter reaches zero, that thing can get garbage collected on the worker side.  And you can opt in of that, you can opt out of that. But this, again, like this is if there's memory pressure, it might be useful for the engine that I release unused objects in the worker side as well. And so I pretty much just use a weak graph, a finalization registry, sorry, to get a notification this proxy has been released and then I can decrease the counter on the worker side and just let go of the message channels once that counter reaches zero. It should say like, this is super advanced stuff and anyone watching this shouldn't be like, oh, my code doesn't use weak references. I should go and add them in somehow. Like, don't do that. Please don't. Yeah. Please don't. But it is just enabling these like couple of edge cases where you can make extra optimizations or like you say, you can avoid a case where you have to call an explicit destructor, like release function or something like that. Yeah. For me, obviously it is the most exciting part is the WebAssembly bit where you now get a deeper integration between the garbage collector and JavaScript and your memory in WebAssembly. So this is the first stepping stone towards getting garbage collected languages to WebAssembly without having to ship your own garbage collector code in WebAssembly. So that's, it's not the whole story, but it's the first puzzle piece. And so I'm obviously thinking ahead and quite excited about the prospect of having managed languages be smaller and I guess better in WebAssembly. Cool. Well, we'll link to the VA article and to comlink. We'll show where you're using it in comlink. Why not? Yeah, that's good. Actually, I do now understand it a lot better than I did before. I'm glad. Well done, Serma. Well done, me. It's super advanced this stuff.  We should say though that this is super advanced stuff.


So, in this lecture I will be talking about convolution and again this is one of the tools that we will use just like FGF to sometimes compute the distribution function and the density function for different kinds of random variables or the functions of random variables. Mostly the convolution is used for computing the distribution function of sums of random variables. So, here the definition says that if x and y are independent random variables, the distribution function of x plus y is said to be the convolution of the distribution functions of x and y. So, the distribution function that we obtain for x plus y is called the convolution of the distribution functions of x and y.  So, by notation it is clear that the f x plus y is the distribution function for x plus y and f x is for x and f y is for capital Y. Now, for the discrete case the definition would be as follows. So, when the x and y both are discrete random variables and they are independent random variables p of x and p of y denote the p m f of x and y respectively. Then p of x plus y equal to t we will write as summation of p x x. So, you fix the value of capital X, then the y will take the values t minus x and of course, the summation will be over all x for which your this probability is positive and also it should be such that t minus x the probability y at t minus x is also positive. Otherwise, since it is a product of these two probabilities whenever one of them is 0 the whole the contribution of the that particular term will be 0. So, simple definition, but we will see how we can apply these definition and similarly for the case when for the continuous case that means when both x and y are independent continuous random variables that let t denote the sum of the two random variables that is t is equal to x plus y. Then your distribution function for t at small t is probability capital T less than or equal to t and this we can write as minus infinity to infinity probability x plus y less than or equal to t conditioned at x equal to x just as here we chose the value of x and then the corresponding value of y got fixed at t minus x. So, here you condition it on x equal to x and then probability x plus y less than or equal to t. So, then that into that means this is the distribution function into the probability that x takes the value well the pdf of x at small x which will be capital f of capital x x into d x and your x can vary from minus infinity to infinity. So, this is a general expression and of course, it will depend on your the range will depend on the values that your random variables take. So, I have used the concept of conditional distribution here and so this is the expression and therefore, in terms of f f f y capital f y and small f x you can write this as minus infinity to infinity probability x plus y less than t conditioned on x equal to x into f x x d x. So, this we can write as f y integration of minus infinity to t minus x of f y y into f x x d x upon f y x and this we can do because x and y are independent. That means the probability x plus y less than t conditioned on x equal to x I am able to write break it up into f y y into f x x upon f x x d y and so because x and y are independent and then into f x x d x.  So, therefore, the first part I can write I mean the integral minus infinity to t minus x f y d y I can write as probability y less than or equal to t minus x. So, whole integral is then minus infinity to infinity probability y less than or equal to t minus x into f x x d x. So, I hope there is no doubt about going from here to here because when x is equal to x your y will be required to be less than or equal to t minus x and so that is why I have written this probability as capital F y t minus x into this. Now, differentiate with respect to t since the limits are independent of your t therefore, the differentiation will just go inside. So, therefore, this will become small f t t and this will be equal to. So, only this thing gets differentiated this is a function of t and therefore, it will be p d f of y at t minus x and then integral from minus infinity to infinity of this function product of these two. So, this will be your convolution you can either write it in this form or you can write it in terms of the p d f's. And of course, the understanding is that wherever you know for all values of t for which this is defined and you also take the values of x for which this is defined. Now, let us so the basic definition is this and then we will just see how we apply it to different cases and of course, there will be repetition in the sense that for some for sums of independent random variables in quite a few cases by other methods by using the transformation method or by the moment generating function. We have already obtained the density functions for the sums of independent random variables, but here I just want to show you the working of this particular method and therefore, we will just go through a few examples. Now, suppose x 1 is Poisson lambda 1 and x 2 is Poisson lambda 2. So, then t is the sum of the two Poisson random variables and now you want to find out probability t equal to n. So, then if I choose x 1 is equal to x then x varies from 0 to n and this will be probability x 1 equal to x into probability x 2 equal to n minus x. So, from here if this is n I fix x 1 at x then x 2 will be n minus x. So, you just sum and now since they are independent and therefore, I have written it this way product of the probability. So, now this particular probability can be written as e raise to minus lambda 1 and we have missed out on the summation should have been there. So, the summation x varying from 0 to n e raise to minus lambda 1. So, this probability is e raise to minus lambda 1 lambda 1 raise to x upon x factorial and this probability would be e raise to minus lambda 2 lambda 2 raise to n minus x upon n minus x factorial. So, here also summation x varying from 0 to n. Now, then just rearrange the terms e raise to minus of lambda 1 plus lambda 2 then I have divided and multiplied by n factorial. So, this is n factorial and then here it will be n factorial divided by x factorial n minus x factorial and then you have lambda 1 raise to x and lambda 2 raise to n minus x. Now, this is the you can see that this is the expansion of the binomial expansion of lambda 1 plus lambda 2 raise to n because you are summing see this thing is independent of x e raise to minus lambda 1 plus lambda 2 divided by n factorial. So, this I take outside and then the summation x from 0 to n of this will be your lambda 1 plus lambda 2 raise to n and so this will be now Poisson with the parameter lambda 1 plus lambda 2. This is probability equal to n. So, therefore, e raise to minus lambda 1 plus lambda 2 divided by n factorial into lambda 1 plus lambda 2 raise to n. So, you can immediately conclude that this is now Poisson with parameter lambda 1 plus lambda 2. So, another example I want you to show that x 1 plus x 2 plus x n is negative binomial. And so here now we are extending this concept to more than 2 sum of more than 2 independent random variables where x i's are actually I could have straight away said that x i are independently identically distributed geometric random variables and geometric random variables with probability of success as p. So, that means probability x i that means the probability this is just a geometric random variable and so and the probability of success is 1 that is it. When you describe a geometric random variable you just need to know the probability of success and then you want to find the probability that you will get a success in n trials. So, now here we first consider the sum of 2 random variables x 1 plus x 2 and so probability x 1 plus x 2 equal to n by convolution we will write as x equal to 1 to n minus 1 because there should be I mean I cannot make this 0 I cannot have x going from 1 to n because in that case when x is equal to n this will be 0 and so anyway this will be not defined on the probability we will write it as 0. So, there will be no contribution to this sum. So, I have to take the summation from 1 to n minus 1 and then if I fix x 1 at x that means for the first geometric random variable the success the first success occurs for x trials then for the second one the first success will occur at the n minus x trial. So, the probability of x 1 equal to x is 1 minus p raise to x minus 1 into p at the x trial the success must occur otherwise before that all failures and similarly here it will be 1 minus p raise to n minus x minus 1 into p. So, when you rearrange the terms here see x minus 1 and this is minus x. So, x minus x cancels out you are left with n minus 2 and this is p square. So, this is equal to sigma x varying from 1 to n minus 1 1 minus p raise to n minus 2 p square, but you see x is not present here. Therefore, you just add up these terms n minus 1 times. So, this is n minus 1 into 1 minus p raise to n minus 2 p square. Now, this you can see is the probability that out of n successes out of sorry out of n trials 2 are successes and n minus 2 are failures. So, that means this is the probability of 2 successes in n trials right where the of the last success occurs where the second success occurs at the end. So, when the 1 success can occur anywhere in the n minus 1 trials. So, therefore, this is n minus 1 1 you can write this as n minus 1 1 choose 1 and then 1 minus p raise to n minus 2 and p square. So, 1 success occurs anywhere in the n minus 1 trials and then 1 success occurs at the end and therefore, this is probability of 2 successes in n trials. So, therefore, x 1 plus x 2 if you let y be equal to x 1 plus x 2 we have shown that y is negative binomial with the parameters 2 comma p right. The probability of success is p here in the example I probably did not really mention, but it is understood that probability that probability that x i is equal to the probability of success sorry. I should say that probability of success is equal to p I should have mentioned that here. So, it is understood anyway right now we can iteratively show that if you now consider the random variable y plus x 3 then by the same argument we will be able to show that this is negative binomial 3 comma p and so on. So, therefore, you can show that this will be negative binomial when x i is a geometric random when each x i is a geometric random variable for all i and x i are independent. In the example where we consider the sum of the geometric independent geometric random variables all with probability of success as p then you see x i was the number of trials required for a success for 1 success. Therefore, see if the corresponding number is n i that means the number of trials required for 1 success for the ith geometric random variable. So, then you see when you say x 1 plus x 2 this will be the number of trials required for 2 successes right and that number will be then n 1 plus n 2. So, essentially when I wrote that the sum x 1 plus x 2 is 2 comma p negative binomial. So, that the understanding is that you want 2 successes and therefore, the number of trials of course, will be equal to n 1 plus n 2 then. So, therefore, finally, when you go on doing iteratively this procedure of you know adding on or convoluting these random variables then x 1 plus x 2 plus x n will finally, give you the number of trials required for n successes right and therefore, this was negative binomial n p right and the total number of successes trials required would be n 1 plus n 2 plus n n right. Now, the next part was that without any calculation you can also conclude see this was just to show you how you would apply convolution and now here we can also because by just by description because when you say x 1 plus x 2 plus x n that means you are asking for n successes and your probability of success is p and therefore, x 1 plus x 2 plus x n gives you the number of trials required for n successes when the probability of success is p. So, just by saying it aloud you know since each x 1 x 2 x n is the is geometric random variable independent therefore, when you add up you can say that this will be a negative binomial n comma p. So, that is all we just to because here you very did not require to use convolution right. Now, let us consider again apply convolution to sum of independent uniform random variables both are 0 1 right. Now, so therefore, the corresponding PDFs will all both be 1 as long as x and y are between 0 and 1 and it will be 0 otherwise right. So, let us define the random variable t equal to x plus y. Now, the thing is that you see we will have to and this is where the this part comes that sometimes of course, you can easily determine the ranges, but sometimes it will not be that easy. So, here for example, you see when I write the formula f x x x and f y t minus x. Now, you see this is defined only for between 0 and 1. So, my t minus x also should vary between 0 and 1 and therefore, I have to get this I have to write I mean I have to do this computation for first for t between 0 and 1 because t minus x greater than 0 implies that x is less than or equal to t. See from here this is not defined for t minus x being negative. So, therefore, t minus x has to be non-negative which requires that your t should be greater than or equal to t greater than or equal to x and then also t minus x should be less than or equal to 1. So, you cannot take a value of and therefore, t must be less than or equal to from here t must be less than or equal to 1 plus x. Since x can take 0 value therefore, you see immediately from here that your t cannot be more than 1. So, here we will have to the way we are defining this it will have to be the limits for t would have to be from 0 to 1. And then your x can vary from 0 to 1 when you write now I mean I am writing the integral this way, but since for x non-negative and x between 0 and 1 this is 1. So, therefore, this will reduce to simply integral 0 to t f t minus x d x. Now, when I say that my x varies from 0 to t. So, this is also defined and therefore, this is also equal to 1 as long as x is varying from 0 to t this is well defined and it is within the range of the values for y. And therefore, this also is 1 and so this integral comes out to be t and t between 0 and 1. So, this is what I have drawn you for you the curve this value is also 1. So, therefore, the p d f for the sum of the 2 random variables when both are uniform will be given by this. Now, because x plus y and both can take values between 0 and 1. So, of course, the range for this is from 0 to 2 and so we have to consider the values of t lying between 1 and 2. And in this case you see again the convolution formula is this. So, t minus x less than or equal to 1 will imply that your x is greater than or equal to t minus 1. So, here immediately you see that t must be greater than or equal to 1 or x is greater than or equal to t minus 1. So, that is why the range t greater than or equal to 1 and then of course, it cannot go beyond 2. So, therefore, again the same reasoning that this value is 1 in the valid portion region where we can define this and why am I writing. So, this is t minus 1 to 1 that means my x can vary from t minus 1 to 1. So, t minus 1 yes. So, this thing you see at t minus 1 this will be 1 because t minus t plus 1 and when this x is 1 this will be t minus 1 because your x has to be greater than or equal to t minus 1. So, therefore, the range is this and again in this range this function is equal to 1. So, the integral is t minus 1 to 1 1 into d x which comes out to be 2 minus t and that will be your this graph will be the function will be represented by this straight line. So, therefore, the sum of the two random uniform random variables both independent and defined on 0 1 the pdf is a triangular distribution thing. So, therefore, you see here you could not have just straight away done this integration from 0 to that means you could not have allowed t to vary from 0 to 2 because that would not have given you the valid answer and here you had to break up the region of integration from 0 to 1 and then 1 to 2. And I suppose because we are writing t minus x. So, we have to do it this way that it x has to be greater than or equal to t minus 1 and we are integrating the respect to x. So, x cannot go beyond 1 therefore, this will be t minus 1 to 1. So, another example is now sum of two independent gamma random variables. So, suppose x is gamma s comma lambda and y is gamma t comma lambda then and x and y are independent. So, we have to obtain the pdf of x plus y. So, define t as x plus y and then by the convolution formula f t a we will write as this. Now, here again we have to apply the same thing because gamma pdf is defined only for non-negative variables. So, therefore, this has to be a minus x has to be non-negative. So, therefore, this a minus x non-negative this implies x less than or equal to a. So, I can that means here my integration has to be from 0 to a. Now, why am I writing this as yeah. So, right now I will you know write the correct range, but we are just right now substituting for f x x which will be lambda e raise to minus lambda x and lambda x raise to s minus 1 because x is s comma lambda gamma s comma lambda. So, the pdf is lambda e raise to minus lambda x into lambda x raise to s minus 1 and this is pdf for y is lambda e raise to minus lambda of a minus x into lambda of a minus x raise to t minus 1. You see as we said x has to be less than or equal to a and now if you. So, therefore, this infinity will get replaced by a and you see here e raise to minus lambda x then e raise to plus lambda x that will cancel out you will be left with e raise to minus lambda a and then here it is lambda x raise to s minus 1. So, if you just take out the lambda here it will be lambda raise to s minus 1 and this will be lambda raise to t minus 1 and you have lambda square here. So, the whole thing will be lambda raise to s plus t minus because this is 2 and this is minus 2. So, you have lambda raise to s plus t and that is what we have written here. So, this is lambda raise to s plus t e raise to minus lambda a and then you are left with x raise to s minus 1 and a minus x raise to t minus 1 d x. Now, make the substitution that x upon a is equal to z. So, this will imply that your d x gets replaced by a d z and your range goes from 0 to 1 instead of 0 to a because x by a we have put a z. So, range for z will be from 0 to 1. So, therefore, the constant terms I have put outside and so this a comes from here and then you have this in this. Now, you see this looks familiar and this is the beta function and therefore, since we want to. So, therefore, we know that this integral from 0 to 1 d z will be equal to gamma s into gamma t upon gamma s plus t. So, from the definition of the beta distribution we know that this integral must be equal to gamma s into gamma t upon gamma s plus t. And therefore, I replace this whole thing by this thing. So, then gamma s, gamma t cancel out you are left with the gamma s plus t and this is lambda raise to so the lambda we write outside here and then it will be lambda a raise to. So, this makes it s plus t minus 1. So, therefore, lambda a s plus t minus 1, 1 lambda I have written out here just to conform to the form of the gamma distribution. And so this is therefore, this is I should have written here, gamma s this is gamma s plus t lambda. So, we have concluded that if you take two independent gamma random variables x is gamma s lambda and y is gamma t lambda then the sum and their independent and the sum will be again gamma distribution having a gamma distribution with parameters s plus t and lambda. So, the same lambda if the second parameter is the same then I can go on adding the gamma random variables and the first parameter gets added of course, you are adding independent gamma random variables. So, corollary first is that if x 1, x 2, x n are gamma s i lambda and they are independent random variables then by repeated use as we did earlier by repeated use of convolution it follows that x 1 plus x 2 plus x n will be gamma sigma s i I varying from 1 to n comma lambda. So, here of course, the this thing is immediate that is you are adding the distribution is not changing it is just the parameter is changing and that also the second parameter the first one that is a common one that remains the same. Another corollary which is that if you take x 1, x 2, x n are identically independently distributed exponential lambda random variables and we know that an exponential lambda here only you can see from the gamma pdf that is a gamma 1 comma lambda. An exponential lambda is gamma 1 comma lambda and so when you take x 1 plus x n exponential random variables I did independently distributed then this is a gamma n comma lambda because the first parameter gets added and this. So, x 1 and we will see uses of all this when we talk about random processes, stochastic processes which are Poisson and Markov and so on. So, I have tried to depict by various because I want you had to you could not just blindly apply the convolution you had to make sure that when you are applying it your values of the variables should be such that these pdf are defined and so on. So, we did this now of course, the question is see we have defined this for independent random variables that means the convolution right now we the definition says that they are independent and then you take the sum and then you can talk about the convolution. But can you answer the converse can you that is if you can show that the for two random variables x and y the distribution function for x plus y can be written as a convolution of the distribution functions of x and y would it imply that x and y are independent. So, this is the question and I will try to answer through a counter example to say that no it may it is not necessary the you may get the distribution of the sum by the convolution, but the variables may not be independent. So, this example is I have taken it from Dodevich and Mishra and as I told you I have often taken examples from this book Dodevich and Mishra and Sheldon and Ross and I have give you the references also at the end of the course. So, here and this example is originally due to W. T. Hall and you will see how cleverly the this construct this has been constructed. So, see as I said the we try to answer the question that if the distribution of x plus y is the convolution of the distribution of x and of y does it follow does it follow that x and y are independent random variables. So, we want to answer this question because we have defined the convolution for independent random variables. So, the table here gives you the joint I should make the at least it will look nice. So, this is it. So, therefore, this table gives you the joint probability function probability mass function of x and y and theta is a fixed number, but it is absolute value less than 1 by 9 because otherwise the entries here will become negative. So, we want this to be a valid table for joint probability mass function of x and y and you can see that when you add up these. So, the marginal p d f's are independent of the marginal probability mass functions are independent of theta and this is where I am saying that the thing has been very well constructed. So, see these will 3 will add up to theta theta will cancel plus theta and minus theta. So, it will be 1 by 3. Similarly, here this minus theta and plus theta will cancel. So, this will also be 1 by 3 and finally, this is also 1 by 3 and your column sums also give you the marginals which are all independent of theta. And now you want to write. So, we want to verify that the distribution function of x plus y is a convolution of the distribution functions of x and y. So, the values that x plus y will take are minus 2, minus 1, 0, 1 and 2. These are the possible values that x plus y can take because your x takes the values minus 1, 0, 1 and y takes the values minus 1, 0, 1. So, you start with probability x plus y equal to 0 and we will have to verify for all possible values to make sure that this is that x plus y, the distribution of x plus y can be obtained as a convolution of distributions of x and y. So, here by convolution I mean I am taking x to be equal to 1, then y will be equal to minus 1. And if you take x equal to minus 1, then y will be 1 and if you take x equal to 0, then y will be also 0. So, these are the 3, you can convolute here this and probability for x equal to 1, 1 by 3 that is what we mean by marginal 1 by 3 into probability y equal to minus 1 that is also 1 by 3. So, therefore, this is 1 by 9. Similarly, you can immediately see that probability x equal to minus 1 is 1 by 3 and probability y equal to 1 is also 1 by 3 and 0, 0 also x equal to 0 gives you 1 by 3 and y equal to 0 also 1 by 3. So, this is 1 by 3 and then similarly, probability x plus y equal to 1. So, here also when you want to fix x and then the corresponding value of y. So, here I put x equal to 1, then y will have to be 0 and I put x equal to 0, y is equal to 1 and you should have put if you put x equal to minus 1, then that is not valid. x equal to minus 1, then y can only take a value 0, 1 or minus 1. So, this is these are only 2 ways you can convolute the sum x plus y equal to 1 here and therefore, this probability is 2 by 9. I have tried to compute just to make sure that see because even if for 1 single value the convolution does not hold, then I cannot say that and so for x plus y equal to 2 only 1 possibility x takes value 1 and y equal to 1. So, this is also I have taken this example because it shows you that when we write f x of x into f y of t minus x, then you see you have to take only possible values of t, you cannot just take any. So, x plus y equal to 2 will be given by x equal to 1 and y equal to 1. So, this probability is 1 by 9 and similarly, x plus y equal to minus 2 will be given by x equal to minus 1 and y equal to minus 1. So, that is 1 by 9. So, now we compute these probabilities without convolution. So, for example, probability x plus y equal to 0 will be probability x equal to minus 1 y equal to 1. So, all pairs that make up x plus y equal to 0 plus probability x equal to 1 y equal to minus 1 and plus probability x equal to 0 y equal to 0. And so, from the table we can see that minus 1 1 x minus 1 and this 1. So, 1 by 9 minus theta and then 1 minus 1. So, 1 minus 1 is 1 by 9 plus theta and then 0 0 x 0 y 0 that is this which is 1 by 9. So, therefore, this adds up to 1 by 3 minus theta and theta cancel out. So, this is 3 upon 9 which is 1 by 3. Similarly, x plus y equal to 1. So, x equal to 0 y equal to 1. So, again 0 1 1 0 and so on. So, 0 1 0 1 will be 1 by 9 plus theta 1 0 will be 1 by 9 minus theta and that is it because the sum to be equal to 1 these are only 2 possible pairs of values that x and y can take. So, 1 by 9 plus theta plus 1 by 9 minus theta is 2 by 9. So, this also matches with this and this matches with this 1 by 3. And then similarly, you can see that x plus y equal to 2 will simply be the pair x equal to 1 y equal to 1 which is 1 by 9 x equal to 1 and y equal to 1 1 by 9 which also matches with this 1 right. And then x plus y equal to minus 2 this is x equal to minus 1 and y equal to minus 1 x equal to minus this is 1 by 9 and here also we got it as 1 by 9. So, we have checked almost for all yes well not exactly may be x plus y equal to minus 1 that is left out, but we have otherwise checked for x plus 0 1 2 2 2 and minus 2. So, that 1 was but you can easily verify that for all values that means the probability mass function of x plus y matches with the probabilities obtained by convolution for all theta less than or equal to 1 by 9. So, therefore, so the 2 things match, but we know that x and y are not independent y because you just take one pair see I just have to show that for one pair of values this does not hold that is probability x equal to minus 1 and y equal to 0 that is from the gain from the table is 1 by 9 plus theta, but this is not equal to sorry what I am saying is that this is not equal to probability x equal to minus 1 into probability y equal to 0. So, x equal to minus 1 from the marginals is this 1 by 3 and probability y equal to 0 this is y equal to 0 is 1 by 3. So, that is 1 by 9 and therefore, the 2 are not equal as long as theta is some positive number of course, satisfying the condition that absolute of theta is less than or equal to 1 by 9. So, for any for a positive theta satisfying this these 2 will not be equal and therefore, x and y will be independent only when theta is 0. So, here is an interesting example and it must have taken them lot of time to construct such an example. Now, if you try to do it for when x takes only 2 different values x and y take 2 different values it will not be possible then you can think of you know trying situation where x and y take 4 values each then you will have to make sure that you will have to write down these probabilities in such a way that the marginals are independent of theta right. And then you can have a chance to show that you can construct such an example that the probability mass function of x plus y can be obtained by convolution, but the variables x and y are not independent. So, it might be a very interesting project, but I am not sure if it is possible, but here definitely not of effort went into it to show that convolution does not imply independence all the time. So, you see according to me we have developed enough machinery to be able to now show you some more interesting application complex in the applications of the tools that we have or the machinery that we have developed so far of probability theory. And I would like to now devote the rest of the course on you know stochastic processes or and only simple basic ones. And because otherwise the you know there is a full vast subject on stochastic processes and things can get very complex, but so the first thing would be the first stochastic process that I would like to talk about would be poison process. And the idea here you have already talked of a poison random wearable and then we have also looked at exponential and gamma random wearables and we will see that how these things get you know we sort of use the different kinds of distribution that we have developed into answering questions. So, essentially the thing is that you know you have it is a counting process and you have a service let us say post office a railway booking counter well there are still people who go and book at the railway counters not everybody does it online is not it is not possible for everybody to do it. So, whatever these services are there now you want to have an estimate as to how many people are coming and what is the so and therefore, then accordingly you can design the service. So, that people do not have to wait for a long time to be serviced how many counters should be there and so on. So, these are the kind of things we will be talking about and so basically we will be defining N T as the number of people who are entering let us say a post office up to time t. So, we will keep a count and we will measure the number of people I mean we will count the number of people who enter the post office say starting from 0 time to time time and then we will I answer lot of questions depending on that, but then the thing is that because we are calling it poison process. So, this four there will be certain conditions which will have to be satisfied by you know this process because when you are modeling it then we have to have some basic conditions which are met by this particular counting process. And then we will develop this structure and try to answer few questions and the other one would be the other process that we will talk about would be Markov process and so they are both interesting the basic and the we can sort of develop will answer lot of questions through these because we have developed the machinery to do that. So, this would be my you know next few lectures would be on poison process and then on Markov processes. In my last lecture I had told you that we will now be talking about some stochastic processes and in fact so and one of them is the Poisson process. This is you can describe this as a probabilistic model used for describing unpredictable events right because there is a chance element. For example, when an earthquake will happen or when a certain person walks into a post office these are all unpredictable events. So, the Poisson process is a probabilistic model and certainly when you model a situation then there are certain rules or certain and of course, so the idea here is that you are modeling a situation where the events exhibit a certain amount of statistical regularity and that of course, this means that you know you can approximate the occurrences by a probability density function. So, these events they exhibit or approximately exhibit a statistical regularity and so essentially the Poisson process is a counting process. So, that means essentially these unpredictable events they get counted by the model that we will create here and then of course, lot of decisions and lot of conclusions can be based on this counting process. This is what we will see in the next couple of lectures. Now, the examples as I said are number of persons entering a post office or a bank up to time t. So, always the measure that means when I am saying n t this is the time to start counting the events starts at 0 and then up to time t. So, we count the number of events that take place and therefore, like for example, when you are counting the number of persons entering a post office or a bank then this is so an event will occur when a person enters the post office. So, therefore, n t will give you the number of people who have entered the bank or the post office up to time t counting from 0 starting time 0. So, 0 to t the number of people who have entered the bank or the post office other examples could be number of children born in a town or a village up to t days or t months whichever this you know time period you want to fix. The time framework is decided and then you start the counting process and of course, in this case event will occur when a child is born. So, you keep counting these events. Now, number of goals hit by a hockey player up to time t. So, when the match starts and then after that up to time t may be this could be the half time or whatever it is then you identify a particular hockey player in the team and then you say number of goals hit by a hockey player up to time t. And here again the event will occur when a goal is hit by this particular player because you are counting the number of goals hit by a particular hockey player. So, this situation and for example, also you can have if you want to pick up a country or a place where a volcano is and then you want to find out the number of times a volcano erupts. So, here of course, your time span may be may be 5 years or 10 years and then you may because volcanoes luckily do not erupt very often. So, therefore, you would your time span would be much more than for these particular events. So, now through these examples we realize that whatever our counting process is and this n t must satisfy the following. So, since it has to be 0 because when this counts the number of events that have taken place. So, obviously, this has to be 0 positive then n t is integer value because we are counting the number of events and then for s less than t your n s must be less than or equal to n t. So, either no event occurs in the interval this or some event occurs after s time s. So, therefore, n s must be less than or equal to n t. So, this number this counting process this satisfies this condition then for s less than t your if you take the difference as. So, 3 and 4 are you can be clubbed together also n t minus n s is equal to equals the number of events that occur in time interval s comma t. So, here of course, n s the you know you have counted the events up to time s. So, after s you start counting the events that take place up to t. So, this will be open at this end this interval time interval enclosed at this end. So, s comma t. So, therefore, this is this. Other things that we want to impose because remember we are thinking of modeling this situation where we want to count the number of events that take place, but certain conditions will have to be met.


Talking about occupations. This free English lesson is sponsored by the following English learning sites. Today, we're going to talk about occupations or jobs. What do you do for a living? This is a common question to ask a person about his or her job or occupation. Other questions are, What is your occupation? What do you do? What kind of work do you do? A simple answer might be, I'm a dentist. I'm an engineer. She's a doctor. He's a lawyer. You can also answer by mentioning the place you work. I'm a sales clerk at Valmart. You can mention both your job and place of employment. I work for the chain company. Or just the company. I work at ample computers. At means the location. I work for the UPX company. For means you're performing a service for the company. I work for Amazon. Sometimes you only need to mention the company name. What do you do at UPX? I'm a... Mention your job title. For example, I'm a scientist. I verb. Tell about the things you do. For example, I teach. I verb plus object. Be more specific. For example, I teach computer skills. You can also ask someone more information about their job. How interesting. That's interesting. What do you teach? What do you do in your job? Do you work from home or at an office? How long have you worked there? What if you aren't currently working? Being a student is also an occupation. It is what occupies your time. I'm a student at George University. I'm studying physics. You can also mention future career plans. I'm preparing to be an architect. I'm taking courses in web design. I'm getting my real estate license. If you don't have a full-time job, be positive about what you do. I'm a stay-at-home mom, or stay-at-home dad. That's actually a full-time job. I'm retired. I'm looking for work right now. I'm between jobs. So, what do you do? Well, I... talk about your occupation. Here are some sample jobs. Doctor Businesswoman Businessman Mechanic To see more jobs, click on the links in the description below. Test yourself. Do you know the English words for these occupations? More occupations. Did you get them all right? Number one. Carpenter Number two. Store clerk or cashier. Number three. Photographer. Number four. Singer. Number five. Gardener. Number six. Chef or cook. Number seven. Librarian. Or maybe a teacher. Number eight. Pilot. Can you think of other occupations? You can use third person singular in the present tense. For example, my friend is a consultant.  She listens to their problems and offers them advice about business. Here's a matching exercise about people in different... about what people in different jobs do. Occupation Mechanic Teacher Doctor Nurse Journalist Fisherman Gardener Chef Cook Firefighter Photographer Practice making sentences like this. A mechanic fixes cars. A chef cooks meals. Match the occupation on the left with the activity on the right. Feel free to pause the video if you'd like more time for practice. Check your answers. A mechanic fixes cars. A teacher teaches classes. A dentist pulls teeth. A doctor or nurse takes care of patients. A journalist writes news stories. A fisherman catches fish. A gardener plants flowers. A chef or cook cooks meals. A firefighter puts out fires. A photographer takes pictures. Here's a sample conversation about occupations. What do you do for a living? What is your occupation? I'm a mechanic. A mechanic that must be a lot of work. It is. Every day I fix cars. How interesting. How many cars do you fix? I fix about 8 cars every day. Practice the conversation using the jobs and activities you've just learned. Feel free to go back to the previous page to get information about jobs and activities. Pause the video if you'd like more time for practice. Free talking. 1. Talk about your own occupation. What kind of work do you do? Describe a typical day at your job. 2. Talk about someone else's occupation and what he or she does. Use third person singular for this. For example, Mr. Tan works at a pharmacy. 3. Have a conversation with a partner. Ask and talk about each other's jobs. Pause the video and take as much time as you'd like for this activity. Hope that was helpful. For more information, check out the links in the description below. And don't forget to subscribe to our channel. Thanks for watching. Learn more English at eslgold.com