Python代写:FIT9133 Analysing Cards

利用NumPy, MatPlotLib, Pandas等三方库,分析扑克组合。

Description

It is now time to show off your data science skills by analysing the Deck class from assignment 2. For this assessment, you may use your own Deck class, or the one provided on Moodle, just as long as it allows for the drawing and returning of cards to the deck.

The purpose of this assessment is to check your understanding of coding in context of a problem, and your ability to read and understand external libraries such as NumPy, MatPlotLib, and Pandas.

Proving Fairness

A deck is considered balanced if there is an equal chance at drawing a card. Thus, because the deck was created by us, we must prove that it is indeed fair. Write code that draws from a deck that contains cards from 1 to King in four suits (heart, diamond, spade, and club), saves the face value of that card and then returns it to the deck.

Do this 1000 times and show that the mean average of the draw is around 6.5-7.5.

Chances of Hands

In poker there is a hand called a “royal flush”. A royal flush is a hand of 10, Jack, Queen, King, and Ace all in hearts. A royal flush can not be beaten by any other hand, and so your task is to discover the chances of obtaining a royal flush if you draw 5 cards in a row.

In poker there is a hand called a “pair”. A hand is considered a “pair” if it contains exactly two of the same face value. There is also a hand called a “flush”. A hand is considered a “flush” if it contains all cards of the same suit. Your task is to investigate the chances of obtaining these hands after drawing 5 cards in a row.

You may nd that the number of trials needs to be more than 1000 to show a result. The more trials you do, the more accurate your result, however it takes more time for each trial you attempt.

You will need to attempt these 1000 trials multiple times, and then take the average of the probability found from all the sets of trials. How many times is up to you.

Change in Chance

Lastly you are to run the experiment from section 1.2 when the amount of suits increases from 1 to 10. Each set of trials must contain the same number of trials for this to work.

You should obtain a list of chances from 1 to 10.

The Report

The final product for this assignment is a report that details your findings from the sections above. In order to communicate what you have found you will need to make graphs using MatPlotLib. For sections 1.1 and 1.2, you may wish to demonstrate your findings via a bar graph of the dierent card tallies. For section 1.3 you will need to make a scatter plot to show how time changes as suit number increases.

However, these are suggestions only. You must make at least 1 graph for each section, but you can feel free to make any that provides useful information, and any amount of them. Ultimately you need to demonstrate you know how to code in context, and make graphs with a purpose.

Marking Guide

I personally do not like writing strict marking guides, however it is a policy that I do, and people will complain if I don’t. So here you go:

  1. Functionality
    • (a) Each experiment can be run independent of each other.
    • (b) Experimentation follows the required specication.
    • (c) Testing demonstrates correctness of functionality.
    • (d) Testing is demonstrated in an appropriate manner.
  2. Code Architecture
    • (a) Code is decomposed into functions.
    • (b) Functions are used to reimplement larger experiments.
    • (c) Testing covers all functionality.
  3. Coding Style
    • (a) Uses appropriate spacing.
    • (b) Has appropriate variable names.
    • (c) The logic is clear and meaningful.
  4. Documentation
    • (a) Explains the purpose of variables.
    • (b) Documents complicated parts of code.
    • (c) Fully documented functions
    • (d) If there needs to be user documentation for programs use then it is well explained.
    • (e) Experimental data is provided, and has been explained.
    • (f) Report is descriptive and explains code choices.

Note: All of the above is assuming that the code is eective. Meaning, if you just write a while loop that prints an index over and over, it won’t count. Your code must do something towards the goal of the assignment.

Further note: Yes, there is a lot of overlap in the above marking guide. Good practise bleeds into all areas of coding, especially when implementing good experiments.

Submission

You should submit this assignment in the form of one or multiple python scripts zipped together. While you may want to do your testing and development in notebooks, it must function in a python script.

Please submit your le with the name Assignment3{STUDENTID}{STUDENTNAME}.zip where STUDENTID is your student ID without the brackets, and STUDENTNAME is your name without the brackets.