LoslegenKostenlos loslegen

Normal distribution

On to the most recognizable and useful distribution of the bunch: the normal or Gaussian distribution. In the slides, we briefly touched on the bell-curve shape and how the normal distribution along with the central limit theorem enables us to perform hypothesis tests.

Similar to the previous exercises, here you'll start by simulating some data and examining the distribution, then dive a little deeper and examine the probability of certain observations taking place.

Diese Übung ist Teil des Kurses

Practicing Statistics Interview Questions in Python

Kurs anzeigen

Anleitung zur Übung

  • Generate the data for the distribution by using the rvs() function with size set to 1000; assign it to the data variable.
  • Display a matplotlib histogram; examine the shape of the distribution.
  • Given a standardized normal distribution, what is the probability of an observation greater than 2?
  • Looking at our sample, what is the probability of an observation greater than 2?

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Generate normal data
from scipy.stats import norm
data = norm.rvs(size=____)

# Plot distribution
plt.hist(____)
plt.show()

# Compute and print true probability for greater than 2
true_prob = 1 - norm.cdf(____)
print(____)

# Compute and print sample probability for greater than 2
sample_prob = sum(obs > ____ for obs in data) / len(____)
print(____)
Code bearbeiten und ausführen