Thursday, September 04, 2025

The Principle Behind the Data: Understand Maximum Likelihood Estimation with Simple Examples

    

Have you ever wondered how statisticians can make statements about an entire population by studying only a small sample? The secret lies in methods such as Maximum Likelihood Estimation—a powerful technique that helps us make the “best guess” about unknown parameters.

What is Statistical Inference?

Statistical inference means obtaining information from a sample and, based on that, drawing conclusions about characteristics of the entire population from which the sample was taken. Among several methods that produce good estimators, today we will focus on the maximum likelihood method.

An Intuitive Example

Imagine a box with many blue and orange balls. You don't know which color is more frequent, but you know there are only two possibilities:

1.   Three blue balls for every orange ball → probability of blue: p = ¾

 


2.   One blue ball for every three orange balls → probability of blue: p = ¼

 

Now, you draw 3 balls with replacement and observe how many are blue. How do you decide what the true value of p is? See Table 1. 


Table 1. The Probabilities at Play


Nº of blue balls

p = ¾

p = ¼

0

1/64

27/64

1

9/64

27/64

2

27/64

9/64

3

27/64

 1/64


Figure 1. The Probabilities at Play


 

The strategy is simple: we choose the value of p that makes our observation most likely.

    If 0 or 1 blue ball comes out → we estimate p = ¼

    If 2 or 3 blue balls come out → we estimate p = ¾

You just used the maximum likelihood estimator!


From the Specific Case to the General


In the real world, we rarely have only two options. In an experiment with “success” or “failure” outcomes, we might have a sample like: S, S, F, F, S, F (3 successes in 6 trials).

The intuitive approach would lead us to calculate:

                                                   p̂ = x / n = 3 / 6 = 1/2

This is not only a reasonable choice—it is the maximum likelihood estimate. For n = 6 trials, the value p = ½ makes the observation of x = 3 successes the most likely of all possibilities. See Table 2.

Table 2: Probabilities associated with the occurrence of x successes in samples of size n = 6

P value

 

Number of success

 

0

1

2

3

4

5

6

p = 1/2

0,01563

0,09375

0,23438

0,3125

0,23438

0,09375

0,01563


Figure 2: Probabilities associated with the occurrence of x successes in samples of size n = 6


Why Does This Matter?


The maximum likelihood estimator is:

 Intuitive: It chooses the parameter that maximizes the chance of observing what we actually observe.

    Powerful: It can be applied to many statistical models that are much more complex than the simple binomial example.

  Consistent: With large samples, it tends to converge to the true value of the population parameter.

    Versatile: It forms the basis for a large number of modern statistical techniques used in data science, machine learning, and scientific research.

Practical Examples of Maximum Likelihood Estimation

Example 1: Screw Factory Quality Control

In a screw factory, quality control is performed by selecting a sample from each batch and checking how many are non-conforming. Consider that in a batch of 500 screws, 38 non-conforming ones were found.

·  What is the maximum likelihood estimator for the proportion of non-conforming screws?

·  What is the estimate obtained for this specific batch?

Solution:
The maximum likelihood estimator (MLE) for a proportion 
p in a binomial distribution is the sample proportion itself, given by the formula p̂ = x / n, where:

·  x is the number of "successes" (in this context, finding a non-conforming screw).

·  n is the sample size.

For this batch:

·  x = 38 (non-conforming screws)

·  n = 500 (total screws in the sample)

The estimate is therefore:
p̂ = 38 / 500 = 0.076 or 7.6%

Conclusion: The maximum likelihood estimate for the proportion of non-conforming screws in the batch is 7.6%.


Example 2: Election Poll (Corrected Version)

Election polls are an attempt to capture voters' intentions at a specific moment by conducting a limited number of interviews. It is, therefore, an effort to measure the whole from a part. Imagine a polling institute conducted a preliminary election poll for mayor in a specific municipality. There were two candidates, which we will call A and B.

500 voters were interviewed, yielding the following results:

·  220 votes would be for candidate A

·  180 votes would be for candidate B

·  The remaining voters were undecided.

a) What is the maximum likelihood estimate for the proportion of undecided voters in the population?
b) What is the maximum likelihood estimate for the proportion of votes for candidate A?

Solution:
The same principle applies. The MLE for a population proportion 
p is the sample proportion p̂ = x / n.

a) Proportion of Undecided Voters:

·  Number of undecided voters in sample (x): 500 - 220 - 180 = 100

·  Sample size (n): 500

·  Estimate: p̂_undecided = 100 / 500 = 0.20 or 20%

b) Proportion of Votes for Candidate A:

·  Number of votes for A in sample (x): 220

·  Sample size (n): 500

·  Estimate: p̂_A = 220 / 500 = 0.44 or 44%

Conclusion: Based on this sample, the maximum likelihood estimates are a 20% proportion of undecided voters and a 44% vote proportion for candidate A in the broader population.


Wednesday, September 03, 2025

O Princípio por Trás dos Dados: Entenda a Estimação por Máxima Verossimilhança com Exemplos Simples

 

