Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Normal Distribution Sampling and Visualization | Random Sampling and Probabilistic Foundations
Simulation and Monte Carlo Modeling with Python

bookNormal Distribution Sampling and Visualization

The normal distribution, also called the Gaussian distribution, is one of the most important probability distributions in statistics and simulation. Many natural phenomena, such as heights, test scores, and measurement errors, are modeled well by the normal distribution. In simulation and Monte Carlo modeling, you often need to generate random samples that follow a normal distribution to mimic real-world randomness or uncertainty. The normal distribution is defined by two key parameters: the mean (center of the distribution) and the standard deviation (spread or width of the distribution).

1234567891011121314151617
import numpy as np import matplotlib.pyplot as plt # Set parameters for the normal distribution mean = 0 std_dev = 1 sample_size = 1000 # Generate random samples from the normal distribution samples = np.random.normal(loc=mean, scale=std_dev, size=sample_size) # Plot a histogram of the samples plt.hist(samples, bins=30, density=True, alpha=0.7, color='skyblue', edgecolor='black') plt.title('Histogram of Normal Distribution Samples') plt.xlabel('Value') plt.ylabel('Density') plt.show()
copy

To understand this code, start by noting the use of np.random.normal, which generates random numbers that follow a normal distribution. The mean parameter (loc) sets the center of the distribution, while the std_dev parameter (scale) determines how spread out the values are around the mean. The sample_size specifies how many random values you want to generate.

The histogram created by plt.hist visualizes these samples. The bins parameter controls how many groupings the data is divided into, while density=True ensures the histogram represents a probability density (so the area under the bars sums to 1). The resulting plot shows how the empirical distribution of your samples matches the familiar bell curve shape of the normal distribution. By adjusting the mean and standard deviation, you can see how the center and width of the distribution change in practice.

Note
Definition

The standard deviation measures the amount of variation or spread in a set of values. In a normal distribution, about 68% of the data falls within one standard deviation of the mean, and about 95% falls within two standard deviations. A larger standard deviation means the distribution is wider and more spread out; a smaller standard deviation means it is narrower and more concentrated around the mean.

question mark

Which of the following statements about the normal distribution is correct?

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 2

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

bookNormal Distribution Sampling and Visualization

Swipe um das Menü anzuzeigen

The normal distribution, also called the Gaussian distribution, is one of the most important probability distributions in statistics and simulation. Many natural phenomena, such as heights, test scores, and measurement errors, are modeled well by the normal distribution. In simulation and Monte Carlo modeling, you often need to generate random samples that follow a normal distribution to mimic real-world randomness or uncertainty. The normal distribution is defined by two key parameters: the mean (center of the distribution) and the standard deviation (spread or width of the distribution).

1234567891011121314151617
import numpy as np import matplotlib.pyplot as plt # Set parameters for the normal distribution mean = 0 std_dev = 1 sample_size = 1000 # Generate random samples from the normal distribution samples = np.random.normal(loc=mean, scale=std_dev, size=sample_size) # Plot a histogram of the samples plt.hist(samples, bins=30, density=True, alpha=0.7, color='skyblue', edgecolor='black') plt.title('Histogram of Normal Distribution Samples') plt.xlabel('Value') plt.ylabel('Density') plt.show()
copy

To understand this code, start by noting the use of np.random.normal, which generates random numbers that follow a normal distribution. The mean parameter (loc) sets the center of the distribution, while the std_dev parameter (scale) determines how spread out the values are around the mean. The sample_size specifies how many random values you want to generate.

The histogram created by plt.hist visualizes these samples. The bins parameter controls how many groupings the data is divided into, while density=True ensures the histogram represents a probability density (so the area under the bars sums to 1). The resulting plot shows how the empirical distribution of your samples matches the familiar bell curve shape of the normal distribution. By adjusting the mean and standard deviation, you can see how the center and width of the distribution change in practice.

Note
Definition

The standard deviation measures the amount of variation or spread in a set of values. In a normal distribution, about 68% of the data falls within one standard deviation of the mean, and about 95% falls within two standard deviations. A larger standard deviation means the distribution is wider and more spread out; a smaller standard deviation means it is narrower and more concentrated around the mean.

question mark

Which of the following statements about the normal distribution is correct?

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 2
some-alt