Skip to content

Generating Random Data and Samples :Understanding and Visualizing Data with Python (Statistics with Python Specialization) Answers 2025

1. Question 1

Generate 3 normal random variables with mean = 100, sd = 1, seed = 123.

When we run:

import numpy as np
np.random.seed(123)
sample = np.random.normal(100, 1, 3)
print(sample)

The output is:

๐Ÿ‘‰ 99.914 101.937 100.282

  • โœ… 99.914 101.937 100.282

  • โŒ 99.822 100.093 100.719

  • โŒ 98.914 100.997 100.283

  • โŒ 100.915 99.997 101.283

  • โŒ 99.922 100.103 100.819

Explanation:
Using seed 123 replicates the exact sequence of normal draws, giving the first option.


2. Question 2

Generate sample of size 10 from integers 1โ€“100 with seed = 123.

Code:

import numpy as np
np.random.seed(123)
population = np.arange(1, 101)
sample = np.random.choice(population, 10)
print(sample)

The output is:

๐Ÿ‘‰ 67 93 99 18 84 58 87 98 97 48

  • โœ… 67 93 99 18 84 58 87 98 97 48

  • โŒ (all other options)

Explanation:
np.arange(1,101) creates integers 1โ€“100, and with seed 123, the sample drawn is exactly the above sequence.


๐Ÿงพ Summary Table

Q# Correct Answer Key Concept
1 99.914 101.937 100.282 Normal RNG with seed
2 67 93 99 18 84 58 87 98 97 48 Sampling with replacement using seed