Hauptinhalt

betacdf

Beta cumulative distribution function

Description

p = betacdf(x,a,b) returns the cumulative distribution function (cdf) of the beta distribution with the shape parameters in a and b, evaluated at the values in x.

example

p = betacdf(x,a,b,"upper") returns the complement of the cdf, evaluated at the values in x, using an algorithm that more accurately computes the extreme upper-tail probabilities as compared to subtracting the lower-tail value from 1.

example

Examples

collapse all

Compute the cumulative distribution function (cdf) for a beta distribution with the shape parameters a and b, evaluated at the values between 0 and 1.

x = 0:0.01:1;
a = 2;
b = 2;
p = betacdf(x,a,b);

Plot the cdf.

plot(x,p)
grid on
xlabel("x")
ylabel("p")

Figure contains an axes object. The axes object with xlabel x, ylabel p contains an object of type line.

Determine the probability of sampling a number greater than 0.9999 from a beta distribution with the shape parameters a=2 and b=2.

p1 = betacdf(0.9999,2,2)
p1 = 
1.0000

This result shows that the probability of sampling a number less than or equal to 0.9999 is so close to 1 that subtracting the number from 1 gives 0.

To approximate the extreme upper-tail probability with greater precision, compute the complement of the beta cdf directly.

p2 = betacdf(0.9999,2,2,"upper")
p2 = 
2.9998e-08

The output indicates a small probability of sampling a number greater than 0.9999.

Input Arguments

collapse all

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

To evaluate the cdf at multiple values, specify x using an array. To evaluate the cdfs 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, betacdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the cdf value of the distribution specified by the corresponding elements in a and b, evaluated at the corresponding element in x.

Data Types: single | double

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

To evaluate the cdf at multiple values, specify x using an array. To evaluate the cdfs 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, betacdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the cdf value of the distribution specified by the corresponding elements in a and b, evaluated at the corresponding element in x.

Data Types: single | double

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

To evaluate the cdf at multiple values, specify x using an array. To evaluate the cdfs 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, betacdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the cdf value of the distribution specified by the corresponding elements in a and b, evaluated at the corresponding element in x.

Data Types: single | double

Output Arguments

collapse all

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

More About

collapse all

Alternative Functionality

  • betacdf is a function specific to the beta distribution. Statistics and Machine Learning Toolbox™ also offers the generic function cdf, which supports various probability distributions. To use cdf, create a BetaDistribution 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 betacdf is faster than the generic function cdf.

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

Extended Capabilities

expand all

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

Version History

Introduced before R2006a