Moment Generating Function Calculator for a Geometric Random Variable
Use this premium calculator to compute the moment generating function, check the valid domain for t, and visualize how the MGF changes for a geometric distribution under either common support convention.
Calculator Inputs
Results
Awaiting calculation
Enter p, choose a geometric convention, and click Calculate MGF to see the formula, numerical value, domain restriction, mean, and variance.
MGF Visualization
The chart plots M(t) across a safe interval below the convergence boundary.
How to calculate the moment generating function of a geometric random variable
The moment generating function, usually abbreviated as MGF, is one of the most useful tools in probability theory because it packages the entire distribution into a single function of a real variable t. For a random variable X, the MGF is defined as MX(t) = E[etX] whenever that expectation exists in a neighborhood of 0. When you are working with a geometric random variable, the MGF is especially elegant because the defining sum becomes a geometric series. That is exactly why this distribution is often one of the first examples used in undergraduate probability courses.
The geometric distribution models repeated independent Bernoulli trials with success probability p, where each trial has only two outcomes: success with probability p and failure with probability 1 – p. The random variable records how long we wait until the first success. However, there are two standard conventions, and they matter a great deal when calculating the MGF:
- Convention 1: X is the number of trials until the first success, so X takes values 1, 2, 3, …
- Convention 2: Y is the number of failures before the first success, so Y takes values 0, 1, 2, …
These two versions are almost the same, but not identical. In fact, X = Y + 1. Because the MGF depends on the exact support, the resulting formulas differ by a factor of et. If you mix up the conventions, your answer will be off even if your algebra is perfect. This calculator makes the distinction explicit so you can compute the correct formula every time.
Step by step derivation for X = number of trials until first success
Suppose X has the geometric distribution on 1, 2, 3, … with success probability p. Then the probability mass function is
By definition, the moment generating function is
Factor out p et and rewrite the remaining series:
This is valid only when the geometric series converges. The ratio is (1 – p)et, so convergence requires
That domain restriction is essential. The MGF is not finite for t values at or beyond the boundary. A common mistake is to write down the closed form but forget to state the interval where it actually exists.
Step by step derivation for Y = number of failures before first success
If Y is the number of failures before the first success, then Y takes values 0, 1, 2, … and the probability mass function becomes
The MGF is
Again, this formula works only when t < -ln(1 – p). Notice that MX(t) = et MY(t), which is exactly what we should expect since X = Y + 1.
Why the MGF matters
The MGF does more than provide an elegant closed form. It gives direct access to moments. If an MGF exists around t = 0, then derivatives of the MGF at 0 recover the moments of the distribution. In principle,
For the geometric distribution, this means you can derive the mean and variance from the MGF rather than memorizing them in isolation. For X on 1, 2, 3, …,
- E[X] = 1 / p
- Var(X) = (1 – p) / p2
For Y on 0, 1, 2, …,
- E[Y] = (1 – p) / p
- Var(Y) = (1 – p) / p2
The variance is the same under both conventions because adding 1 shifts the distribution without changing its spread.
Interpretation of the convergence boundary
The term t < -ln(1 – p) may look abstract at first, but it has a practical interpretation. The larger p is, the more quickly the geometric probabilities decay, so the MGF remains finite over a wider positive interval of t. Conversely, when p is small, the tail is heavier, so the MGF blows up sooner as t increases. That is why the convergence boundary expands as success becomes more likely.
| Success probability p | Mean for trials version E[X] = 1/p | Variance (both conventions) | Boundary for t, -ln(1 – p) | Interpretation |
|---|---|---|---|---|
| 0.10 | 10.0000 | 90.0000 | 0.1054 | Rare success, long waiting times, narrow positive t domain |
| 0.25 | 4.0000 | 12.0000 | 0.2877 | Moderate waiting time with visibly heavier tail |
| 0.50 | 2.0000 | 2.0000 | 0.6931 | Balanced success chance, much wider convergence range |
| 0.80 | 1.2500 | 0.3125 | 1.6094 | Fast success, concentrated distribution, broad positive t domain |
These are real computed statistics from the exact formulas. They illustrate a key pattern: as p increases from 0.10 to 0.80, the expected waiting time drops sharply and the allowed range for positive t expands dramatically. This relationship is visible in the calculator chart, which rises more gently for larger p because the waiting time distribution is less spread out.
Common mistakes students make
- Using the wrong support convention. This is the most frequent error. Always check whether the random variable starts at 0 or 1.
- Dropping the convergence condition. The formula is incomplete without the condition t < -ln(1 – p).
- Confusing the MGF with the probability generating function. The PGF uses sX, while the MGF uses etX.
- Incorrectly indexing the sum. For the trials version, the sum starts at k = 1; for the failures version, it starts at k = 0.
- Forgetting that p must satisfy 0 < p < 1. The geometric law is not meaningful at the endpoints.
Comparison of the two geometric conventions
| Feature | Trials until first success | Failures before first success |
|---|---|---|
| Support | 1, 2, 3, … | 0, 1, 2, … |
| PMF | P(X = k) = (1 – p)^(k – 1)p | P(Y = k) = (1 – p)^k p |
| MGF | p e^t / [1 – (1 – p)e^t] | p / [1 – (1 – p)e^t] |
| Mean | 1/p | (1 – p)/p |
| Variance | (1 – p)/p^2 | (1 – p)/p^2 |
| Relationship | X = Y + 1, so MX(t) = e^t MY(t) | |
Worked numerical example
Suppose p = 0.35 and you define X as the number of trials until the first success. Then the MGF is
If you want the MGF at t = 0.2, substitute directly:
This tells you the expected value of e0.2X. While that may not sound intuitive at first, it becomes powerful when deriving moments, proving distributional identities, and studying sums of independent random variables.
Relationship to the memoryless property
The geometric distribution is the only discrete distribution with the memoryless property:
This property says that after surviving m failures, the future waiting time behaves as though the process is starting fresh. While the MGF itself is not the memoryless property, the clean rational form of the MGF reflects the same structural simplicity. Both facts emerge from the repeated multiplication by 1 – p from one trial to the next.
How to use this calculator effectively
- Enter a valid success probability p between 0 and 1.
- Choose whether your random variable counts trials or failures.
- Enter a value of t you want to evaluate.
- Click the Calculate button to get the symbolic MGF, numerical value, mean, variance, and validity interval.
- Inspect the chart to see how the MGF grows as t approaches the convergence boundary from below.
The chart is especially useful for intuition. Every geometric MGF passes through 1 at t = 0 because M(0) = E[e0X] = 1. As t increases toward the boundary, the denominator approaches zero and the function rises sharply. For negative t, the exponential factor dampens larger values of the random variable, so the MGF falls below 1.
Authoritative references for further study
If you want a deeper treatment of geometric distributions, generating functions, and related probability tools, these references are excellent places to continue:
- Penn State STAT 414 Probability Theory course materials
- NIST Engineering Statistics Handbook
- MIT OpenCourseWare probability and statistics resources