betastat
Beta mean and variance
Description
Examples
Compute the mean and variance of a beta distribution.
a = 1; b = 2; [m,v] = betastat(a,b)
m = 0.3333
v = 0.0556
Create two vectors a and b as the parameters of a beta distribution. Return the mean m and variance v of the beta distribution defined by a and b.
a = 1:6; b = 2*a; [m,v] = betastat(a,b)
m = 1×6
0.3333 0.3333 0.3333 0.3333 0.3333 0.3333
v = 1×6
0.0556 0.0317 0.0222 0.0171 0.0139 0.0117
If a or b is less than or equal to zero, betastat returns NaN.
a = [-1 2 0]; b = [3 -2 1]; [m,v] = betastat(a,b)
m = 1×3
NaN NaN NaN
v = 1×3
NaN NaN NaN
Input Arguments
First shape parameter, specified as a positive scalar value or an array of positive
scalar values. If both a and b are arrays,
they must be the same size. If either a or b
is a scalar, then betastat expands the scalar argument into a
constant array of the same size as the other argument.
Data Types: single | double
Second shape parameter, specified as a positive scalar value or an array of positive
scalar values. If both a and b are arrays,
they must be the same size. If either a or b
is a scalar, then betastat expands the scalar argument into a
constant array of the same size as the other argument.
Data Types: single | double
Output Arguments
Mean for the beta distribution, returned as a numeric scalar or an array of numeric
scalars. m is the same size as a and
b. Each element in m is the mean of the beta
distribution specified by the corresponding elements in a and
b. If a(i) or b(i) is
less than or equal to zero, then m(i) is
NaN.
The mean of the beta distribution with parameters a and b is a / (a + b).
Variance for the beta distribution, returned as a numeric scalar or an array of
numeric scalars. v is the same size as a and
b. Each element in v is the variance of the
beta distribution specified by the corresponding elements in a and
b. If a(i) or b(i) is
less than or equal to zero, then v(i) is
NaN.
The variance of the beta distribution with parameters a and b is
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
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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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
- United Kingdom (English)