Sonia Vieira – Sonia Vieira https://soniavieira.com.br Thu, 13 Feb 2025 20:12:35 +0000 pt-BR hourly 1 https://wordpress.org/?v=6.7.2 https://soniavieira.com.br/wp-content/uploads/2024/11/cropped-abra-o-livro-32x32.png Sonia Vieira – Sonia Vieira https://soniavieira.com.br 32 32 Teorema de Bayes: um exemplo https://soniavieira.com.br/teorema-de-bayes-um-exemplo/ https://soniavieira.com.br/teorema-de-bayes-um-exemplo/#respond Fri, 01 Nov 2024 17:18:00 +0000 A 21 de fevereiro de 2022 publiquei, no meu blog, sob o título de Inferência Bayesiana, um problema que encontrei no extraordinário livro: Kahneman, D. Thinking…fast and slow. Farrar, Straus and Giroux.  2011 p.167 -168.                    

         Problema

Um táxi que causou um acidente de trânsito se evadiu.

Para julgar o caso, são fornecidos os seguintes dados: 85% dos táxis da
cidade são da empresa Verde e 15% da empresa Azul. Uma testemunha que
presenciou o acidente disse que o taxi era da empresa Azul. Essa testemunha foi
colocada em teste e se verificou que nas condições do acidente, acertava a cor
dos táxis 80% das vezes. Qual é a probabilidade de o taxi que causou o acidente
ser da empresa Azul, dado que a testemunha disse que era da Azul?

Solução

Este é um problema clássico de inferência
bayesiana. Há duas fontes de informação: uma estatística populacional e o
relato de uma testemunha não perfeitamente confiável. Essas duas informações
devem ser combinadas usando o teorema de Bayes.

Veja as probabilidades:

  • P(A): Probabilidade de o táxi ser da empresa Azul (0,15).
  • P(V): Probabilidade de o táxi ser da empresa Verde (0,85).
  • P(TA): Probabilidade de a testemunha dizer que o táxi é da empresa Azul dado que o
    táxi é realmente da empresa Azul (0,80).
  • P(TV): Probabilidade de a testemunha dizer que o taxi é da empresa Azul dado que o
    táxi é da empresa Verde (0,20).
  • P(T): Probabilidade de a testemunha dizer que o táxi é da empresa Azul.

Queremos calcular P(AT), que é a
probabilidade de o táxi ser da empresa Azul dado que a testemunha disse que era
da empresa Azul. Usamos a fórmula de Bayes:

Portanto, a probabilidade de o táxi ser da empresa Azul dado que a
testemunha disse que era da empresa Azul é de aproximadamente
41,4%.

 

 

]]>
https://soniavieira.com.br/teorema-de-bayes-um-exemplo/feed/ 0
ESTIMATION: problem set https://soniavieira.com.br/estimation-problem-set/ https://soniavieira.com.br/estimation-problem-set/#respond Sun, 22 Sep 2024 15:11:00 +0000                            SUMMARY

                          Here
you will find five exercises on statistical estimation.

                        To solve them, you need
to understand percentiles, uniform

                        distribution, exponential distribution, and
confidence intervals.

 

 

]]>
https://soniavieira.com.br/estimation-problem-set/feed/ 0
HYPOTHESIS TESTING: PROBLEMS FOR ENGINEERS https://soniavieira.com.br/hypothesis-testing-problems-for-engineers/ https://soniavieira.com.br/hypothesis-testing-problems-for-engineers/#respond Sun, 08 Sep 2024 20:19:00 +0000 SUMMARY       

 Here, you will find six exercises on hypothesis testing.

 To solve them, you need knowledge of the following concepts:

 Normal distribution, Binomial distribution, Hypothesis testing,

 Hypothesis testing when the standard deviation is unknown,

 Level of significance and Power of the test.

 

 

 

Os exercícios aqui apresentados são do livro:

Gibra,I.N. Probability and statistical inference for

