MATLAB Normal Distribution Probability Density Function: Plotting the Probability Curve of Normal Distribution
发布时间: 2024-09-14 15:20:24 阅读量: 31 订阅数: 29
# Normal Distribution Probability Density Function in MATLAB: Plotting Probability Curves
The normal distribution, also known as the Gaussian distribution, is a continuous probability distribution extensively used in statistics and probability theory. Its probability density function (PDF) describes the likelihood of a random variable appearing around a particular value.
In MATLAB, the `normpdf` function can be used to calculate the PDF of a normal distribution. This function requires two parameters: the mean (`mu`) and the standard deviation (`sigma`). The mean represents the center of the distribution, while the standard deviation indicates the dispersion of the distribution.
```matlab
% Mean and standard deviation
mu = 0;
sigma = 1;
% Calculate PDF for specific values
x = -3:0.1:3;
y = normpdf(x, mu, sigma);
% Plot the PDF curve
plot(x, y, 'b-', 'LineWidth', 2);
xlabel('x');
ylabel('Probability Density');
title('Normal Distribution Probability Density Function');
```
# 2. Plotting Normal Distribution Probability Curves
### 2.1 Understanding the Normal Distribution Probability Density Function
#### 2.1.1 Definition and Characteristics of Normal Distribution
The normal distribution, also known as the Gaussian distribution, is a continuous probability distribution characterized by a bell-shaped curve for its probability density function. The two critical parameters of a normal distribution are the mean (μ) and the standard deviation (σ).
The mean indicates the center of the distribution, whereas the standard deviation indicates the dispersion. The normal distribution possesses the following characteristics:
* Symmetry: The probability density function is symmetric about the mean.
* Unimodality: The probability density function has a single peak.
* Asymptotic behavior: The tails of the distribution approach zero asymptotically.
#### 2.1.2 Mathematical Expression of the Probability Density Function
The probability density function of the normal distribution is given by:
```
f(x) = (1 / (σ√(2π))) * exp(-((x - μ)^2) / (2σ^2))
```
Where:
* x is the random variable
* μ is the mean
* σ is the standard deviation
* π is the mathematical constant pi
### 2.2 Plotting the Normal Distribution Probability Curve
#### 2.2.1 Normal Distribution Function in MATLAB
MATLAB provides the `normpdf` function to calculate the probability density function of the normal distribution. The syntax for this function is as follows:
```
y = normpdf(x, mu, sigma)
```
Where:
* x is the value at which to compute the probability density
* mu is the mean
* sigma is the standard deviation
* y is the computed probability density value
#### 2.2.2 Basic Steps for Plotting the Probability Curve
The basic steps to plot a normal distribution probability curve are:
1. **Generate data points:** Use the `linspace` function to generate a sequence of data points covering the required range of x values.
2. **Compute the probability density:** Use the `normpdf` function to calculate the probability density for each data point.
3. **Plot the curve:** Use the `plot` function to draw the curve of probability density against the data points.
```
% Generate data points
x = linspace(-3, 3, 100);
% Compute the probability density
y = normpdf(x, 0, 1);
% Plot the curve
plot(x, y, 'b-', 'LineWidth', 2);
xlabel('x');
ylabel('Probability Density');
title('Normal Distribution Probability Curve');
```
**Code Logic Analysis:**
* `linspace(-3, 3, 100)` creates a sequence of 100 uniformly distributed data points from -3 to 3.
* `normpdf(x, 0, 1)` calculates the probability density for each data point, with a mean of 0 and a standard deviation of 1.
* `plot(x, y, 'b-', 'LineWidth', 2)` plots the probability curve in blue solid lines with a line width of 2.
* `xlabel('x')` and `ylabel('Probability Density')` set the labels for the x-axis and y-axis, respectivel
0
0