Skip to content

Commit e9ecdfc

Browse files
Address reviewer comments in numpy.md
- Update prose to reference NumPy's Generator API instead of np.random - Add optional seed parameter to DiscreteRV.__init__ for reproducibility Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 81bdeab commit e9ecdfc

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lectures/numpy.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ z[z > 3]
10501050
NumPy provides some additional functionality related to scientific programming
10511051
through its sub-packages.
10521052

1053-
We've already seen how we can generate random variables using np.random
1053+
We've already seen how we can generate random variables using NumPy's Generator API.
10541054

10551055
```{code-cell} python3
10561056
z = rng.standard_normal(10000) # Generate standard normals
@@ -1248,14 +1248,14 @@ class DiscreteRV:
12481248
probabilities given by q.
12491249
"""
12501250
1251-
def __init__(self, q):
1251+
def __init__(self, q, seed=None):
12521252
"""
12531253
The argument q is a NumPy array, or array like, nonnegative and sums
12541254
to 1
12551255
"""
12561256
self.q = q
12571257
self.Q = cumsum(q)
1258-
self.rng = np.random.default_rng()
1258+
self.rng = np.random.default_rng(seed)
12591259
12601260
def draw(self, k=1):
12611261
"""

0 commit comments

Comments
 (0)