normpdf in matlab in matlab

normpdf is a function in MATLAB that calculates the value of the probability density function (pdf) of the normal distribution at a specified value.

The syntax of the function is as follows:

main.m
y = normpdf(x, mu, sigma)
26 chars
2 lines

where x is the value at which to calculate the pdf, mu is the mean of the distribution, and sigma is the standard deviation of the distribution.

Here is an example code that uses normpdf to plot the normal distribution curve:

main.m
mu = 0;                   % mean of the distribution
sigma = 1;                % standard deviation of the distribution
x = linspace(-4, 4, 100);  % x values for the plot
y = normpdf(x, mu, sigma); % calculate the pdf at each value of x
plot(x, y);               % plot the pdf
xlabel('x');
ylabel('pdf');
title('Normal Distribution');
336 chars
9 lines

This code will produce a plot of the normal distribution curve with mean mu = 0 and standard deviation sigma = 1 over the range x from -4 to 4.

related categories

gistlibby LogSnag