Main Content

unidstat

Discrete uniform mean and variance

Description

m = unidstat(n) returns the mean for the discrete uniform distribution with the minimum value 1 and maximum value n.

[m,v] = unidstat(n) also returns the variance for the distribution.

example

Examples

collapse all

Compute the mean and variance of a discrete uniform distribution with the maximum value n.

n = 10;
[mean,variance] = unidstat(n)
mean = 
5.5000
variance = 
8.2500

Input Arguments

collapse all

Maximum value in the discrete uniform distribution, specified as a positive integer or an array of positive integers.

Data Types: single | double

Output Arguments

collapse all

Mean for the discrete uniform distribution, returned as a numeric scalar or an array of numeric scalars. m is the same size as n. Each element in m is the mean of the discrete uniform distribution specified by the corresponding element in n.

The mean of the discrete uniform distribution with parameter n is (n + 1)/2.

Variance for the discrete uniform distribution, returned as a numeric scalar or an array of numeric scalars. v is the same size as n. Each element in v is the variance of the discrete uniform distribution specified by the corresponding element in n.

The variance of the discrete uniform distribution with parameter n is (n2 – 1)/12.

Extended Capabilities

expand all

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

Version History

Introduced before R2006a