CS计算机代考程序代写 Warmup

Warmup

Our Sample Space for rolling one die is 𝑆𝑆 = {1,2,3,4,5,6}

This means, our Sample Space for rolling 10 die is
𝑆𝑆10 = {lists of 10 items, where order matters}

The probability of getting exactly six 1’s is:

10
6

⋅ 54

610

Different ways you can
get six 1s

Different the 4 other die
rolls can turn out. (No 1s)

Total size of 𝑆𝑆10

Random Variable – Definition and Example

𝑋𝑋 (Capital X) is the random variable for the number of heads shown
The probabilities of each of these should add up to one.

3 2 22 1 1 1 0

𝒙𝒙 0 1 2 3
𝑃𝑃(𝑋𝑋 = 𝑥𝑥) 1/8 3/8 3/8 1/8

Random Variable – Another Example

Try it on your own first. Solution on the next slide

Random Variable – Another Example

𝒙𝒙 2 3 4 5 6 7 8 9 10 11 12
𝑃𝑃(𝑋𝑋 = 𝑥𝑥) 1/36 2/36 3/36 4/36 5/36 6/36 5/36 4/36 3/36 2/36 1/36

Hint: Look at the diagonals to
see how many times you can
get each sum

Exercises

Try these on your own first. Solutions on the next slides

Exercises

𝑋𝑋 ≤ 1 is the same as 𝑋𝑋 = 0 or 𝑋𝑋 = 1

𝑃𝑃 𝑋𝑋 ≤ 1 = 𝑃𝑃 𝑋𝑋 = 1 + 𝑃𝑃 𝑋𝑋 = 2

1
8

+
3
8

=
4
8

=
1
2

𝒙𝒙 0 1 2 3
𝑃𝑃(𝑋𝑋 = 𝑥𝑥) 1/8 3/8 3/8 1/8

Exercises

Let 𝑀𝑀 be the event that 𝑆𝑆 is a multiple of 3.

𝑃𝑃 𝑀𝑀 = 𝑃𝑃 𝑆𝑆 = 3 ∪ 𝑆𝑆 = 6 ∪ 𝑆𝑆 − 9 ∪ 𝑆𝑆 = 12

= 𝑃𝑃 𝑆𝑆 = 3 + 𝑃𝑃 𝑆𝑆 = 6 + 𝑃𝑃 𝑆𝑆 − 9 + 𝑃𝑃 𝑆𝑆 = 12

2
36

+
5

36
+

4
36

+
1

36
=

12
36

=
1
3

𝒙𝒙 2 3 4 5 6 7 8 9 10 11 12
𝑃𝑃(𝑋𝑋 = 𝑥𝑥) 1/36 2/36 3/36 4/36 5/36 6/36 5/36 4/36 3/36 2/36 1/36

3 divides 𝑆𝑆

Recall

Note that independent
events are NOT
necessarily disjoint
(and vice versa).

Example

Try it on your own first. Solution on the next slide

Example

𝑃𝑃 𝑋𝑋 = 𝑎𝑎 ∩ 𝑌𝑌 = 𝑏𝑏 =
1

52
=

1
13

×
1
4

Therefore, these events are independent.

𝑃𝑃 𝑋𝑋 = 𝑎𝑎 =
4

52
=

1
13

For example, probability of getting a
Queen

𝑃𝑃 𝑌𝑌 = 𝑏𝑏 =
13
52

=
1
4

For example, probability of
getting a Diamond

Examples

Try it on your own first. Solution on the next slide

Examples

For this one, try looking at a counterexample.

Suppose 𝑆𝑆 = 12 and 𝑇𝑇 = 1.
This 𝑆𝑆 means, you rolled two dice that sum up to 12
This 𝑇𝑇 means you got 1 three that showed up.

𝑃𝑃 𝑆𝑆 = 12 = 1
36

and 𝑃𝑃 𝑇𝑇 = 1 = 11
36

The probability of getting a 12, and having a 3 we know is zero.
But

1
36

× 11
36
≠ 0. So we know that these events are not independent

Exercise

From the textbook (33.1)
Let (𝑆𝑆,𝑃𝑃) be a sample space with 𝑆𝑆 = {𝑎𝑎, 𝑏𝑏, 𝑐𝑐,𝑑𝑑} and

𝑃𝑃 𝑎𝑎 = 0.1,𝑃𝑃 𝑏𝑏 = 0.2,𝑃𝑃 𝑐𝑐 = 0.3,𝑃𝑃 𝑑𝑑 = 0.4
Define random variables 𝑋𝑋,𝑌𝑌 on this sample space according to the below
table:

