473,382 Members | 1,202 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Card Drawing Simulation

mia023
89
hello there i have trouble understanding this assignment so can any one explain it to me.



Joe Optimist makes the following claim “If we draw three cards randomly from a standard 52-card deck, we have a greater than 10% chance of having them be of consecutive face values”. (9 7 8) (Q 10 J) (A 3 2) (Q K A) are all considered consecutive face values, but (3 4 6) and (J Q A) do not, independently of the card
suits. The draws are always made from a full deck, i.e., a card is returned to the deck before the next one is taken.
One way to verify this claim is to perform a Monte Carlo simulation in which we randomly draw 3 cards from a deck and check whether the cards have 3 consecutive values. If we repeat this experiment a sufficiently large number of times and collect statistics on the number of times we obtain 3 consecutive cards, the ratio of that number to the total number of trials gives us an estimate of the probability we seek.
Write a program Consecutive.java to evaluate whether the claim is true or not. The program should take a command line integer parameter N indicating the number of trials to perform and return the probability of having a 3-draw consisting of consecutive face values. Run the program with N = 1,000, N = 10,000, N=100,000 and comment on the accuracy of your results. Hints: The face values of cards can be mapped to integers between 1 and 13. Write a method that returns a random number in that range, and use it to draw 3 cards. Write another method that checks whether 3 cards have consecutive face values.
Nov 7 '07 #1
8 7282
r035198x
13,262 8TB
hello there i have trouble understanding this assignment so can any one explain it to me.



Joe Optimist makes the following claim “If we draw three cards randomly from a standard 52-card deck, we have a greater than 10% chance of having them be of consecutive face values”. (9 7 8) (Q 10 J) (A 3 2) (Q K A) are all considered consecutive face values, but (3 4 6) and (J Q A) do not, independently of the card
suits. The draws are always made from a full deck, i.e., a card is returned to the deck before the next one is taken.
One way to verify this claim is to perform a Monte Carlo simulation in which we randomly draw 3 cards from a deck and check whether the cards have 3 consecutive values. If we repeat this experiment a sufficiently large number of times and collect statistics on the number of times we obtain 3 consecutive cards, the ratio of that number to the total number of trials gives us an estimate of the probability we seek.
Write a program Consecutive.java to evaluate whether the claim is true or not. The program should take a command line integer parameter N indicating the number of trials to perform and return the probability of having a 3-draw consisting of consecutive face values. Run the program with N = 1,000, N = 10,000, N=100,000 and comment on the accuracy of your results. Hints: The face values of cards can be mapped to integers between 1 and 13. Write a method that returns a random number in that range, and use it to draw 3 cards. Write another method that checks whether 3 cards have consecutive face values.
Why didn't you ask your teacher about it?
Nov 7 '07 #2
hello there i have trouble understanding this assignment so can any one explain it to me.



Joe Optimist makes the following claim “If we draw three cards randomly from a standard 52-card deck, we have a greater than 10% chance of having them be of consecutive face values”. (9 7 8) (Q 10 J) (A 3 2) (Q K A) are all considered consecutive face values, but (3 4 6) and (J Q A) do not, independently of the card
suits. The draws are always made from a full deck, i.e., a card is returned to the deck before the next one is taken.
One way to verify this claim is to perform a Monte Carlo simulation in which we randomly draw 3 cards from a deck and check whether the cards have 3 consecutive values. If we repeat this experiment a sufficiently large number of times and collect statistics on the number of times we obtain 3 consecutive cards, the ratio of that number to the total number of trials gives us an estimate of the probability we seek.
Write a program Consecutive.java to evaluate whether the claim is true or not. The program should take a command line integer parameter N indicating the number of trials to perform and return the probability of having a 3-draw consisting of consecutive face values. Run the program with N = 1,000, N = 10,000, N=100,000 and comment on the accuracy of your results. Hints: The face values of cards can be mapped to integers between 1 and 13. Write a method that returns a random number in that range, and use it to draw 3 cards. Write another method that checks whether 3 cards have consecutive face values.
The point is to simulate a drawing of cards... Make a method that gives you a random card (maybe think of the random cards as random numbers from 1 to 13). Then make a loop so you get 3 random numbers. Then make some logic that can determine if the numbers are 3 consecutive numbers. For example (1 2 3) but take care that (1 3 2) would also count as consecutive.

