我制作了一个Python脚本来测试Monty Hall Problem 我的问题是代码似乎输出了30%的胜利和60%的损失,而它应该做相反的事情。
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to 52.1.*.* [52.1.*.*] port 22.
debug1: Connection established.
debug1: identity file mypem.pem type -1
debug1: identity file mypem.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2
debug1: match: OpenSSH_6.2 pat OpenSSH*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 6b:5a:e2:0c:c5:98:ff:34:6e:c6:2c:84:ea:a0:88:0f
debug1: Host '52.1.*.*' is known and matches the RSA host key.
debug1: Found key in /Users/sergey.novgorodsky/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: mypem.pem
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
我觉得我错过了一些明显的东西。 任何帮助将不胜感激。
答案 0 :(得分:4)
这实际上并没有正确实现Monty Hall问题。当初始猜测不正确时,在给出切换要约之前会显示另一个不正确的门,因此这是一个确定性选项。当初始猜测正确时,其他一个不正确的门会随机显示。
在您的实施中,在最初的猜测之后,您没有得到任何额外的信息 - 您只是随意选择第二扇门,这与您的第一扇门不同。
以下是如何实施正确方法的示例:
In [168]: from random import randint, choice
...: wins = 0
...: losses = 0
...: for i in range(1000):
...: correctDoor = randint(1, 3)
...: guessDoor = randint(1, 3)
...: if guessDoor != correctDoor:
...: newGuessDoor = correctDoor
...: else:
...: newGuessDoor = choice([i for i in [1,2,3] if i != guessDoor])
...: if newGuessDoor == correctDoor:
...: wins = wins+1
...: else:
...: losses = losses+1
...: print('Wins = ' + str(wins) + '\nLosses = ' + str(losses) + '')
...:
Wins = 653
Losses = 347