scientists and engineers.

 

]]>
https://soniavieira.com.br/hypothesis-testing-problems-for-engineers/feed/ 0
Teste de hipóteses (um parâmetro) https://soniavieira.com.br/teste-de-hipoteses-um-parametro/ https://soniavieira.com.br/teste-de-hipoteses-um-parametro/#respond Mon, 02 Sep 2024 19:11:00 +0000

*****************************************************

RESUMO

Estão aqui apresentados quatro exercícios que exigem conhecimento dos seguintes tópicos: Erro
tipo I. Erro tipo II. Probabilidade de erro tipo I.
Probabilidade
de erro tipo II.
Alfa e
beta. Poder do teste.
Tamanho da amostra para
ter poder do teste com valor especificado.

 

 Os exercícios aqui
apresentados são do livro:

       Gibra, I.N. Probability and statistical inference for
scientists and engineers.

                               

]]>
https://soniavieira.com.br/teste-de-hipoteses-um-parametro/feed/ 0
RUNS TEST OU TESTE DE RUNS OU TESTE DAS SEQUÊNCIAS https://soniavieira.com.br/runs-test-ou-teste-de-runs-ou-teste-das-sequencias/ https://soniavieira.com.br/runs-test-ou-teste-de-runs-ou-teste-das-sequencias/#respond Sat, 17 Aug 2024 13:37:00 +0000  RESUMO

Você encontra aqui: a definição de run ou sequência; o teste de runs para 

verificar se uma sequência de dados é aleatória; o teste de runs para verificar 

a aleatoriedade da amostra; e o procedimento para o teste de runs em uma amostra.

INTRODUÇÃO

]]>
https://soniavieira.com.br/runs-test-ou-teste-de-runs-ou-teste-das-sequencias/feed/ 0
DISTRIBUIÇÃO DE POISSON https://soniavieira.com.br/distribuicao-de-poisson/ https://soniavieira.com.br/distribuicao-de-poisson/#respond Sat, 10 Aug 2024 16:04:00 +0000

RESUMO

 Você encontra aqui: o que é distribuição
de Poisson; função de probabilidade

 da distribuição de Poisson; usos da
distribuição de Poisson; 

média e variância da distribuição;
aproximação da distribuição de Poisson

 pela distribuição normal; aproximação da
distribuição binomial

 pela distribuição de Poisson; aditividade da distribuição de Poisson.

 

INTRODUÇÃO

 

 

 

 

 

]]>
https://soniavieira.com.br/distribuicao-de-poisson/feed/ 0
Lema de Neyman-Pearson https://soniavieira.com.br/lema-de-neyman-pearson/ https://soniavieira.com.br/lema-de-neyman-pearson/#respond Sat, 03 Aug 2024 19:32:00 +0000 RESUMO

 Aqui se explica o que diz o lema
de Neyman-Pearson. 

Para entender, você precisa conhecer os seguintes conceitos:

 hipótese nula; hipótese alternativa; nível de significância; 

poder do teste; teste
de razão de verossimilhanças.


                                                              LEMA DE NEYMAN-PEARSON

 

                                 We love feedback

                                 How would you rate your experience?

                                    

]]>
https://soniavieira.com.br/lema-de-neyman-pearson/feed/ 0
Hypothesis Tests on a Single Standard Deviation https://soniavieira.com.br/hypothesis-tests-on-a-single-standard-deviation/ https://soniavieira.com.br/hypothesis-tests-on-a-single-standard-deviation/#respond Fri, 12 Jul 2024 22:13:00 +0000 Chi-square
distribution

 

If Z
is a random variable with a standardized normal distribution (mean zero and
variance 1), then Z2 has a chi-square distribution with 1
degree of freedom. If Z1, Z2, ……, Zk,
are a set of independent and identically distributed standard normal variables,
then the sum of their squares has a chi-square distribution with k
degrees of freedom. 

 

NOTE: Let Xi be independent
and normally distributed random variables with mean µ and
variance 1. 
Then
(Xi – µ) has mean zero and 
has
a chi-square distribution with k degrees of freedom.

 

EXAMPLES

 

