Main Content

betapdf

Beta probability density function

Description

y = betapdf(x,a,b) returns the probability density function (pdf) of the beta distribution at each of the values in x using the corresponding parameters in a and b. Values in x must be between [0,1].

example

Examples

collapse all

Compute the pdf values evaluated at the values in x for the beta distribution with first shape parameter a and second shape parameter b.

x = 0.2:0.2:1;
a = 2;
b = 1;
y = betapdf(x,a,b)
y = 1×5

    0.4000    0.8000    1.2000    1.6000    2.0000

Compute the pdf values evaluated at 0.1 for various beta distributions with different first shape parameter values.

a = [1,2,3];
b = 1;
y = betapdf(0.1,a,b)
y = 1×3

    1.0000    0.2000    0.0300

Input Arguments

collapse all

Values at which to evaluate the pdf, specified as a scalar value or an array of scalar values in the range [0,1].

To evaluate the pdf at multiple values, specify x using an array. To evaluate the pdfs of multiple distributions, specify a and b using arrays. If one or more of the input arguments x, a, and b are arrays, then the array sizes must be the same. In this case, betapdf 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 a and b, evaluated at the corresponding element in x.

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

Data Types: single | double

First shape parameter, specified as a positive scalar value or a numeric array of positive values.

To evaluate the pdf at multiple values, specify x using an array. To evaluate the pdfs of multiple distributions, specify a and b using arrays. If one or more of the input arguments x, a, and b are arrays, then the array sizes must be the same. In this case, betapdf 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 a and b, evaluated at the corresponding element in x.

Example: [0.75,0.5;10,100]

Data Types: single | double

Second shape parameter, specified as a positive scalar value or a numeric array of positive values.

To evaluate the pdf at multiple values, specify x using an array. To evaluate the pdfs of multiple distributions, specify a and b using arrays. If one or more of the input arguments x, a, and b are arrays, then the array sizes must be the same. In this case, betapdf 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 a and b, evaluated at the corresponding element in x.

Example: [0.2,100;4,7]

Data Types: single | double

Output Arguments

collapse all

pdf values, evaluated at the values in x, returned as a scalar value or an array of scalar values. y is the same size as x, a, and b after any necessary scalar expansion. Each element in y is the pdf value of the distribution specified by the corresponding elements in a and b, evaluated at the corresponding element in x.

More About

collapse all

Extended Capabilities

expand all

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

Version History

Introduced before R2006a