Moment Generating Function Calculator
Compute MGFs, moments, means, variances, and distribution curves from one interface.
Results are calculated automatically as you enter data.
▼ See explanations and tips below ▼
Related Calculators
What Are Moment-Generating Functions?
A moment-generating function, often shortened to MGF, is a function that summarizes a probability distribution in a compact mathematical form. For a random variable \(X\), the moment-generating function is defined as:
The variable \(t\) is not a value of the random variable itself. It is an argument used to build a function that can reveal important facts about the distribution.
The name comes from the fact that MGFs can generate raw moments. A raw moment is an expected power of the random variable, such as \(E[X]\), \(E[X^2]\), or \(E[X^3]\). The first raw moment is the mean. The second raw moment helps compute the variance.
MGFs are useful because they connect probability with calculus. Instead of repeatedly summing or integrating to find moments, you can differentiate the MGF and evaluate the derivative at \(t=0\), as long as the MGF exists around zero.
Why Moment-Generating Functions Matter
Moment-generating functions are common in probability theory and mathematical statistics because they give a systematic way to work with distributions.
They are especially useful for:
- Finding means, variances, and higher raw moments.
- Comparing distributions by their functional form.
- Working with sums of independent random variables.
- Recognizing a distribution from its MGF.
- Checking whether a parameter change affects the mean, spread, or tail behavior of a distribution.
For students, MGFs are a bridge between probability and calculus. For instructors and analysts, they are a concise way to explain why familiar formulas for mean and variance are true.
Key Terms to Know
- Random variable: A numerical outcome of a random process, usually written as \(X\).
- Expected value: The long-run average value of a random variable, written as \(E[X]\).
- Raw moment: An expected power of a random variable, written as \(E[X^r]\).
- Mean: The first raw moment, \(E[X]\).
- Variance: A measure of spread, equal to \(E[X^2]-[E[X]]^2\).
- PMF: A probability mass function, used for discrete distributions.
- PDF: A probability density function, used for continuous distributions.
- MGF domain: The set of \(t\) values for which the moment-generating function is finite.
- Rate parameter: A positive parameter often used for exponential and gamma distributions. This calculator uses rate parameterization for those distributions.
- Scale parameter: The reciprocal of a rate parameter. For example, if a gamma distribution is written with rate \(\beta\), the corresponding scale is \(\theta=\frac{1}{\beta}\).
How Moment-Generating Functions Work
The core idea is that the exponential function has a power series:
Taking the expected value gives:
That is why the derivatives of \(M_X(t)\) at zero produce raw moments:
For the first two moments:
Then variance can be found from:
For a discrete random variable with PMF \(p(x)\), the MGF is usually calculated by summing over the support:
For a continuous random variable with PDF \(f(x)\), the MGF is calculated by integrating:
The function must be finite on an interval around \(t=0\) to be treated as an MGF in the usual sense. Some distributions have moments but do not have a finite MGF near zero, so the domain matters.
Common MGFs for Supported Distributions
The calculator supports common discrete and continuous distributions. The table below uses the same parameter conventions as the calculator.
| Distribution | MGF \(M_X(t)\) | Mean | Variance | Domain of \(t\) |
|---|---|---|---|---|
| Bernoulli \((p)\) | \(1-p+pe^t\) | \(p\) | \(p(1-p)\) | All real \(t\) |
| Binomial \((n,p)\) | \((1-p+pe^t)^n\) | \(np\) | \(np(1-p)\) | All real \(t\) |
| Poisson \((\lambda)\) | \(\exp(\lambda(e^t-1))\) | \(\lambda\) | \(\lambda\) | All real \(t\) |
| Geometric \((p)\), support \(1,2,3,\ldots\) | \(\frac{pe^t}{1-(1-p)e^t}\) | \(\frac{1}{p}\) | \(\frac{1-p}{p^2}\) | \(t<-\ln(1-p)\) when \(0<p<1\) |
| Normal \((\mu,\sigma)\) | \(\exp\left(\mu t+\frac{\sigma^2t^2}{2}\right)\) | \(\mu\) | \(\sigma^2\) | All real \(t\) |
| Exponential rate \(\lambda\) | \(\frac{\lambda}{\lambda-t}\) | \(\frac{1}{\lambda}\) | \(\frac{1}{\lambda^2}\) | \(t<\lambda\) |
| Gamma shape \(\alpha\), rate \(\beta\) | \(\left(\frac{\beta}{\beta-t}\right)^\alpha\) | \(\frac{\alpha}{\beta}\) | \(\frac{\alpha}{\beta^2}\) | \(t<\beta\) |
| Uniform \((a,b)\) | \(\frac{e^{bt}-e^{at}}{(b-a)t}\), with \(M_X(0)=1\) | \(\frac{a+b}{2}\) | \(\frac{(b-a)^2}{12}\) | All real \(t\) |
For the geometric distribution, if \(p=1\), all probability is concentrated at \(X=1\), so the MGF reduces to \(e^t\) and is finite for all real \(t\).
For the uniform distribution, the displayed formula has a removable issue at \(t=0\) because it contains \(t\) in the denominator. The correct value is still:
Examples of Moment-Generating Functions in Practice
Example 1: Bernoulli MGF and the Mean
Suppose \(X\) follows a Bernoulli distribution with success probability \(p=0.4\). The MGF is:
Substitute \(p=0.4\):
To find the mean, differentiate:
Evaluate at \(t=0\):
So the mean is:
If you evaluate the MGF at \(t=0.5\), you get:
That number is the MGF value at \(t=0.5\), not the mean and not a raw moment by itself. The moment comes from the derivative at zero.
Example 2: Exponential Mean and Variance from the MGF
Suppose \(X\) follows an exponential distribution with rate \(\lambda=2\). Its MGF is:
The first derivative is:
So the mean is:
The second derivative is:
So the second raw moment is:
Then the variance is:
Example 3: A Domain Edge Case
For a gamma distribution with shape \(\alpha=2\) and rate \(\beta=3\), the MGF is:
This MGF is finite only for:
A value such as \(t=2.5\) is inside the domain, but \(t=3\) is not. At \(t=3\), the denominator becomes zero:
So the MGF is not finite there. This is why checking the domain is part of interpreting an MGF result.
How to Interpret the Result
The result has several parts, and each part answers a different question.
MGF formula shows the closed-form moment-generating function for the selected distribution and parameters. This is the main mathematical object being evaluated.
Domain tells which values of \(t\) are allowed. If \(t\) is outside the domain, the MGF is not finite there, so the value should not be interpreted.
Mean is the expected value of the selected distribution. It has the same scale as the random variable \(X\).
Variance measures spread around the mean. Its unit is the square of the unit of \(X\).
\(M(t)\) is the value of the MGF at the entered \(t\). It is not the same thing as the requested raw moment unless it is connected to derivatives at \(t=0\).
Raw moment is the calculator’s analytically evaluated value of \(E[X^r]\) for the selected moment order. The mathematical definition is:
PMF or PDF chart shows the shape of the selected probability distribution. For discrete distributions, the graph shows probability mass. For continuous distributions, it shows density. The graph is not an MGF curve.
Common Mistakes and Misconceptions
Confusing \(M(t)\) with a moment. The value \(M(t)\) is the MGF evaluated at one input. A raw moment comes from a derivative of the MGF at \(t=0\).
Ignoring the domain of \(t\). Exponential, gamma, and geometric MGFs have upper limits on allowed \(t\) values. Values at or beyond the boundary are not valid.
Using the wrong gamma parameterization. This calculator uses the gamma rate parameter \(\beta\). If your textbook uses scale \(\theta\), then \(\beta=\frac{1}{\theta}\).
Assuming the geometric distribution starts at zero. The geometric model used here is the number of trials until the first success, so its support is \(1,2,3,\ldots\).
Expecting the chart to show the MGF. The chart shows the PMF or PDF of the distribution, not \(M_X(t)\) as a function of \(t\).
Entering a fractional moment order. This calculator evaluates the closed-form raw-moment formulas for integer orders (1) through (6); it rejects fractional or out-of-range orders instead of rounding them.
Rounding too early. If you use displayed values in later calculations, rounding can change the final answer. Keep extra precision when doing follow-up work.
When to Use Moment-Generating Functions
Use MGFs when you want to:
- Find or verify a mean, variance, or raw moment.
- Understand how a distribution’s parameters affect its moments.
- Compare common probability distributions.
- Identify a distribution from a known MGF.
- Study sums of independent random variables.
- Check homework or teaching examples involving common distributions.
- Connect probability formulas with differentiation and Taylor series.
MGFs are most useful when the distribution has a clean closed form and the MGF exists around \(t=0\). For empirical data analysis, simulation, or complex custom models, other tools may be more appropriate.
Limitations and Things to Keep in Mind
Not every probability distribution has an MGF in the usual sense. The MGF must be finite on an interval around \(t=0\). If it is not finite there, the derivative method does not apply in the standard way.
This calculator supports Bernoulli, binomial, Poisson, geometric, normal, exponential, gamma, and uniform distributions. It does not accept a custom PMF, PDF, or data sample.
The exponential and gamma distributions use rate parameters, not scale parameters. This is important because rate and scale are reciprocals.
The geometric distribution uses support starting at \(1\), meaning \(X\) counts the trial on which the first success occurs. A different convention, with support starting at \(0\), has a different MGF and mean.
The requested moment order is treated as an integer from \(1\) through \(6\). Fractional, zero, negative, and higher-order requests are not directly supported.
For every supported distribution and moment order from \(1\) through \(6\), raw moments use a distribution-specific analytic formula rather than finite-difference differentiation. Uniform moments use stable polynomial identities when the bounds are close together.
Displayed numeric values use up to 8 significant digits. Values with absolute value below \(10^{-10}\) may display as 0, and very large or non-finite values may not produce a usable number.
For infinite-support distributions such as Poisson and geometric, a chart can only show a finite visible range. The unseen tail may still contain probability mass.
For statistical work that affects grades, research conclusions, engineering decisions, finance, health, safety, legal obligations, or official records, double-check the result with the formulas, your course convention, and a qualified instructor or professional when appropriate.
How to Use This Calculator
- Select one of the supported distributions: Bernoulli, binomial, Poisson, geometric, normal, exponential, gamma, or uniform.
- Enter the parameters for that distribution, such as \(p\), \(n\), \(\lambda\), \(\mu\), \(\sigma\), \(\alpha\), \(\beta\), \(a\), or \(b\).
- Enter the moment order you want to estimate. The supported range is \(1\) through \(6\).
- Enter the value of \(t\) where you want to evaluate \(M(t)\).
- Check the domain result to make sure the selected \(t\) value is valid.
- Review the MGF formula, mean, variance, and \(M(t)\) value.
- Use the calculation steps to understand how derivatives at \(t=0\) relate to raw moments.
- Use the PMF or PDF chart to inspect the shape of the selected distribution.
Frequently Asked Questions
What does an MGF tell you?
An MGF summarizes a distribution through the expected value \(E[e^{tX}]\). When it exists near \(t=0\), its derivatives at zero give the raw moments of the distribution. It can also help identify distributions and work with sums of independent random variables.
Is \(M(t)\) the same as the mean?
No. The mean is \(M_X'(0)\), the first derivative of the MGF evaluated at zero. The displayed \(M(t)\) value is the MGF evaluated at the entered \(t\) value.
Why are some \(t\) values not allowed?
Some MGFs are finite only for certain values of \(t\). For example, the exponential MGF \(\frac{\lambda}{\lambda-t}\) is finite only when \(t<\lambda\). If \(t\) is outside the domain, the MGF value is not meaningful.
Why does the geometric distribution start at 1 here?
This calculator uses the convention where a geometric random variable counts the number of trials until the first success. Under that convention, the possible values are \(1,2,3,\ldots\). A convention that counts failures before the first success starts at \(0\) and uses different formulas.
What is the difference between gamma rate and gamma scale?
Rate and scale are reciprocal parameterizations. If the rate is \(\beta\), the scale is \(\theta=\frac{1}{\beta}\). This calculator uses the rate form, so the gamma MGF is \(\left(\frac{\beta}{\beta-t}\right)^\alpha\).
How are raw moments calculated?
The raw moment is mathematically \(M_X^{(r)}(0)\). For the supported distributions, the calculator evaluates the corresponding distribution-specific analytic formula for orders \(1\) through \(6\); it does not approximate derivatives with finite differences.
Why is \(M(0)=1\)?
At \(t=0\), the expression inside the expectation is \(e^{0X}=1\). Therefore:
This is true for any valid MGF.
Sources and References
Books and Textbooks
- Hossein Pishro-Nik. Introduction to Probability, Statistics, and Random Processes. Kappa Research, 2014. Section 6.1.3, “Moment Generating Functions.” https://www.probabilitycourse.com/chapter6/613momentfunctions.php
- Joseph K. Blitzstein and Jessica Hwang. Introduction to Probability. 2nd ed., Chapman & Hall/CRC, 2019. Chapter 6, “Moments,” including moment-generating functions and generating moments with MGFs. Publisher listing: https://www.routledge.com/Introduction-to-Probability-Second-Edition/Blitzstein-Hwang/p/book/9781138369917
Online and Official Sources
- Penn State Department of Statistics. “9 Moment Generating Functions.” STAT 414: Introduction to Probability Theory. Accessed July 4, 2026. https://online.stat.psu.edu/stat414/Lesson09
- Penn State Department of Statistics. “14 Continuous Random Variables.” STAT 414: Introduction to Probability Theory. Accessed July 4, 2026. https://online.stat.psu.edu/stat414/Lesson14
- Penn State Department of Statistics. “15 Exponential, Gamma and Chi-Square Distributions.” STAT 414: Introduction to Probability Theory. Accessed July 4, 2026. https://online.stat.psu.edu/stat414/Lesson15
- Penn State Department of Statistics. “16 Normal Distributions.” STAT 414: Introduction to Probability Theory. Accessed July 4, 2026. https://online.stat.psu.edu/stat414/Lesson16
- Eric W. Weisstein. “Gamma Distribution.” MathWorld—A Wolfram Resource. Accessed July 4, 2026. https://mathworld.wolfram.com/GammaDistribution.html