1) Car
speed is measured using a radar unit. In an urban area, t
he radar readings Xi are
normally distributed with a mean of 25 mph and a standard deviation of 3 mph.
A recent
source claims that the standard deviation of his radar is 1. Imagine your manager
wishes to test the hypothesis H0: σ = 1 versus the
alternative hypothesis H1: σ ≠ 1. To carry out this test,
your manager has asked you to take five speed measurements using a test car
that was programmed to travel at 25 mph. This was done and the speed
measurements you recorded were 25, 24, 27, 25, 26.
Should the hypothesis H0: σ = 1 be rejected at the
significance level α = 10%?  

Let's calculate the variance of X: 
 
The variance is

and the standard deviation is

                                          

You’ve found out that
the sum of squared deviations,
Σ (Xi)2 equals 6.
For a significance test
at
α = 10% and 5 degrees of freedom you
will find in a chi-square distribution table:

 


The calculated value of 6 is inside the acceptance region. H0: σ = 1 cannot be rejected.

 

2)  Your manager was not pleased since he doubts that sigma can be less than 3. As a result, he
insisted
you should take a new
sample to test the null hypothesis
H0:
σ = 1 against the alternative
hypothesis H1: σ ≠ 1. What should you do? Obtain five
new speed measurements using the same test car set to 25 mph, in the same
conditions. Suppose the recorded speeds were 28, 27, 30, 28, 29. T
he hypothesis H0: σ
= 1 should be rejected at the significance level
α = 10%?  

 

Let’s
calculate the variance of X:

 

                 

 

 

You found out that
the sum of squared deviations,
Σ (Xi)2 equals 63. For a significance test
at
α = 10% and 5 degrees of freedom you
will find in a chi-square distribution table:

 

Since Σ (X- µ)2= 63 >11.07, the
hypothesis the radar has standard deviation σ =1 was rejected at the 10%
significance level. You have two samples and two different conclusions.

 

In
fact,
these two examples illustrate how random sampling
variability can lead to different conclusions when testing a hypothesis with
samples of the same size and the same significance level, from the same
population in the same conditions. This occurs because sample statistics are
not perfect estimates of their corresponding population parameters.
 

 

3) But
your manager argued, pointi
ng out that radar readings in urban areas usually
follow a normal distribution with a mean speed of 25 mph and a standard
deviation of 3 mph. He suggests taking another five measurements and test again
the hypotheses H0: σ = 1 against H1: σ ≠ 1.
Following this suggestion, you record five additional speeds: 29, 27, 29, 26,
and 29.  Should the hypothesis H0:
σ = 1 be rejected at a significance level α = 10%?

 

 

 

            

The
numerator of the fraction should fall between 1.145 and 11.07 to support the
hypothesis H0:
σ = 1, but
53 is unquestionably out. Therefore, you must reject the null hypothesis.

Are
you satisfied with your manager’s sugestions?
Perhaps you should look the given examples from a different perspective.
To test H0: σ =1, what
if you use the sample mean instead of the hypothesized mean
µ = 25 mph?
Let’s calculate the sample mean and the sample variance:

              

By using the sample mean, the degrees of freedom are reduced to n – 1. Consequently,
the sum of squared deviations follows a chi-square distribution with 4 degrees
of freedom. Refer to the chi-square table to find the critical values for
α=10
with 4 degrees of freedom.

 

 

.

Given that the sum of squared deviations equals 8 is
less than 9.48, it is reasonable to conclude that
σ = 1 at the 10% significance level, as claimed.

 

If you accept σ = 1, we can look at

 

You’ve made the assumption that the radar readings follow a normal
distribution with a mean
μ = 25 and a standard deviation σ = 1. Then  follow a normal
distribution with a mean
μ = 25 and a standard deviation

 

The random sample of 5 observations you’ve collected has mean  28.  Hence, you are able to test the
hypothesis that the mean of the radar readings is 25 against the alternative
hypothesis that it is greater than 25 using a z-test.

To calculate the z-score, we use the formula

 

 

