Normal probability density function - MATLAB normpdf (2024)

Normal probability density function

collapse all in page

Syntax

y = normpdf(x)

y = normpdf(x,mu)

y = normpdf(x,mu,sigma)

Description

example

y = normpdf(x) returns the probability density function (pdf) of the standard normal distribution, evaluated at the values in x.

y = normpdf(x,mu) returns the pdf of the normal distribution with mean mu and the unit standard deviation, evaluated at the values in x.

example

y = normpdf(x,mu,sigma) returns the pdf of the normal distribution with mean mu and standard deviation sigma, evaluated at the values in x.

Examples

collapse all

Standard Normal Distribution pdf

Open Live Script

Compute the pdf values for the standard normal distribution at the values in x.

y = 1×5 0.0540 0.2420 0.3989 0.2420 0.0540

Normal Distribution pdf

Open Live Script

Compute the pdf values evaluated at the values in x for the normal distribution with mean mu and standard deviation sigma.

x = [-2,-1,0,1,2];mu = 2;sigma = 1;y = normpdf(x,mu,sigma)
y = 1×5 0.0001 0.0044 0.0540 0.2420 0.3989

Compute the pdf values evaluated at zero for various normal distributions with different mean parameters.

mu = [-2,-1,0,1,2];sigma = 1;y = normpdf(0,mu,sigma)
y = 1×5 0.0540 0.2420 0.3989 0.2420 0.0540

Input Arguments

collapse all

xValues at which to evaluate pdf
scalar value | array of scalar values

Values at which to evaluate the pdf, specified as a scalar value or an array of scalar values.

To evaluate the pdf at multiple values, specify x using an array. To evaluate the pdfs of multiple distributions, specify mu and sigma using arrays. If one or more of the input arguments x, mu, and sigma are arrays, then the array sizes must be the same. In this case, normpdf expands each scalar input into a constant array of the same size as the array inputs. Each element in y is the pdf value of the distribution specified by the corresponding elements in mu and sigma, evaluated at the corresponding element in x.

Example: [-1,0,3,4]

Data Types: single | double

muMean
0 (default) | scalar value | array of scalar values

Mean of the normal distribution, specified as a scalar value or an array of scalar values.

To evaluate the pdf at multiple values, specify x using an array. To evaluate the pdfs of multiple distributions, specify mu and sigma using arrays. If one or more of the input arguments x, mu, and sigma are arrays, then the array sizes must be the same. In this case, normpdf expands each scalar input into a constant array of the same size as the array inputs. Each element in y is the pdf value of the distribution specified by the corresponding elements in mu and sigma, evaluated at the corresponding element in x.

Example: [0 1 2; 0 1 2]

Data Types: single | double

sigmaStandard deviation
1 (default) | positive scalar value | array of positive scalar values

Standard deviation of the normal distribution, specified as a positive scalar value or an array of positive scalar values.

To evaluate the pdf at multiple values, specify x using an array. To evaluate the pdfs of multiple distributions, specify mu and sigma using arrays. If one or more of the input arguments x, mu, and sigma are arrays, then the array sizes must be the same. In this case, normpdf expands each scalar input into a constant array of the same size as the array inputs. Each element in y is the pdf value of the distribution specified by the corresponding elements in mu and sigma, evaluated at the corresponding element in x.

Example: [1 1 1; 2 2 2]

Data Types: single | double

Output Arguments

collapse all

More About

collapse all

Normal Distribution

The normal distribution is a two-parameter family of curves. The first parameter, µ, is the mean. The second parameter, σ, is the standard deviation.

The standard normal distribution has zero mean and unit standard deviation.

The normal probability density function (pdf) is

y=f(x|μ,σ)=1σ2πe(xμ)22σ2,forx.

The likelihood function is the pdf viewed as a function of the parameters. The maximum likelihood estimates (MLEs) are the parameter estimates that maximize the likelihood function for fixed values of x.

Alternative Functionality

  • normpdf is a function specific to normal distribution. Statistics and Machine Learning Toolbox™ also offers the generic function pdf, which supports various probability distributions. To use pdf, create a NormalDistribution probability distribution object and pass the object as an input argument or specify the probability distribution name and its parameters. Note that the distribution-specific function normpdf is faster than the generic function pdf.

  • Use the Probability Distribution Function app to create an interactive plot of the cumulative distribution function (cdf) or probability density function (pdf) for a probability distribution.

References

[1] Evans, M., N. Hastings, and B. Peaco*ck. Statistical Distributions. 2nd ed. Hoboken, NJ: John Wiley & Sons, Inc., 1993.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Version History

Introduced before R2006a

See Also

pdf | normcdf | norminv | normrnd | mvnpdf | NormalDistribution | normspec

Topics

  • Normal Distribution

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

 

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Normal probability density function - MATLAB normpdf (1)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

Contact your local office

Normal probability density function - MATLAB normpdf (2024)

References

Top Articles
Latest Posts
Article information

Author: Stevie Stamm

Last Updated:

Views: 6676

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Stevie Stamm

Birthday: 1996-06-22

Address: Apt. 419 4200 Sipes Estate, East Delmerview, WY 05617

Phone: +342332224300

Job: Future Advertising Analyst

Hobby: Leather crafting, Puzzles, Leather crafting, scrapbook, Urban exploration, Cabaret, Skateboarding

Introduction: My name is Stevie Stamm, I am a colorful, sparkling, splendid, vast, open, hilarious, tender person who loves writing and wants to share my knowledge and understanding with you.