Please note that the recommended version of Scilab is 6.0.2. This page might be outdated.
See the recommended documentation of this function
variancef
variance (and mean) of a vector or matrix of frequencyweighted real or complex numbers
Syntax
[s [,mc]] = variancef(x, fre [,orien [,m]]) [s, mc] = variancef(x) [s, mc] = variancef(x, fre, "r"1 ) [s, mc] = variancef(x, fre, "c"2 ) [s, mc] = variancef(x, fre, "*" , %nan) [s, mc] = variancef(x, fre, "r"1, %nan) [s, mc] = variancef(x, fre, "c"2, %nan) s = variancef(x, fre, "*", m) s = variancef(x, fre, "r", m) s = variancef(x, fre, "c", m)
Arguments
 x
vector or matrix of real or complex numbers
 fre
vector or matrix of positive decimal integers = frequencies:
fre(i,j)
is the number of times thatx(i,j)
must be counted.fre
andx
have same sizes. orien
the orientation of the computation. Valid values are:
 1 or "r" : result is a row, after a columnwise computation.
 2 or "c" : result is a column, after a rowwise computation.
 "*" : full undirectional computation (default); explicitly required when
m
is used.
 m
The known mean of the underlying statistical distribution law (assuming that it is known).
 "*" mode (default):
m
must be scalar  "r" or 1 mode:
m
is a row of lengthsize(x,2)
. The variance along the column #j is computed usingm(j)
as the mean for the considered column. Ifm(j)
is the same for all columns, it can be provided as a scalarm
.  "c" or 2 mode:
m
is a column of lengthsize(x,1)
. The variance along the row #i is computed usingm(i)
as the mean for the considered row. Ifm(i)
is the same for all rows, it can be provided as a scalarm
.
When
m
is not provided, thevariance
is built dividing the quadratic distance of n values tomean(x,fre)
(ormean(x,fre,"c")
ormean(x,fre,"r")
) by (n1) (n being sum(fre) or sum(fre,"c") or sum(fre,"r")). If the elements ofx
are mutually independent, the result is then statistically unbiased.Else, the
variance
is built dividing the quadratic distance of values tom
by the number n of considered values.If a true value
m
independent from x elements is used,x
andm
values are mutually independent, and the result is then unbiased.When the special value
m = %nan
is provided, the variance is still normalized by n (not n1) but is computed usingm = mean(x, fre)
instead (orm = mean(x,fre,"c")
orm = mean(x,fre,"r")
). Thism
does not bring independent information, and yields a statistically biased result. "*" mode (default):
 s
 The variance of weighted values of
x
elements. It is a scalar or a column vector or a row vector according toorien
.  mc
 Scalar or
orien
wise mean of weightedx
elements (= mean(x, fre,..)
), as computed before and used as reference in the variance.
Description
This function computes the variance of the values of a
vector or matrix x
, each of them x(i,j)
being counted fre(i,j)
times.
If x
is complex, then variancef(x,fre,..) = variancef(real(x),fre,..) + variancef(imag(x),fre,..)
is returned.
s = variancef(x,fre)
(or s=variancef(x,fre,"*")
) returns the scalar variance computed over all values of x
.
s = variancef(x,fre,"r")
(or equivalently s = variancef(x,fre,1)
) returns a row s
such that for each j,
s(j) = variancef(x(:,j),fre(:,j),..)
.
s = variancef(x,fre,"c")
(or equivalently s = variancef(x,fre,2)
) returns a column s
such that for each i,
s(i) = variancef(x(i,:),fre(i,:),..)
.
When the mean m
is provided, it is used as reference in the variance computation instead of being internally estimated from x
(unless it is equal to the special value %nan
: See m
's description). This allows to compute the variance of a sample x
with respect to a given statistical model (rather than extracting an empirical statistical dispersion in order to build the model).
Examples
x = [0.2113249 0.0002211 0.6653811; 0.7560439 0.9546254 0.6283918] fre = [1 2 3; 3 4 3] [s, m] = variancef(x, fre) [s, m] = variancef(x, fre, "r") [s, m] = variancef(x, fre, "c") // Example #2: x0 = grand(20, 7, "uin", 9, 10)+0.4 x = matrix((9:10)+0.4, 5, 4) fre = members(x, x0) // Computes the frequencies of x's elements in x0 [s, m] = variancef(x, fre) // Should be equal to variance(x0) [s, m] = variance(x0) // Example #2 (followup): m = (9+10)/2+0.4 // Known asymptotic mean (if x0 had an infinite number of elements) s = variancef(x, fre, "*", m) // Sample variance wrt the true mean s0 = (10  (9))^2 /12 // Known asymptotic variance s2 = variancef(x, fre, "*", %nan) // Takes m = meanf(x,fre) => always <= s
See also
Bibliography
Wonacott, T.H. & Wonacott, R.J.; Introductory Statistics, fifth edition, J.Wiley & Sons, 1990.
History
Version  Description 
5.5.0 

Comments
Add a comment:
Please login to comment this page.