Given that the z-score is greater than 1.645, you must reject the null hypothesis
that the mean is 25 at 10 % level of significance.

 

Therefore, based on this sample of radar readings (29, 27, 29, 26, 29), it
is reasonable to conclude that the new radar is not calibrated (mean
μ = 25 and a standard deviation σ = 1).

 Now, you could
think: would a radar with σ = 3 produce measurements as above? If σ
= 3, σ2 = 9. How will the numerator of

 

behave? Remember:
chi-square only tell what happens when E(
X-µ)2 =1. But here
E(X-µ)2 =9. What to do?

The
new test statistic is:

  

where s2 comes
from the sample and σ2 comes from H0.
The degrees of freedom associated with the test statistic (for finding the
critical statistic) is (n-1). For this test to be valid, the population must be normally
distributed
. So, calculate

 

The test statistic chi square equals which is in the 95% region of acceptance: [0.4844: 11.1433].
H0 cannot be rejected.

 

 

 

IMPORTANT:
This is an exercise of statistics; it doesn’t tell you radar calibration
procedures. It is therefore useful to have a set of accepted standards and
protocols for maintaining the quality of radars.

 

 

 

]]>
https://soniavieira.com.br/hypothesis-tests-on-a-single-standard-deviation/feed/ 0
Normal distribution: exercises https://soniavieira.com.br/normal-distribution-exercises/ https://soniavieira.com.br/normal-distribution-exercises/#respond Thu, 04 Jul 2024 20:28:00 +0000

The
graphical representation of a normal distribution is a bell-shaped curve that
is symmetrical about the mean. Therefore, half of the values
​​of the random variable X are equal to or
greater than the mean and half are equal to or less than the mean. The curve
encompasses 100% of the population with all possible values
​​that the random variable can assume liyng under the
curve. A normal distribution is defined by two parameters: the mean, denoted by
µ
and the standard deviation, denoted by σ.


Graphical representation of the normal distribution

EXERCISES

1.  
On
a certain road, the speed limit is 40 km/h with a tolerance of 7 km/h. The
speed at which the driver travels on this road varies, with an average speed
μ=40km/h
and a standard deviation
σ = 4 km/h. What is the
probability that the driver will exceed 47 km/h and get a ticket? 
To determine this, we must
standardize the variable (µ = 0, σ =1. Then we can consult a
standardized normal distribution table, typically located at the end of
statistical textbooks.
Calculate:


Tip: You can utilize software to determine probabilities..

2. In regular operation conditions, radar readings is a random variable normally distributed with mean μ = 25 mph and standard deviation σ = 3 mph. To test the calibration of the radar, a test car traveling at 25 mph is used. Assuming the radar is correctly calibrated, i.e., with μ = 25 mph and σ = 3 mph, what is the probability that the radar detects the test car’s speed to be: a) 28 mph or higher? b) 27½ mph or higher? c) At what speed should the radar record for the probability of a value exceeding this speed to be 5%?

    a) Probability of detecting 28 mph or more.

                      b) Probability of detecting 27½ mph or more.

 c) To have a 5% probability of the radar measuring a higher speed.



                                                             Remember that

More control means fewer mistakes. You need to keep this in mind when
you want more quality. Compare the probabilities obtained in examples 2b, 3 and
4.


3.  A calibration test will be carried out on 4 radars that operate together. A test car with a speed set at 25 mph will be used.  Under optimal conditions, the speed of each radar is a random variable following a normal distribution with mean µ=25 mph and standard deviation σ=3mph. If the radars are calibrated, what is the probability that the collected measurements will give an average speed of 27½ mph or higher?


4. The idea of ​​using 4 radars is good; however,
having 9 is
advantageous. Increased control (in this case, through a larger quantity of radars) decreases the risk of error. There are 9
calibrated radars in operation
simultaneously. After calibration, the speed of each radar unit is a normally distributed random variable
with mean µ = 25 mph and standard deviation
σ = 3 mph. Using a test
car
traveling at a constant speed of 25
mph, what is the probability that the
collected measurements will yield
an average speed 27½ mph or higher?


