top of page

EXERCÍCIOS DE ESTATÍSTICA

A Questão que criou a Teoria das Probabilidades

In 1654, a time when the Renaissance was in full flower, the Chevalier de Mere, a French nobleman with a taste for both gambling and mathematics, challenged the famed French mathematician Blaise Pascal to solve a puzzle. The question was how to divide the stakes of an unfinished game of chance between two players when one of them is ahead. The puzzle had confounded mathematicians since it was posed some two hundred years earlier by the monk Luca Paccioli. This was the man who brought double-entry bookkeeping to the attention of the business managers of his day---and tutored Leonardo da Vinci in the multiplication tables. Pascal turned for help to Pierre de Fermat, a lawyer who was also a brilliant mathematician. The outcome of their collaboration was intellectual dynamite. What might appear to have been a seventeenth-century version of the game of Trivial Pursuit led to the discovery of the theory of probability, the mathematical heart of the concept of risk.

Peter L. Bernstein, “Against the Gods: The Remarkable Story of Risk”, 1998.

imagem Pascal and Pierre de Fermat.jpg

NETFLIX Film, “NOVA: Prediction By The Numbers”, 2018.

Linda Problem by Kahneman and Tversky

The best-known and most controversial of our experiments involved a fictitious lady called Linda. Amos and I made up the Linda problem to provide conclusive evidence of the role of heuristics in judgment and of their incompatibility with logic. This is how we described Linda:

 

Linda is thirty-one years old, single, outspoken, and very bright. She majored in philosophy. As a student, she was deeply concerned with issues of discrimination and social justice, and also participated in antinuclear demonstrations.

 

Which alternative is more probable?

 

a)Linda is a bank teller.

 

b)Linda is a bank teller and is active in the feminist movement.

 

obs: (Lembrar que aqui eles perguntam a maior probabilidade no sentido de cálculo de probabilidade, conforme a ciência exata da Estatística determina. Não é somente uma ideia subjetiva.)

 

Daniel Kahneman, “Thinking, Fast and Slow”, Farrar, Straus and Giroux, 1st edition (October 1, 2011).

A questão dos 5 times de vôlei

Em uma competição de vôlei, estão inscritos 5 times. Pelo regulamento, todos os times devem se enfrentar apenas uma vez e, ao final da competição, eles serão classificados pelo número de vitórias. Dois ou mais times com o mesmo número de vitórias terão a mesma classificação. Em cada jogo, os times têm probabilidade ½ de vencer.

a) Explique por que 2 times não podem empatar na classificação com 4 vitórias cada um.

b) Qual é a probabilidade de que o primeiro classificado termine a competição com 4 vitórias?

c) Qual é a probabilidade de que os 5 times terminem empatados na classificação?

d) Qual é a probabilidade de que 3 times terminem empatados em primeiro lugar na classificação?

Probabilidade Condicional

1) You are invested in two hedge funds. The probability that hedge fund Alpha generates positive returns in any given year is 60%. The probability that hedge fund Omega generates positive returns in any given year is 70%. Assume the returns are independent. What is the probability that both funds generate positive returns in a given year? What is the probability that both funds lose money?

 

2) There is a 30% chance that oil prices will increase over the next six months. If oil prices increase, there is a 60% chance that the stock market will be down. What is the probability that oil prices increase and the stock market is down over the next six months?

Pequeno Texto sobre Proabilidade Condicional

Função Densidade de Probabilidade
sample-problem.png

Plot a graph, using Python, for the Probability Mass Function (PMF) and for the Probability Distribution Function (PDF) (the name Cumulative Distribution Function (CDF) is also used for the PDF function)

M. B. Miller, “Quantitative Financial Risk Management”, Wiley, 2019

Problema do Ticket Counter
imagem-problema-ticket-counter.png
Simulação de Monte Carlo

a) Use Monte Carlo Simulation to estimate the mean and standard deviation of (X^2), when X follows a Weibull distribution with a=b=1.

 

