A generating function is a mathematical tool that encodes a sequence of numbers or probabilities into a polynomial, where each coefficient corresponds to a specific value; this encoding allows us to recover individual values through derivatives (PK = f^(K)(0)/K!) and perform powerful operations like calculating expected values, convolving distributions (multiplying generating functions yields the distribution of sums), and solving combinatorial counting problems by multiplying generating functions that represent different constraints.
A Brief Introduction to Generating Functions in Probability & Counting
Added:okay let's talk about generating functions so what is a generating function and why do we want to know about it I think a nice way to think about it is treating it purely as a convenient trick to record a bunch of numbers open probabilities associated with some integers or counts so let's imagine a dice it is a goodlook dice but it's not perfect and the probability of having a number is not exactly 1 / 6 and we can write down the probability of having number one as P1 number two as P2 and so on okay now pause the video and think about the following question can you create a mathematical function that contain all the information about these probabilities so that we can recover all property values from P1 to P6 anytime we want okay if you think about it it may be clear that you need a way to isolate these values from each other somehow probably the simplest way to do that is using a polinomial by associating each number with different powers of the polinomial so it goes like this so P1 goes with X P2 goes with X squ and so on at this point we don't really care about the roots of the polinomial or we don't even care about how this function look like all we care about is we just want to keep these numbers safely inside this polinomial function and now you have a gen function for these probabilities so can this function speed out or generate the probability values back to us um let's think about it let's first focus on P1 which seems easiest so how can you get back P1 from this function consider this function as a machine with a bunch of buttons you can press and this each button correspond to some mathematical operations so again pause the video and think about it for a moment and yes we can use calculus here so let's just take a derivative of GX okay every term except the P1 term has X in it so that means we can simply let X to be zero and we have P1 so how about P2 we can take another derivative and set X to be zero great uh this means that if you want to get the value of PK we just need to take the derivative of GX K * evaluate it at xal Z and then divide with some appropriate constant this constant is actually K factorial and I'll let you prove it now we can get the probability values back from our generating function but uh didn't we already know them why do we need to go through this much work just to recover what we already know well it's true that no magic happens here whatever you do with a generating function it should be in principle possible without using it but at the same time generating function can do amazing things because it lets us apply powerp analytical tools to the whole distribution so here is a simple example so let's look at the first derivative of our generating function what happens if you let X to V1 do you see what's going on here we have just calculated the expected value of the dice another really cool thing happens when you multiply generating functions okay see what happens if we Square our generating function here the lowest power of X will be two and you'll get p1^ squar as its coefficient right and let's just write few more terms again just pause the video and just look at these terms do you see any patterns let's imagine the case where we throw the same dice twice and count the total number of eyes if you get two ones the total will be two if you get one and six the total will be seven right now think about the probability of having the total of two you should have one I in both cases so the probability will be P1 * P1 well this is exactly same as the coefficient of x to the^ of two is this a coincidence now let's look at another case to have four as a total you should either have one and three or two and two or 3 and one such probability is P1 * P3 plus P2 * P2 plus P3 * P1 which is again exactly same as the coefficient of the X to the^ of 4 so you can also notice that the power of X is always equal to the sum of the subscript in the probability values right so in other words if you multiply generating functions the resulting function will be yet another generating function which represent the probability distribution of the sum of the values from the original generating functions this is really cool and this property makes counting problems really easy and also makes generating function as a really useful tool to study random graphs with arbitrary degre distribution so I'll just show you a simple counting example say you want to buy 10 candies and they are red blue and green candies somehow you want to have even number of red candies more than six blue candies and less than three green candies how many ways are there to combine these color candies you may want to just carefully count all the cases but with generating functions this can be done quite systematically so first of all you can represent the even number of red candies as a generating function and then the case for the more than six blue candies as another generating function and finally less than three green candies means this simple generating function now we can multiply all these generating functions to enumerate all POS possible cases where we can buy candies so now we expand this formula and all we need to do is check out what is the coefficient of x to the^ of 10 this coefficient tell us how many ways there are to combine three colored candids so uh although it can be puzzling at first generating functions are really cool and convenient and awesome and we can also talk about how it can be applied to solve problems in net talk science in some other videos thank you
Up Next

Generating Functions in Combinatorics: Discrete Math Lecture 30
@iit
99K views•2007-12-06

Gain Recalibration in Hippocampal Path Integration: Math Theory
@1024kyz
144 views•2020-07-02

Fourier Series Introduction: The Big Idea Explained
@DrTrefor
387K views•2021-05-03

The Mathematical Impossibility of Accurate World Maps
@Vox
23.3M views•2016-12-02
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Mathematics
![[3. Discrete RVs] 3.1 Discrete Random Variables Basics](https://i.ytimg.com/vi_webp/STcqHZyPRI8/maxresdefault.webp)


![Probability and Statistics [Lec 5] : Random Variables and Expectation](https://i.ytimg.com/vi_webp/FeiGeBparjo/maxresdefault.webp)








![[멱급수 전개 (개념 및 예제풀이)] 테일러급수 & 매클로린급수](https://i.ytimg.com/vi/WYicw5Z_vKQ/maxresdefault.jpg)




![VALOR NUMÉRICO de un POLINOMIO👉con [SUMA INFINITA] ✔ EJERCICIO RESUELTO](https://i.ytimg.com/vi/90-U5V05bo4/maxresdefault.jpg)





















