# In finding the moment generating function why do we multiply by $e^{tx}$ for each pmf term?

The moment generating function that is associated with the discrete random variable $X$ and pmf $f(x)$ is defined as:

$$M(t) = E\left[e^{tX}\right] = \sum_{x \in S} e^{tx} f(x).$$

Where does this $e^{tx}$ come from? This vaguely looks like an integrating factor from differential equations.

Also, I find it strange that when we take the derivative of $M(t)$ we don't say "lets take the partial derivative with respect to t" but isn't this what we're doing, treating $x$ as a constant? Why do we use the derivative notation instead of the partial derivative operator?

There's a potential ambiguity in your question:

If you're asking (a) "Why is $e^{tX}$ inside the expectation?" then the answer is 'that's the definition of the moment generating function'.

On the other hand, if you're asking (b) "Given we want $E(e^{tX})$, why does $e^{tX}$ appear in the summation?", this would be because that's how expectation works.

That is, for the continuous case $E[g(X)] = \int g(x) f(x) dx$ (indeed, some authors seem to regard that law as a definition of expectation).

Why do we use the derivative notation instead of the partial derivative operator?

Because $X$ isn't regarded an argument of $M$, $t$ is. If it were $M(X,t)$, then we'd write $\partial$, but it's $M_X(t)$, so we write $d$. This isn't some accident of notation, however - it really is a function of $t$ we're dealing with, though calculated with respect to the distribution of $X$. Inside the integral/sum, $x$ is actually a dummy variable; it could as easily be represented by $u$, or any other dummy, and $M$ is certainly not a function of the dummy variable in any sense. You might think of $X$ like an indexing variable (since it determines which $M$ you get), but if $M$ is to be regarded as a function of something to do with $X$, it's really $F_X$ (through $dF$) that $M$ is a function of.

If $X$ is a discrete random variable taking its vales in $S$ and $h$ is a non negative function, then $$\mathbb E[h(X)]=\sum_{x\in S}h(x)\mathbb P\{X=x\}.$$ Indeed, we formally have $$\mathbb E[h(X)]=\mathbb E[h(X)\chi_{\bigcup_{x\in S}\{X=x\}}]=\sum_{x\in S}\mathbb E[h(X)\chi_{\{X=x\}}].$$ Now we use this with the map $x\mapsto e^{tx}$, where $t$ is fixed.

We don't need the partial derivative as there is no ambiguity: we can only take the derivative with respect to $t$.