b) Calculate correlation coefficient, using Monte Carlo Simulation, by X and (X^2) when X is uniformly distributed in [0,1].

Problema das Moedas Correlacionadas

Dois amigos, João e José, estão jogando com duas moedas. Só que essas moedas são correlacionadas. Para a Moeda 1 há 30% de chance de que seja sorteado o valor “CARA”. Se para a Moeda 1 for sorteado o valor “CARA”, há 60% de chance de que seja sorteado o valor “CARA” para a Moeda 2. Ou seja, as moedas estão correlacionadas.

 

O jogo é o seguinte: Se após o lançamento das 2 moedas saírem dois valores “CARA” quem leva o dinheiro da aposta é o João. E se após o lançamento das 2 moedas saírem dois valores “COROA” quem leva o dinheiro da aposta é o José. Se saírem valores “CARA” e “COROA”, não há vencedores.

 

Você consegue fazer uma Simulação de Monte Carlo para determinar quem tem maior probabilidade de ganhar o jogo???

Problema de Varáveis Estocásticas Correlacionadas

>>> import numpy as np

>>> val = np.random.multivariate_normal((0,0),[[1,1],[1,4]],1000)

random.multivariate_normal(mean, cov, size=None, check_valid='warn', tol=1e-8)

 

Draw random samples from a multivariate normal distribution.

 

The multivariate normal, multinormal or Gaussian distribution is a generalization of the one-dimensional normal distribution to higher dimensions. Such a distribution is specified by its mean and covariance matrix. These parameters are analogous to the mean (average or “center”) and variance (standard deviation, or “width,” squared) of the one-dimensional normal distribution.

Row-wise and Column-wise Pearson Correlation Coefficients

Examples

__________________________________________________________________________

 

In this example we generate two random arrays, xarr and yarr, and compute the row-wise and column-wise Pearson correlation coefficients, R. Since rowvar is true by default, we first find the row-wise Pearson correlation coefficients between the variables of xarr.

 

>>> import numpy as np

>>> rng = np.random.default_rng(seed=42)

>>> xarr = rng.random((3, 3))

>>> R1 = np.corrcoef(xarr)

 

If we add another set of variables and observations yarr, we can compute the row-wise Pearson correlation coefficients between the variables in xarr and yarr.

>>> yarr = rng.random((3, 3))

>>> R2 = np.corrcoef(xarr, yarr)

Problema do Monty Hall

The original and most simple scenario of the Monty Hall problem is this:

 

You are in a prize contest and in front of you there are three doors (A, B and C). Behind one of the doors is a prize (Car), while behind others is a loss (Goat). You first choose a door (let’s say door A). The contest host then opens another door behind which is a goat (let’s say door B), and then he asks you if will you stay behind your original choice or will you switch the door. The question behind this is what is the better strategy?

The most common answer is that it doesn’t matter which strategy you choose because it is 50/50 chance – but it is not.

https://www.r-bloggers.com/in-memory-of-monty-hall/

Também é interessante ver o livro do Charles Wheelan, “Naked Statistics: Stripping the Dread from the Data”, Publisher :‎ W. W. Norton & Company; 1st edition (January 13, 2014)

imagem Monty Hall.jpg

Segue abaixo um código em Python elaborado por Daniel Cavalcanti (dcavalcanti08@gmail.com), provando que a melhor estratégia é sempre mudar de porta!!!

Não acredita???

 

Jogue você mesmo!!!

# -*- coding: utf-8 -*-
"""
Created on Sun May 17 17:52:48 2020

@author: Daniel Cavalcanti (dcavalcanti08@gmail.com)
"""

import random

print("Escolha uma porta: A, B ou C")

 

portaescolhida = input()

 

print()

 

portacarro = random.choice(['A', 'B', 'C'])

 

print()

 

