104k views
1 vote
Suppose we have a deck of spade cards (13 cards), and one card is picked and put back into the deck, one more is picked and put back into the deck and one more is picked and put back into the deck. Write a Monte Carlo simulation where you run the simulation of this 3 card picks for 100 times. Calculate the probability of getting the same card for each pick (6 points).

User EdMorte
by
5.3k points

1 Answer

4 votes

Answer

The code is attached.

Step-by-step explanation:

I wrote a function in python, the steps are as follows

  • selects 3 integers randomly between 1 and 13 and assigns these integers to variables named spade1,spade2 and spade3
  • sets a counter variable and defaults to 0
  • if spade1==spade2 and spade1==spade3 then increases the counter by one
  • does this 100 times.
  • calculates the probability of getting same card for each pick by returning counter/100

Suppose we have a deck of spade cards (13 cards), and one card is picked and put back-example-1
User Wot
by
5.9k points