Hoeffding Inequality

Download as PDF

Have you ever wondered how pollsters can predict an election by asking just a few thousand people? Or how a chef knows a giant pot of soup is seasoned correctly after tasting one spoonful? They rely on a key idea from statistics, and Hoeffding's Inequality gives us a mathematical guarantee for it.

Hoeffding Inequality — an original Algebra911 reference diagram defining hoeffding inequality and a worked example.
Hoeffding's Inequality: A Guide to Guessing Smart

What Is Hoeffding's Inequality?

Hoeffding's Inequality is a rule in probability that gives us an upper limit on how likely it is that the average of a random sample will be far away from the true average of the entire population. In simpler terms, it provides a mathematical guarantee that if you take enough samples of something, your sample average will be very close to the real average. It's a tool that helps us measure our confidence when we use a small sample to make a guess about a very large group.

Imagine you have a massive jar with millions of red and blue marbles. You want to know the exact percentage of red marbles, but you can't count them all. So, you pull out a random sample of 100 marbles. Let's say you get 58 red ones, so your sample average is 58%. Hoeffding's Inequality helps you answer the question: What is the maximum probability that the true percentage for the whole jar is actually more than, say, 65%? It gives you a worst-case scenario, telling you that the probability of your sample being that misleadingly high is less than some specific number.

What Are the Key Ingredients for Hoeffding's Inequality?

To use this powerful tool, our data needs to have a few special properties. Think of these as the ingredients in a recipe. If you're missing one, the recipe won't work.

  1. Independent Random Variables: This is the most important ingredient. Each piece of data you collect must be independent, meaning the outcome of one doesn't affect the outcome of another. Flipping a coin multiple times is a perfect example; the result of the first flip has no impact on the second. In our marble example, we would need to put each marble back after drawing it to ensure the probabilities don't change and the draws stay independent.
  2. Bounded Variables: Each of your random variables must be 'bounded,' which means they have a defined minimum and maximum value. For example, if we assign a value of 1 to flipping a 'Head' and 0 to a 'Tail', the values are bounded between 0 and 1. Test scores are often bounded between 0 and 100. This is crucial because the inequality needs to know the maximum possible range of your data.
  3. Sample Size (n): This is simply the number of times you collect data. In our marble example, the sample size was n=100. As we'll see, a larger sample size makes our estimates much more reliable.
  4. Deviation or Error (t): This is the 'error margin' you are concerned about. It's the distance between your sample average and the true average that you want to test. For example, if your sample average is 58%, you might want to know the probability that the true average is more than 5% away from that, so t=0.05.

How Does the Hoeffding's Inequality Formula Work?

The formula itself might look a little intimidating, but let's break it down piece by piece. There are two main versions: a one-sided version and a two-sided version.

Let's say X¯ is the average of our sample, and μ is the true average of the whole population. The one-sided version tells us the probability that our sample average is too high by at least an amount t:

P(\bar{X} - \mu \ge t) \le e^{-2nt^2 / (b-a)^2}

Let's decode the symbols:

  • P(...) stands for 'the probability of the event in the parentheses'.
  • X¯ is our calculated sample average.
  • μ (the Greek letter 'mu') is the true population average we're trying to estimate.
  • t is the error threshold we care about.
  • e is Euler's number, a special constant in math approximately equal to 2.718.
  • n is our sample size.
  • a and b are the lower and upper bounds of our data. The term (ba) is the range of a single data point.

Often, we don't care if the error is high or low; we just care if it's far away from the true value. This is where the two-sided version comes in. It tells us the probability that the absolute difference between our sample average and the true average is at least t.

P(|\bar{X} - \mu| \ge t) \le 2e^{-2nt^2 / (b-a)^2}

Notice it's almost the same formula! We just put a '2' in front because we are now considering the probability of being too high OR too low. The vertical bars |...| mean 'absolute value', which measures distance from zero, ignoring positive or negative signs.

Let's Solve Some Problems! (Worked Examples)

The best way to understand Hoeffding's Inequality is to see it in action.

Example 1

You flip a fair coin 100 times. A fair coin should land on heads 50% of the time, so the true mean μ is 0.5. What is the maximum probability that you get 65 or more heads?