if ((portacarro == 'A' and portaescolhida == 'A')):
  print("Eu vou revelar para você que a porta B tem uma cabra.")

    print()

    print('Você quer trocar sua porta??')
    print()

    escolhafinal = input()
  if escolhafinal == 'sim':
        print("Infelizmente você perdeu")
  else:
        print("Parabéns, você ganhou o carro")
  print()
  print("A porta certa era " + portacarro)

if ((portacarro == 'A' and portaescolhida == 'B')):
  print("Eu vou revelar para você que a porta C tem uma cabra")
    print()
    print('Você quer trocar a sua porta??')
    print()
    escolhafinal = input()
  if escolhafinal == 'sim':
        print("Parabéns, você ganhou")
  else:
        print("Infelizmente você perdeu")
  print()
  print("A porta certa era " + portacarro)    
       
if ((portacarro == 'A' and portaescolhida == 'C')):
  print("Eu vou revelar para você que a porta B tem uma cabra")
    print()
    print('Você quer trocar sua porta??')
    print()

    escolhafinal = input()    
  if escolhafinal == 'sim':
        print("Parabéns, você ganhou")
  else:
       print("Infelizmente você perdeu")
  print()
  print("A porta certa era " + portacarro)    
       
if ((portacarro == 'B' and portaescolhida == 'A')):
  print("Eu vou revelar para você que a porta C tem uma cabra.")

    print()

    print('Você quer trocar sua porta??')
    print()

    escolhafinal = input()
  if escolhafinal == 'sim':
        print("Parabéns, você ganhou")
  else:
        print("Inelizmente você perdeu")
  print()
  print("A porta certa era " + portacarro)    
       
if ((portacarro == 'B' and portaescolhida == 'B')):
  print("Eu vou revelar para você que a porta C tem uma cabra")
    print()
    print('Você quer trocar a sua porta??')
    print()
    escolhafinal = input()
  if escolhafinal == 'sim':
        print("Infelizmente você perdeu")
  else:
        print("Parabéns, você ganhou")
  print()
  print("A porta certa era " + portacarro)   

if ((portacarro == 'B' and portaescolhida == 'C')):
  print("Eu vou revelar para você que a porta A tem uma cabra")
    print()
    print('Você quer trocar sua porta??')
    print()

    escolhafinal = input()    
  if escolhafinal == 'sim':
        print("Parabéns, você ganhou")
  else:
       print("Infelizmente você perdeu")
  print()
  print("A porta certa era " + portacarro) 
      
if ((portacarro == 'C' and portaescolhida == 'A')):
  print("Eu vou revelar para você que a porta B tem uma cabra.")

    print()

    print('Você quer trocar sua porta??')
    print()

    escolhafinal = input()
  if escolhafinal == 'sim':
        print("Parabéns, você ganhou")
  else:
        print("Inelizmente você perdeu")
  print()
  print("A porta certa era " + portacarro)    
       
if ((portacarro == 'C' and portaescolhida == 'B')):
  print("Eu vou revelar para você que a porta A tem uma cabra")
    print()
    print('Você quer trocar a sua porta??')
    print()
    escolhafinal = input()
  if escolhafinal == 'sim':
        print("Infelizmente você perdeu")
  else:
        print("Parabéns, você ganhou")
  print()
  print("A porta certa era " + portacarro) 
       
if ((portacarro == 'C' and portaescolhida == 'C')):
  print("Eu vou revelar para você que a porta A tem uma cabra")
    print()
    print('Você quer trocar sua porta??')
    print()

    escolhafinal = input()    
  if escolhafinal == 'sim':
        print("Infelizmente você perdeu")
  else:
       print("Parabéns, você ganhou")
  print()
  print("A porta certa era " + portacarro)

------------------------------

No pdf abaixo você pode encontrar uma explicação qualitativa para o problema do Monty Hall. 

Mas, sinceramente... A minha sugestão é você pegar o código em Python acima e fazer uma simulação de Monte Carlo para provar que a melhor estratégia é trocar de porta!!!

bottom of page