OPERATIONS OF RANDOM VARIABLES

If X and Y are independent random variables with means µ1 and µ2 and variances σ12 and σ22 respectively, then:

Z = X + Y is a random variable with mean µ1 + µ2 and variance σ12 + σ22.

W = X – Y is a random variable with mean µ1µ2 and variance σ12 + σ22.

Var (a Z) = a2 Var (Z)

σ (a Z) = a σ (Z). 

                                             EXERCISE


5. If we consider the subway arrival time as a random variable with mean µ1 = 8h10m and standard deviation σ1 = 40s, and your arrival at the station as a random variable with mean µ2 = 8h08m and standard deviation σ2 =30s, how likely is it that you will miss the train? Let S represent the subway arrival time and Y represent your arrival time at the station. Therefore, W = S – Y, your waiting time, is a random variable with a normal distribution, having an average of 8:10 – 8:08 = 2 m = 120 s, variance of 402 + 302 =1600 + 900 = 2500 s, and a standard deviation of 50. Missing the train would occur if W ≤ 0. To calculate the probability of W ≤ 0:


Decision rule


Set critical values ​​ to reject specific results. This is crucial for quality control.

                                                EXERCISE

6. In
the canning
industry, the pH (the acidity) of the product in each can is a random variable that is normally distributed with mean 7 and standard deviation of 0.5. If the pH of the product falls
below 6.0 or exceeds
8.0, the can is rejected. What is the
probability of this happening?


]]>
https://soniavieira.com.br/normal-distribution-exercises/feed/ 0
Distribuição normal: exercícios com solução https://soniavieira.com.br/exercicios-resolvidos-de-distribuicao-normal/ https://soniavieira.com.br/exercicios-resolvidos-de-distribuicao-normal/#respond Mon, 01 Jul 2024 19:59:00 +0000  

         A representação
gráfica da
distribuição normal é uma curva em formato de sino, simétrica em torno da média. Portanto, metade dos valores da
variável
aleatória X são
iguais ou superiores à média e a outra metade são iguais ou inferiores à média. A curva abriga 100% da
população, ou seja, todos os possíveis valores
que que a variável aleatória
pode assumir estão sob a curva. A
distribuição normal é definida
por dois parâmetros: a média, representada por µ e o desvio padrão, representada
por σ. 

                                   Representação gráfica da distribuição
normal

                                                                            EXERCÍCIOS

 

1.   O limite
de velocidade em uma determinada estrada é de 40
km/h, com tolerância de 7 km/h. A velocidade de um
motorista que viaja nesta estrada é uma variável aleatória
com média μ = 40 km/h e desvio padrão σ = 4 km/h. Qual é a
probabilidade de esse motorista ultrapassar 47 km/h e ser multado? 

 

Vamos
padronizar a variável, que terá então média zero e desvio padrão 1 e procurar a
probabilidade associada a essa variável em uma tabela de distribuição normal padronizada
ou reduzida, encontrada no apêndice da maioria dos livros didáticos de estatística.
Calcule:

 

RESPOSTA:
A probabilidade pedida é 4%.

NOTA:
Você pode achar a probabilidade usando software. 

       2. Em condições normais de operação, a média das medidas feitas por um radar é µ
= 25 mph e o
desvio padrão é σ
= 3 mph
. Um carro de teste com velocidade fixada em 25 mph é normalmente utilizado para verificar se o radar está calibrado. Considerando que o radar está em boas
condições, isto é, que µ = 25 mph e σ = 3 mph, qual é a probabilidade de o
radar atribuir ao carro de teste velocidade: a) 28 mph ou mais? b) 27½ mph ou
mais? c) Qual é a velocidade limite para que a probabilidade de serem medidas velocidades maiores que ela seja 5%?

a)   Probabilidade de
medir 28 mph ou mais
    

 
            RESPOSTA: A probabilidade pedida é de 0,1587, 
aproximadamente 16%.

          

                                b) Probabilidade de medir 27½