Solution:

  1. Identify the variables:
    We can represent heads as 1 and tails as 0. So, our data is bounded by a=0 and b=1.
    The sample size is n=100.
    The true mean is μ=0.5.
    Getting 65 heads out of 100 means our sample average is X¯=65/100=0.65.
    The deviation we're interested in is t=X¯μ=0.650.5=0.15.
  2. Choose the right formula:
    We want to know the probability of the average being at least 0.65, so we use the one-sided formula: P(X¯μt)e2nt2/(ba)2.
  3. Plug in the numbers and calculate:
    P(X¯0.50.15)e2(100)(0.15)2/(10)2
    e2(100)(0.0225)/12
    e4.5
    0.0111

Conclusion: The probability of getting 65 or more heads in 100 flips of a fair coin is at most about 1.11%. The actual probability is even lower, but Hoeffding's gives us a guaranteed upper limit.

Example 2

A factory produces light bulbs. The bulbs are designed to work for at least 3000 hours and at most 5000 hours. The factory manager doesn't know the true average lifespan. She tests a random sample of 200 bulbs and finds their average lifespan is 4100 hours. What is the probability that the true average lifespan for all bulbs is actually more than 100 hours away (higher or lower) from her sample's average?

Solution:

  1. Identify the variables:
    The data is bounded by a=3000 and b=5000. The range is ba=2000.
    The sample size is n=200.
    We don't know the true mean μ, but we are testing the difference from our sample mean X¯=4100.
    The deviation we care about is t=100 hours.
  2. Choose the right formula:
    We want to know the probability of the error being in either direction (more than 100 hours away), so we use the two-sided formula: P(|X¯μ|t)2e2nt2/(ba)2.
  3. Plug in the numbers and calculate:
    P(|X¯μ|100)2e2(200)(100)2/(2000)2
    2e2(200)(10000)/4000000
    2e4000000/4000000
    2e1
    2(0.3679)0.7358

Conclusion: There is at most a 73.58% chance that the true average lifespan is more than 100 hours different from the 4100 hours found in the sample. This bound is quite high, suggesting we might need a larger sample for more precision.

Example 3

A political polling agency wants to estimate the proportion of voters who favor a certain policy. They want to be confident that their poll result is within 3% of the true proportion. How many people do they need to survey to guarantee that the probability of their error being larger than 3% (t=0.03) is less than 5% (0.05)?

Solution: This is a different kind of problem! We are given the probability we want, and we have to find the sample size n.

  1. Identify the variables:
    A voter's choice can be represented as 1 (favors) or 0 (does not). So, the bounds are a=0 and b=1.
    The deviation is t=0.03.
    The desired maximum probability is 0.05.
    The sample size n is what we need to find.
  2. Set up the inequality:
    We are concerned about error in either direction, so we use the two-sided formula. We want the bound to be less than or equal to 0.05.
    2e2nt2/(ba)20.05
    2e2n(0.03)2/(10)20.05
  3. Solve for n:
    2e2n(0.0009)0.05
    e0.0018n0.025
    To solve for n in the exponent, we take the natural logarithm (ln) of both sides.
    ln(e0.0018n)ln(0.025)
    0.0018n3.6888
    Now, we divide by 0.0018. Remember to flip the inequality sign when multiplying or dividing by a negative number!
    n3.68880.0018
    n2049.33

Conclusion: Since we can't survey a fraction of a person, we must round up. The agency needs to survey at least 2050 people to achieve their desired level of confidence.

How Does Sample Size Change Everything?

One of the most important lessons from Hoeffding's Inequality is the power of collecting more data. The sample size, n, is in the exponent of the formula. This means that as n gets bigger, the probability bound gets smaller very quickly. A larger sample size dramatically reduces the maximum chance that your sample average is misleading.

Let's use the polling example from before, where we wanted to know the probability of our poll being off by more than 3% (t=0.03). Let's see how the probability bound changes as we increase our sample size n.

