Step 1 is simple. Step 2, Iβm sure I got the formulas correct because I got outputs with an acceptable shape. Step 4 is pretty straightforward. But at Step 3, I am given this:

- Example of how to use
`np.random.choice()`

:

```
np.random.seed(0)
probs = np.array([0.1, 0.0, 0.7, 0.2])
idx = np.random.choice(range(len(probs)), p = probs)
```

- This means that you will pick the index (
`idx`

) according to the distribution: π(πππππ₯=0)=0.1, π(πππππ₯=1)=0.0, π(πππππ₯=2)=0.7, π(πππππ₯=3)=0.2 - Note that the value thatβs set to
`p`

should be set to a 1D vector. - Also notice that π¦Μ β¨π‘+1β©, which is
`y`

in the code, is a 2D array.

So y is the probability are the probabilities in a 2D array, but I need to input a 1D array in np.random.choice of the same size. I noticed that the probabilities of the same second index add up to 1. So I indexed into the counter at first, but it gave wrong values.

```
Sampling:
list of sampled indices:
[23, 7, 15, 26, 25, 23, 21, 14, 23, 23, 7, 16, 26, 24, 18, 14, 10, 0]
list of sampled characters:
['w', 'g', 'o', 'z', 'y', 'w', 'u', 'n', 'w', 'w', 'g', 'p', 'z', 'x', 'r', 'n', 'j', '\n']
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-110-5ed45dfbad4e> in <module>
19 print("\033[92mAll tests passed!")
20
---> 21 sample_test(sample)
<ipython-input-110-5ed45dfbad4e> in sample_test(target)
15 assert indices[-1] == char_to_ix['\n'], "All samples must end with \\n"
16 assert min(indices) >= 0 and max(indices) < len(char_to_ix), f"Sampled indexes must be between 0 and len(char_to_ix)={len(char_to_ix)}"
---> 17 assert np.allclose(indices[0:6], [23, 16, 26, 26, 24, 3]), "Wrong values"
18
19 print("\033[92mAll tests passed!")
AssertionError: Wrong values
```

How are you supposed to aggregate a bunch of probability distributions into one probability distribution for the np.random.choice?