mph ou mais


              RESPOSTA:
A
probabilidade pedida é de 0,20327, 

                                       aproximadamente 20%.

 

                     c) Velocidade que delimita 5% de probabilidade de medir 

                          as velocidades maiores

 

                      RESPOSTA: Precisa medir aproximadamente 30 mph.
 
 

LEMBRE-SE
DE QUE

 

Mais
controle significa erros menores. É preciso ter isso em mente quando se quer
mais qualidade. Compare as probabilidades obtidas nos exemplos 2b, 3 e 4.

                                  EXERCÍCIOS

3. Revise o problema anterior. Para testar se 4 radares que operam conjuntamente estão calibrados, é utilizado
um carro de teste com velocidade fixada em 25 mph.  Quando  calibrados, as medições feitas por cada radar
é uma variável aleatória independente com distribuição normal de média µ =25 mph e desvio
padrão σ = 3 mph. Se os radares estiverem em condições normais de trabalho, qual é a probabilidade de a média das medições feitas por eles ser igual ou maior que 27½ mph?

 

 

 
RESPOSTA: A
probabilidade pedida é 5,4%.

4. A ideia de usar 4 radares é
boa, mas usar 9 radares é melhor. Para verificar se 9 radares que operam conjuntamente estão calibrados, é utilizado um carro de teste com velocidade fixada em 25 mph. A velocidade de cada radar, quando calibrado, é uma variável aleatória com
distribuição normal de média µ =25 mph e desvio padrão σ = 3 mph. Qual é a
probabilidade de  a média das medições feitas pelos 9 radares ser igual ou superior a 27½ mph?

 

RESPOSTA: A probabilidade
pedida é 1,24%.

OPERAÇÕES COM VARIÁVEIS ALEATÓRIAS

                                             EXERCÍCIO

5. Supondo que o horário de chegada do metrô seja uma variável aleatória com média µ1 =
8h10min e desvio padrão
σ1 = 40s, e que
a
sua chegada na estação seja uma variável aleatória com média µ2 = 8h08min e desvio padrão σ2 =30s, qual é a probabilidade de você não conseguir pegar
o metrô?

 

Faça M indicar o horário de
chegada do metrô e V indicar seu horário de chegada na estação. Então, W = M – V,
seu tempo de espera, é uma variável aleatória com distribuição
normal de média 8:10 – 8:08 = 2 min = 120 s, variância 402 + 302
=1600 + 900 = 2500 s e desvio padrão 50. 

 

Você não consegue pegar o
trem se W ≤ 0. Para achar a probabilidade de W ≤ 0:

RESPOSTA: A probabilidade pedida é 0,82%.

REGRA DE DECISÃO

Imponha valores críticos para
rejeitar determinados resultados. Em controle da qualidade, isso é essencial.

                                     EXERCÍCIOS

6. Em uma indústria de alimentos enlatados, o nível de acidez (pH) do
produto em cada lata é uma variável aleatória com distribuição normal de média
7 e desvio padrão 0,5. A lata é rejeitada toda vez que o produto apresentar pH inferior a 6,0 ou superior a 8,0.
Qual é a probabilidade de isso
acontecer? 

                      RESPOSTA: A probabilidade pedida é 4,55%.

7. O fabricante de determinado produto alimentício
vendido em pacotes de 3kg quer saber se o peso médio de seu
produto varia significativamente de 3 kg. Se, no nível
de significância de 1%, o peso médio diferir significativamente de 3
kg, o fabricante ajusta a balança. A experiência mostra que o desvio
padrão é 0,03kg. O peso médio de uma amostra aleatória de novas embalagens foi de
2,991 kg. O resultado ajuda decidir se o peso médio do
pacote é significativamente diferente de 3kg?

 

 

                                     RESPOSTA: O peso médio do pacote não difere de 3 kg, significativamente.

 A balança está calibrada (α =1%).

 

 

 

                            

]]>
https://soniavieira.com.br/exercicios-resolvidos-de-distribuicao-normal/feed/ 0