unifstat
Continuous uniform mean and variance
Syntax
Description
Examples
Compute the mean and variance of a continuous uniform standard distribution.
a = 0; b = 1; [m,v] = unifstat(a,b)
m = 0.5000
v = 0.0833
Create two vectors a and b, where a is the lower endpoint and b is the upper endpoint of a continuous uniform distribution. Return the mean m and variance v of the continuous uniform distribution defined by a and b.
a = 1:6; b = 2*a; [m,v] = unifstat(a,b)
m = 1×6
1.5000 3.0000 4.5000 6.0000 7.5000 9.0000
v = 1×6
0.0833 0.3333 0.7500 1.3333 2.0833 3.0000
If the lower endpoint a is greater than or equal to the upper endpoint b, unifstat returns NaN.
a = [1 2 3]; b = [3 2 1]; [m,v] = unifstat(a,b)
m = 1×3
2 NaN NaN
v = 1×3
0.3333 NaN NaN
Input Arguments
Lower endpoint of the continuous uniform distribution, specified as a numeric scalar, vector, or array.
If a is a numeric vector or an
array, then it must have the same size as b. If
a is a numeric scalar, the function expands a
to a constant matrix that has the same dimensions as b.
Example: [0 -1 7 9]
Data Types: single | double
Upper endpoint of the continuous uniform distribution, specified as a numeric scalar, vector, or array.
If b is a numeric vector or an
array, then it must have the same size as a. If
b is a numeric scalar, the function expands b
to a constant matrix that has the same dimensions as a.
Example: [1 1 10 12]
Data Types: single | double
Output Arguments
Element-wise mean of a continuous uniform distribution, returned as a numeric scalar, vector, or array.
Each element in m is the mean of a distribution specified by
the corresponding elements in a and b. If
a and b are not the same size,
m is the size of a and
b after any necessary scalar expansion. If
a(i) is greater than or equal to b(i), then
m(i) is NaN, where i is
the index of an element. The mean of the continuous uniform distribution with endpoints
a and b is (a + b)/2.
Element-wise variance of a continuous uniform distribution, returned as a numeric scalar, numeric vector, or numeric array.
Each element in v is the variance of a distribution specified
by the corresponding elements in a and b. If
a and b are not the same size,
v is the size of a and
b after any necessary scalar expansion. If
a(i) is greater than or equal to b(i), then
v(i) is NaN, where i is
the index of an element. The variance of the continuous uniform distribution with
endpoints a and b is (a –
b)2/12.
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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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
- United Kingdom (English)