[Scilab-users] Vectorization and variance
Stefan Du Rietz
sdr at durietz.se
Wed Feb 13 00:06:44 CET 2013
On 2013-02-12 18:47, Stefan Du Rietz wrote:
> On 2013-02-12 18:34, Stefan Du Rietz wrote:
> --------------------
>> On 2013-02-12 17:50, Serge Steer wrote:
>> --------------------
>>> Are you sure of your variance definition? For me if v is a vector the
>>> variance of v is computed by sqrt(sum( (v-mean(v))^2))
>>
>> That is standard deviation -- the variance is without sqrt.
>>
>> variance(v)
>>
>> /Stefan
>
> I was too quick ;-(
>
> -->stdev(v) == sqrt(variance(v))
> ans =
> T
>
> but your formula was wrong ...
>
> /Stefan
>
A little more about variance (n is the number of elements in v):
-->variance(v) == 1/(n-1) * sum( (v-mean(v))^2 )
ans =
T
which is not exactly equal to
-->mean( (v-mean(v))^2 ) == 1/n * sum( (v-mean(v))^2 )
ans =
T
There is much written about why you should divide by n-1 and not by n
(as for the common mean) and I don't know if I yet understand it fully ...
/Stefan
More information about the users
mailing list