Monty Hall problem: Difference between revisions

Content added Content deleted
(added Ursala)
Line 1,206: Line 1,206:
Estimate: 4960/10000 wins for 'picking anew' strategy
Estimate: 4960/10000 wins for 'picking anew' strategy
Of course, this challenge could also be tackled by putting up a GUI and letting the user be the source of the randomness. But that's moving away from the letter of the challenge and takes a lot of effort anyway...
Of course, this challenge could also be tackled by putting up a GUI and letting the user be the source of the randomness. But that's moving away from the letter of the challenge and takes a lot of effort anyway...

=={{header|Ursala}}==

This is the same algorithm as the Perl solution. Generate two lists
of 10000 uniformly distributed samples from {1,2,3}, count each
match as a win for the staying strategy, and count each non-match as a win
for the switching strategy.

<lang Ursala>
#import std
#import nat
#import flo

rounds = 10000

car_locations = arc{1,2,3}* iota rounds
initial_choices = arc{1,2,3}* iota rounds

staying_wins = length (filter ==) zip(car_locations,initial_choices)
switching_wins = length (filter ~=) zip(car_locations,initial_choices)

format = printf/'%0.2f'+ (times\100.+ div+ float~~)\rounds

#show+

main = ~&plrTS/<'stay: ','switch: '> format* <staying_wins,switching_wins>
</lang>
Output will vary slightly for each run due to randomness.
<pre>
stay: 33.95
switch: 66.05
</pre>


=={{header|Vedit macro language}}==
=={{header|Vedit macro language}}==