A normal distribution produces values centered around a chosen mean, with their spread controlled by standard deviation. Random samples vary, so a generated mean may not exactly match the target. For a normal distribution, about 68% of values fall within one standard deviation of the mean, 95% within two, and 99.7% within three. section 1.15 section 1.5
g = np.random.default_rng(0) s = Series(g.normal(0, 100, 100_000)) #1
Generate 100,000 normally distributed floating-point values with mean 0 and standard deviation 100, then wrap the NumPy array in a pandas Series. section 1.15
Use pandas descriptive statistics to inspect the resulting shape. Calling describe returns the count, mean, standard deviation, minimum, quartiles, median, and maximum together. A large sample should have a median close to its mean because the distribution is symmetric, though random variation prevents exact equality. section 1.14 section 1.15
count 100000.000000 mean 0.157670 std 99.734467 min -485.211765 25% -66.864170 50% 0.172022 75% 67.343870 max 424.177191 dtype: float64
The displayed describe result shows a mean near zero, a median close to the mean, and a standard deviation near the requested 100. section 1.15
Testing sensitivity to an outlier
Replace every occurrence of the minimum value with five times the maximum value using a boolean mask and .loc. Running describe again reveals that the maximum changes dramatically, while the mean and standard deviation shift noticeably. The median changes much less, illustrating why extreme values affect the mean more strongly than the median. section 1.15 section 1.5
Repeated weekday measurements
Generate 28 rounded temperatures from a normal distribution with mean 20 and standard deviation 5. Give the values a repeating Sunday-through-Saturday index, then select the Monday entries and calculate their mean. section 1.18















