# Python代写 | CS 365, Fall 2021, Homework 2

本次美国代写是使用Python的一个Homework

**0.1 1. Problem Solving**

**0.1.1 1.1 Chebyshev inequality**

1.1.1 (5 points) Consider a fair dice and using the Chebyshev inequality compute the bound on

the probability:

1. P[fi4orfi3]

2. P[fi5orfi2]

3. P[fi6orfi1].

1.1.2 (5 points) Consider again a fair dice that you roll 10 times and compute the same bounds

for 10, which is the average over 10 roles.

1.1.3 (5 points) Do the same for 1000 average over 1000 rolls.

0.1.2 1.2 A book consisting of 500 pages contains 1,500 uses of the word “data”. We are interested in the

probability of finding the word “data” on a random page.

1.2.1 Which probability distribution that we studied do you think best describes this scenario?

Explain in your own words why you think that is.

1.2.2 (10 points) What is the probability that a randomly selected page contains exactly 3

occurrences of the word “data”? Show the formula you use, explain how you set the value of the

parameters and compute the result (up to 3 digits).

1.2.3 (10 points) Compute the probability that there are more than 2 occurrences of the word

“data” on a randomly selected page. Show your computation the same way as in 1.2.2.

0.2 3. Experiments

the If you have not already done so, please review Lab 2 and read this blog post before attempting

this problem: http://www.empiricalzeal.com/2012/12/21/what-does-randomness-look-like/#more-

2450

During the 2015-2016 NBA season, Steph Curry made NBA history by scoring an astronomical 402

successful three-point shots (breaking the previous record of 286 successful three-pointers, which

Curry had set the year before.) Below, we import a game-by-game record of Curry for that season.

Each row represents a single game. Pay particular attention to the column “3P,” which is the

number of successful three-pointers Curry scored each game.ir die:

[1]: import pandas as pd

data = pd.read_csv(“https://raw.githubusercontent.com/catabia/cs391_spring21/

,→main/curry16.csv”)

data

[1]: Rk G Date Age Tm Unnamed: 5 Opp Unnamed: 7 GS MP \

0 1 1 2015-10-27 27-227 GSW NaN NOP W (+16) 1 35:37

1 2 2 2015-10-30 27-230 GSW @ HOU W (+20) 1 27:24

2 3 3 2015-10-31 27-231 GSW @ NOP W (+14) 1 35:38

3 4 4 2015-11-02 27-233 GSW NaN MEM W (+50) 1 28:24

4 5 5 2015-11-04 27-235 GSW NaN LAC W (+4) 1 32:38

.. .. .. … … … … … … .. …

74 78 75 2016-04-05 28-022 GSW NaN MIN L (-7) 1 42:35

75 79 76 2016-04-07 28-024 GSW NaN SAS W (+11) 1 36:17

76 80 77 2016-04-09 28-026 GSW @ MEM W (+1) 1 33:59

77 81 78 2016-04-10 28-027 GSW @ SAS W (+6) 1 35:22

78 82 79 2016-04-13 28-030 GSW NaN MEM W (+21) 1 29:46

… DRB TRB AST STL BLK TOV PF PTS GmSc +/-

0 … 3 6 7 2 0 2 1 40 34.9 12

1 … 7 7 6 1 0 1 4 25 22.4 12

2 … 4 4 9 4 0 2 3 53 49.2 16

3 … 2 3 3 3 1 3 2 30 26.1 37

4 … 5 5 4 1 0 0 3 31 26.0 7

.. … … … … … … … .. … … …

74 … 4 6 15 3 0 3 4 21 17.8 3

75 … 5 5 9 2 0 3 2 27 24.1 14

76 … 9 9 8 1 0 2 1 17 11.3 10

77 … 5 5 5 2 0 4 4 37 28.2 7

78 … 3 4 6 2 0 2 2 46 40.2 19

[79 rows x 30 columns]

0.2.1 3.1 (5 points)

Create a new pandas DataFrame with two columns, containing: 1. The number of successful three-

pointers (should range from 1-12, as Curry scored anywhere between 1-12 three-pointers per game)

2. The number of games in which Curry scored that many three-pointers

0.2.2 3.2 (10 points)

Use matplotlib to create a bar plot from the DataFrame you created in 2.1, with the number of

three-pointers on the x-axis and the number of games on the y-axis. Draw a line on the bar plot

that represents the mean number of successful three-pointers per game. Remember to also label

your x and y axes, and to give your plot an appropriate title.

0.2.3 3.3 (10 points)

Looking at the bar graph you produced in 3.2, do you think that the number of three-pointers

Steph Curry scores in a game is random? Why or why not?

0.2.4 3.4 (15 points)

Calculate Curry’s average number of successful three-pointers per game. Then, use the Poisson

distribution to predict how many games Curry should score no three-pointer, 1 three-pointer, 2

three-pointers, etc. (Calculate this for the range from 0 to 12.)