Sample Size (n)Hoeffding Bound: P(|X¯μ|0.03)...Interpretation
1002e2(100)(0.03)2=2e0.181.67A useless bound! It's greater than 1. This sample size is too small to guarantee anything useful.
5002e2(500)(0.03)2=2e0.90.81Still a very high bound. We can't be very confident in our result.
10002e2(1000)(0.03)2=2e1.80.33Now we're getting somewhere. There's at most a 33% chance our poll is off by more than 3%.
20502e2(2050)(0.03)2=2e3.690.05This is the number we calculated in Example 3. We have a guarantee the probability of a large error is less than 5%.
50002e2(5000)(0.03)2=2e90.00025With a very large sample, the chance of our result being significantly off becomes incredibly small.

This table clearly shows the relationship: more data leads to more certainty. This is the fundamental principle behind all scientific experiments and surveys.

Common Mistakes to Avoid

  • Forgetting the Bounds: Hoeffding's Inequality only works for random variables that have a clear minimum (a) and maximum (b). If your data could theoretically be any number, you can't apply this formula directly.
  • Assuming Independence: The formula breaks down if your data points are not independent. For example, if you measure the daily stock price, today's price is likely related to yesterday's price. These are not independent, so Hoeffding's would not apply.
  • Misinterpreting the Result: The inequality gives you an upper bound, not the exact probability. The true probability of a large error is often much smaller than the Hoeffding bound. The bound is a worst-case guarantee, which is what makes it so useful, but it's not always a tight estimate.
  • Mixing Up One-Sided and Two-Sided Formulas: Be careful to use the two-sided formula (with the 2 in front) when you care about errors in either direction (e.g., 'different from by more than 5'). Use the one-sided formula when you only care about an error in one specific direction (e.g., 'at least 5 more than').
  • Calculation Errors: The formula involves exponents and decimals, so it's easy to make a small mistake. Double-check your calculations, especially when squaring t and calculating the final value with e.

Quick Summary and Reference

Here are the key takeaways for Hoeffding's Inequality:

  • What it is: A mathematical tool that provides a guaranteed upper limit on the probability that a sample average is far from the true population average.
  • What it needs: A set of independent and bounded random variables.
  • The Core Idea: The more data you collect (larger n), the smaller the probability that your sample average is misleading.
  • The Main Formulas:
    One-Sided (e.g., sample is too high):
    P(X¯μt)e2nt2/(ba)2
    Two-Sided (e.g., sample is too high OR too low):
    P(|X¯μ|t)2e2nt2/(ba)2

Frequently Asked Questions

Is Hoeffding's Inequality always accurate?

It's not about being accurate in the way an exact calculation is. It provides a 'bound,' which is a guaranteed maximum probability. The true probability is always less than or equal to the Hoeffding bound, so in that sense, it is always a correct, conservative statement.

What does 'bounded' mean in simple terms?

Bounded means that the possible values of your data have a definite minimum and a definite maximum. For example, a test score is bounded between 0 and 100. A person's age in years is bounded between 0 and perhaps 130.

Why is the letter 'e' in the formula?

The letter 'e' (Euler's number) is a special mathematical constant that shows up naturally in processes involving growth and probability. Its appearance in this formula comes from the advanced mathematical proof used to derive the inequality, which is related to exponential functions.

What's the difference between this and the Central Limit Theorem?

The Central Limit Theorem (CLT) says that for large samples, the distribution of sample averages will look like a bell curve. Hoeffding's Inequality makes no assumption about the shape of the distribution. It gives a probability bound that works for any distribution and any sample size, large or small, as long as the data is bounded.

Can I use this for my school science project?

Yes, absolutely! If your project involves repeated, independent trials (like testing different fertilizers on 10 separate plants each), you can use Hoeffding's Inequality to make a strong statement about how confident you are that your observed results are close to the true effects.

Why is the bound sometimes a number greater than 1?

If your sample size is too small for the error margin you're testing, the formula can produce a number larger than 1. This doesn't mean the probability is over 100%. It simply means the bound is not 'informative' or useful in that specific case; it's too loose to tell you anything meaningful.

Who was Wassily Hoeffding?

Wassily Hoeffding was a highly influential statistician and probabilist who was born in Finland and later worked in the United States. He published this famous inequality in 1963, and it has become a fundamental tool in statistics, machine learning, and computer science.