This should get you on your way, but really... if you get an assignment and you have no clue what's going on, then you should talk to your teacher, not a internet forum.
Nov 7 '07 #3
JosAH
11,448 Expert 8TB
You can check the outcome of your Monte Carlo simulation: you can draw three
numbers in the range [1,13] in 13^3 ways. Only 11*3! draws are correct, i.e.
1-2-3, 2-3-4, 3-4-5 ... 11-12-13 in any order are the correct draws.

So the probability of having drawn three adjacent numbers == 11*3!/13^3.
In other words: that optimistic fellow is way too optimistic ;-)

kind regards,

Jos
Nov 7 '07 #4
JosAH
11,448 Expert 8TB
Come to think of it: this paragraph is not correct:

Hints: The face values of cards can be mapped to integers between 1 and 13. Write a method that returns a random number in that range, and use it to draw 3 cards. Write another method that checks whether 3 cards have consecutive face values.
For a real deck of cards there's the probability that you draw 3 equal cards, no
matter the suit is 1x(3*51)x(2*50).

The probability to draw three equal numbers out of a set [1,13] equals (1/13)^2

Those probabilities aren't equal.

kind regards,

Jos
Nov 7 '07 #5
mia023
89
Come to think of it: this paragraph is not correct:



For a real deck of cards there's the probability that you draw 3 equal cards, no
matter the suit is 1x(3*51)x(2*50).

The probability to draw three equal numbers out of a set [1,13] equals (1/13)^2

Those probabilities aren't equal.

kind regards,

Jos
Thank you alot i figured it out.
Nov 7 '07 #6
JosAH
11,448 Expert 8TB
Thank you alot i figured it out.
Was that your own hint or was it present in the original assignment text? If it
were the latter, go back to your lecturer and tell her/him about it.

kind regards,

Jos
Nov 7 '07 #7
balabaster
797 Expert 512MB
Was that your own hint or was it present in the original assignment text? If it
were the latter, go back to your lecturer and tell her/him about it.

kind regards,

Jos
Seems to me that this is a simple mathematical equation of the form nCr where n is the total number of elements in a set and r is the number of items you wish to choose which will give you the total different combinations of elements in a set...in this instance 13C3.

Subtract from that the number of consecutive combinations found in a set of 13 and divide one into the other giving you the final result. I forget the exact formula...but it has to do with factorial, it should be easy to find on the internet.
Nov 7 '07 #8
JosAH
11,448 Expert 8TB
Seems to me that this is a simple mathematical equation of the form nCr where n is the total number of elements in a set and r is the number of items you wish to choose which will give you the total different combinations of elements in a set...in this instance 13C3.

Subtract from that the number of consecutive combinations found in a set of 13 and divide one into the other giving you the final result. I forget the exact formula...but it has to do with factorial, it should be easy to find on the internet.
No need to google; see my previous replies for those formula.

kind regards,

Jos
Nov 7 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Steaming Balturd | last post by:
are there any php based economic simulations out there - not trading games per se, but more like simulating an economy, be it running a business or running a government? All i've been able to...
23
by: JC | last post by:
I am very new to programming and learning on my own. Why do I keep getting duplicate values using this code? I want to shuffle a deck of 52 cards. The logic seems right to me. Randomize For...
0
by: Constandinos Mavromoustakis | last post by:
Dear all, first we apologize if you receive multiple copies of this announcement. please see below if you are interested. Thank you in advance....
0
by: Constandinos Mavromoustakis | last post by:
http://agent.csd.auth.gr/~cmavrom -------------------------------------------------- ============================================================================ = 37th Annual Simulation...
0
by: Gus | last post by:
---------------------------------------------------------------------------- ------------------------------------ Call for Papers: 38th Annual Simulation Symposium Part of the 2005 Spring...
19
by: Nicolas Pernetty | last post by:
Hello, I'm looking for any work/paper/ressource about continuous system simulation using Python or any similar object oriented languages (or even UML theory !). I'm aware of SimPy for...
0
by: Karatza Helen | last post by:
Our apologies if you have received multiple copies -------------------------------------------------- Call for Papers: 38th Annual Simulation Symposium Part of the 2005 Spring Simulation...
1
by: James dean | last post by:
Could someone explain how this works. I think the graphics card is used to do blitting and drawing shapes like rectangles. How does it draw using the Graphics card on the PC and why is this feature...
5
by: Raman | last post by:
Hello friends, I want to print an ID card. I have one Windows Form that contains front and back side. The printer is printing both front and back side at a time. I am trying to send both sides...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.