Complete (a) through (g) in text

𝒔𝒔 𝑿𝑿(𝒔𝒔) 𝒀𝒀(𝒔𝒔)
𝑎𝑎 1 -1
𝑏𝑏 3 3
𝑐𝑐 5 6
𝑑𝑑 8 10

Motivation and Videos

Watch these videos on Expected Value and Variance:
• https://www.youtube.com/watch?v=kZTKuMBJP7Y

• This one is long, but fun, and provides good motivation for this section
• https://www.youtube.com/watch?v=OvTEhNL96v0
• https://www.youtube.com/watch?v=sheoa3TrcCI

Definitions

Examples

Try these on your own first. Solution on the next slides

Examples

𝒙𝒙 1 2 3 4 5 6
𝑃𝑃(𝑋𝑋 = 𝑥𝑥) 1

6
1
6

1
6

1
6

1
6

1
6

𝐸𝐸 𝑋𝑋 = 1
1
6

+ 2
1
6

+ 3
1
6

+ 4
1
6

+ 5
1
6

+ 6
1
6

= �
𝑖𝑖=1

6

𝑥𝑥𝑖𝑖𝑃𝑃(𝑥𝑥𝑖𝑖)

=
21
6

= 3.5

Examples

𝐸𝐸 𝑋𝑋 = 1
1
2

+ 2
1
4

+ 3
1
8

+ 4
1
8

=
15
8

= 1.875

𝒙𝒙 1 2 3 4
𝑃𝑃(𝑋𝑋 = 𝑥𝑥) 1

2
1
4

1
8

1
8

Exercise

Try it on your own first. Solution on the next slide

Exercise

= �
𝑖𝑖=2

12

𝑥𝑥𝑖𝑖𝑃𝑃(𝑥𝑥𝑖𝑖)

…do a lot of arithmetic…

= 7

𝒙𝒙 2 3 4 5 6 7 8 9 10 11 12
𝑃𝑃(𝑋𝑋 = 𝑥𝑥) 1/36 2/36 3/36 4/36 5/36 6/36 5/36 4/36 3/36 2/36 1/36

But, there is a quicker
way to get this answer!

Algebra of Random Variables

Basically, what this tells us, is that when we’re dealing
with Expected Value, we can break things down into
individual events and put them back together and
we’ll get the same answer.

To answer this previous question,
it required a lot of work!

What linearity allows us to do, is take the Expected Value
of 1 die (which we already calculated), and multiply that by
2 to get the expected value of rolling 2 dice.

Linearity of Expectation

Fancy math for what the previous slide says. The previous
slide is intuition. This slide is formal.

From 2 to n

Try it on your own first. Solution on the next slide

From 2 to n

1
𝑛𝑛
1 + 2

𝑛𝑛
2 + 3

𝑛𝑛
3 + ⋯+ 𝑛𝑛

𝑛𝑛
𝑛𝑛 = 𝑛𝑛2

𝑛𝑛−1

This equality can be proven with a combinatorial proof. Check for yourself
before moving on.

Product of Random Variables

Examples

Try these on your own. Solutions on the next slide

Examples

A straightforward application gives the solution
1
4

A straightforward application gives the solution
7
2

2
= 49

4

Variance

Try this on your own. Solution on the next slide

Variance

Recall: 𝐸𝐸 𝑋𝑋 = 7
2

𝒙𝒙 1 2 3 4 5 6
𝑃𝑃(𝑋𝑋 = 𝑥𝑥) 1

6
1
6

1
6

1
6

1
6

1
6

𝑥𝑥 − 𝐸𝐸(𝑋𝑋)
1 −

7
2

2 −
7
2

3 −
7
2

4 −
7
2

5 −
7
2

6 −
7
2

𝑥𝑥 − 𝐸𝐸 𝑋𝑋
2 25

4
9
4

1
4

1
4

9
4

25
4

𝐸𝐸 𝑥𝑥 − 𝐸𝐸 𝑋𝑋
2 1

6

25
4

1
6

9
4

1
6

1
4

1
6

1
4

1
6

9
4

1
6

25
4

𝑉𝑉𝑎𝑎𝑉𝑉 𝑋𝑋 =
35
12

Read this table from left to right, and then work your way
down the columns after you understand where everything
is coming from

In general, calculating the Variance
this way is a lot of arithmetic, even
for a relatively small example like
this one

Another [long] Example

Another [long] Example

Another [long] Example