8 de Maio de 2011 by amrlima
Paradoxo de São Petersburgo: um teste
Estava a ler estatística quando me deparei com este interessante paradoxo.
Este paradoxo, terá sido pela primeira vez publicado por Daniel Bernoulli(1700-1782) (se bem que tenha sido introduzido por Nicolas Bernoulli a Montmort em 1713) Supõe-se que dois indivíduos Pedro e Paulo concordam em jogar um jogo baseado em lançar uma moeda. Neste jogo, lança-se sucessivamente a moeda até dar cara, então, se a moeda tiver aparecido à n-ésima tentativa, Paulo dará a Pedro 2n-1 moedas. A questão que se coloca é sobre quanto deve Pedro pagar a Paulo pelo privilégio de jogar tal jogo?
Intuitivamente, talvez se indicasse uma qualquer quantia finita, mas na verdade, seja qual for a quantia que Pedro invista por cada jogo, se ele tiver dinheiro suficiente para jogar número suficiente de vezes ele deverá sair a lucrar. Em cada jogo ele tem œ de probabilidade de ganhar uma moeda, (œ)2 de ganhar duas moedas e assim sucessivamente, tendo portanto (œ)n de probabilidade de ganhar 2n-1 moedas. Como probabilisticamente é suposto por cada n jogos, ganhar (œ).1+(œ)2.2+…+(œ)n.2n-1 moedas e este somatório, quando n tende para infinito, tende também para infinito, conclui-se que se jogar número suficiente de jogos, poderá ganhar uma quantia de dinheiro superior a qualquer valor estabelecido. Fonte
Como estava aborrecido decidir por isto em código 🙂 (Python).
#/usr/bin/env python # -*- coding: utf-8 -*- import random import string def throw_coin(): '''Head is 0, Tail is 1''' return random.randint(0, 1) def main(): games = raw_input('Number of games: ') payment = 100 # This is to define the money the player has to pay to be hable # to play the game print "Initial player payment is %d" % payment cash = 0 for i in range(int (games)): throws = 0 throws = throws + 1 while (throw_coin() != 0): # throw coin until head comes up throws = throws + 1 cash = cash + 2 ** (throws - 1) # Equivalent to 2^(i-1) print "Throws %d" % throws print "You have wone: %d euros so far!" % cash print "You won %d €! You payed %d in advance. You result was %d €!" % (cash , payment, cash - payment) if __name__ == "__main__": main() |
sesamoid bone - 29 de Junho de 2014 @ 18:39
Today, while I was at work, my cousin stole my apple ipad and tested to
see if it can survive a twenty five foot drop, just so she can be a youtube sensation. My apple
ipad is now destroyed and she has 83 views. I know this is
completely off topic but I had to share it with someone!
My web site; sesamoid bone
Tree Stump Grinding Fort Lauderdale - 9 de Agosto de 2014 @ 2:31
When someone writes an post he/she retains the thought of a user in his/her brain that how
a user can be aware of it. Therefore that’s why this
article is great. Thanks!
my weblog :: Tree Stump Grinding Fort Lauderdale
jeremy92bdzjizpwi.de.la - 25 de Agosto de 2014 @ 5:34
Hey there I am so thrilled I found your web site, I really found you by error, while I was
looking on Bing for something else, Anyhow I am here now and would just like to say thanks for
a marvelous post and a all round interesting blog (I also love the theme/design), I don’t
have time to read through it all at the minute but I have bookmarked it and
also added your RSS feeds, so when I have time I will be back to
read much more, Please do keep up the excellent work.