URL: http://en.diveintodeeplearning.org/chapter_crashcourse/probability.html

# Probability and statistics

In the third calculation in section 2.6.3: Pr(D1=1 and D2=1)=0.0001â‹…0.9985+0.98â‹…0.0015=0.00176955, Pr(D1=1 and D2=1|H=0) is 0.0003 as calculated in the first equation, not 0.0001, although the final result is right:)

Hi, I would like to understand the output of this `print(nd.random.multinomial(probabilities, shape=(10))) [3 5 2 3 3 2 2 1 5 0]`

It is 10 times roll of a dice. So is the output saying 1 was rolled 3 times, 2 for 5 and so on till 6 ? or it is returning the output of each dice roll (but then it also gives a 0)

Thank you

It is 10 times roll of a die. This array is the actual outputs. In this example, the numbers on the die go from 0 to 5, not 1 to 6 compared to an actual physical die.

Effectively in your example, you rolled:

first a 3, then a 5, then a 2, then a 3, then a 3, then a 2, then a 2, then a 1, then a 5, then a 0.

Hi, I would like to clarify where the third line in the following snippet from section â€ś4.3 Normal distributionâ€ť comes from:

```
# Generate 10 random sequences of 10,000 uniformly distributed random variables
tmp = np.random.uniform(size=(10000,10))
x = 1.0 * (tmp > 0.3) + 1.0 * (tmp > 0.8)
mean = 1 * 0.5 + 2 * 0.2
variance = 1 * 0.5 + 4 * 0.2 - mean**2
print('mean {}, variance {}'.format(mean, variance))
```

In particular, does (tmp > 0.3) means take all values above 0.3 and where is this 0.3 and 0.8 coming from anyway?

Yes, `(tmp > 0.3)`

returns a boolean array with same shape as `tmp`

and value of `True`

whenever `tmp[i,j] > 0.3`

.

Line 3 â€śtransformsâ€ť the uniform variables generated in line 2 into random variables `X`

defined above in the text such that `P(0) = 0.3, P(1) = 0.5, P(2) = 0.2`

.

This is where `0.3`

comes from, and `0.8`

is just `0.3 + 0.5`

(or, if youâ€™d like to see it another way, `1 - 0.2`

).

Hope this is not too confusing, itâ€™s really easier to see it than to write it, if you know what I mean.