Você já se perguntou como os estatísticos conseguem fazer afirmações sobre toda uma população estudando apenas uma pequena amostra? O segredo está em métodos como a Estimação por Máxima Verossimilhança - uma técnica poderosa que nos ajuda a fazer o "melhor palpite" sobre parâmetros desconhecidos.

O que é Inferência Estatística?

A inferência estatística significa obter informações de uma amostra e, com base nela, concluir características de toda a população de onde a amostra foi retirada. Entre vários métodos que produzem bons estimadores, hoje vamos focar no método de máxima verossimilhança.

Um Exemplo Intuitivo:

Imagine uma urna com muitas bolas azuis e laranja. Você não sabe qual cor é mais frequente, mas sabe que só há duas possibilidades:

1.    Três bolas azuis para cada bola laranja → probabilidade de azul (p) = ¾

2.    Uma bola azul para cada três bolas laranja → probabilidade de azul (p) = ¼

Agora, você retira 3 bolas com reposição e observa quantas são azuis. Como decidir qual é o verdadeiro valor de p? Veja a Tabela 1.

Tabela 1. As Probabilidades em Jogo

Nº de bolas azuis

p = ¾

p = ¼

0

1/64

27/64

1

9/64

27/64

2

27/64

9/64

3

27/64

 1/64


Figura 1. As Probabilidades em Jogo


A estratégia é simples: escolhemos o valor de p que torna nossa observação mais provável.

·      Se saírem 0 ou 1 bola azul → estimamos p = ¼

·      Se saírem 2 ou 3 bolas azuis → estimamos p = ¾

Você acabou de usar o estimador de máxima verossimilhança!

Do Caso Específico para o Geral 

No mundo real, raramente temos apenas duas opções. Em um experimento com resultados "sucesso" ou "fracasso", podemos ter uma amostra como: S, S, F, F, S, F (3 sucessos em 6 tentativas).

A abordagem intuitiva nos levaria a calcular:
p̂ = x / n = 3 / 6 = 1/2

Esta não é apenas uma escolha razoável - é a estimativa de máxima verossimilhança. Para n = 6 tentativas, o valor p = ½ torna a observação de x = 3 sucessos a mais provável de todas as possibilidades. Veja a Tabela 2.

Tabela 2: Probabilidades de x sucessos em amostras de tamanho n =6

 

Valor de p

 

Número de sucessos

 

0

1

2

3

4

5

6

p = 1/2

0,01563

0,09375

0,23438

0,3125

0,23438

0,09375

0,01563

 

Figura 2: Probabilidades associadas à ocorrência de x sucessos em amostras de tamanho n =6

 

 

  Por que isso importa?

 O estimador de máxima verossimilhança é:

·         Intuitivo: Escolhe o parâmetro que maximiza a chance de observarmos o que realmente observamos.

·   Poderoso: Pode ser aplicado a diversos modelos estatísticos muito mais complexos que o exemplo binomial simples.

·         Consistente: Com amostras grandes, tende a convergir para o valor verdadeiro do parâmetro populacional.

·      Versátil: Forma a base para uma grande quantidade de técnicas estatísticas modernas usadas em ciência de dados, aprendizado de máquina e pesquisa científica.

Exemplos da vida real

*1. Em uma fábrica de parafusos, o controle de qualidade é feito selecionando-se uma amostra de cada lote e verificando quantos são não conformes. Considere que em um lote de 500 parafusos, foram encontrados 38 não conformes. Qual é o estimador de máxima verossimilhança para a proporção de não conformes? Qual é a estimativa obtida por esse lote?

         Resposta:

·      O Estimador de Máxima Verossimilhança (MLE) para a proporção p em uma distribuição binomial é a própria proporção amostral de sucessos (onde "sucesso" é, neste contexto, encontrar um parafuso não conforme).

·      A fórmula do estimador é: p̂ = x / n

·      A estimativa para este lote específico é calculada plugando os valores da amostra na fórmula do estimador:


                        p̂ = 38 / 500 = 0,076 ou 7,6%

Resposta Final para o Exemplo 1:

O estimador de máxima verossimilhança para a proporção de não conformes é p̂ = x/n. Com base na amostra deste lote (38 não conformes em 500 parafusos), a estimativa pontual para a proporção de não conformes no lote é de 7,6%.

*2. Foram entrevistados 500 eleitores e obtidos os seguintes resultados: 220 votos seriam para o candidato A, 180 votos seriam para o candidato B e os demais eleitores (100 pessoas) estavam indecisos.
a) Qual é a estimativa de máxima verossimilhança para a proporção de eleitores indecisos na população?
b) Qual é a estimativa de máxima verossimilhança para a proporção de votos do candidato A?
Resposta
a) O estimador é 
p̂ = x/n. A estimativa para a proporção de indecisos é p̂(indecisos) = 100 / 500 = 0,20 ou 20%.
b) Da mesma forma, a estimativa para a proporção do candidato A é 
(A) = 220 / 500 = 0,44 ou 44%.

VEJA:


1.  Mood A. M. e Graybill, F. A. Introduction to the theory of statistics. McGraw