-  [JOIN IRC!]


[Return]
Posting mode: Reply
Name
Subject   (reply to 442)
Message
File
Password  (for post and file deletion)
¯\(°_O)/¯
  • Supported file types are: BMP, GIF, JPG, PNG
  • Maximum file size allowed is 10000 KB.
  • Images greater than 400x400 pixels will be thumbnailed.
  • Currently 317 unique user posts. View catalog

  • Blotter updated: 2015-09-02 Show/Hide Show All


File 138883845871.jpg - (20.10KB , 407x309 , mainimage.jpg )
442 No. 442
How would you write a little program to test the effect of swapping in the Monty Hall problem? Here's my attempt in Java.

http://pastebin.com/LSi1AR9e
>> No. 443
What doesn't work about your program?

The only thing that jumps out at me as problematic is that you are randomly choosing how to swap. You should swap to whichever door you didn't guess and wasn't revealed.

The do/while that you're using there (and for choosing which door to reveal) makes the code a little harder to understand at a glance, so I wouldn't use it where you don't have to. Plus, there's no need to repeat either of those steps, so you'll get a (probably meaningless) performance boost.
>> No. 446
>>443
>You should swap to whichever door you didn't guess and wasn't revealed.

Yeah, that's what it does. The do loop runs until swap is not equal to either chosenDoor or revealedDoor. Is there a better way of achieveing this?
>> No. 447
>>446

I mean, "guess", not "chosenDoor".
>> No. 448
>>446
I think you should do it with a for-loop, infinite loops are dangerous. Or just a conditional since there's only three doors.

Theoretically, the RNG could give back the same (wrong) number infinite times. But I'm probably just nit-picking here.

Trivia: in my language nit-picking is called ant-fucking


Delete post []
Password  
Report post
Reason