简体   繁体   English

从任意向量获取平均为零的向量

[英]get vector which's mean is zero from arbitrary vector

as i know to get zero mean vector from given vector,we should substract mean of given vector from each memeber of this vector.for example let us see following example 我知道从给定向量中得到零均值向量,我们应该从该向量的每个成员中减去给定向量的均值。例如让我们看下面的例子

r=rand(1,6)

we get 我们得到

0.8687    0.0844    0.3998    0.2599    0.8001    0.4314

let us create another vector s by following operation 让我们通过以下操作创建另一个向量

s=r-mean(r(:));

after this we get 之后,我们得到

 0.3947   -0.3896   -0.0743   -0.2142    0.3260   -0.0426 

if we calculate mean of s by following formula 如果我们通过以下公式计算s的均值

  mean(s)

we get 我们得到
ans = 回答=

 -5.5511e-017 

actually as i have checked this number is very small 实际上,正如我检查过的那样,这个数字很小

     -5.5511*exp(-017)

ans =

 -2.2981e-007

so we should think that our vector has mean zero?so it means that that small deviation from 0 is because of round off error?for exmaple when we are creating white noise or such kind off random uncorrelated sequence of data,actually it is already supposed that even for such small data far from 0,it has zero mean and it is supposed in this case that for example for this case 所以我们应该认为我们的向量的均值为零,所以这意味着与0的较小偏差是由于舍入误差造成的。例如,当我们创建白噪声或此类随机无关数据序列时,实际上已经假定即使对于远离0的小数据,它的均值也为零,在这种情况下,例如

  -5.5511e-017 =0 ?

approximately of course 当然大约

e-017 means 10 to the power of -17 (10^-17) but still the number is very small and hypothetically it is 0. And if you type e-017的意思是10等于-17(10 ^ -17)的幂,但是数字仍然很小,并且假设为0。如果键入

format long;

you will see the real precision used by Matlab 您将看到Matlab使用的实际精度

Actually you can refer to the eps command. 实际上,您可以参考eps命令。 Although matlab uses double that can encode numbers down to 2.2251e-308 the precission is determined size of the number. 尽管matlab使用double可以编码低至2.2251e-308的数字, 2.2251e-308确定的是数字的大小。

Use it in the format eps(number) - it tell you the how large is the influence of the least significant bit. eps(number)格式使用它-它告诉您最低有效位的影响有多大。

on my machine eg. 在我的机器上 eps(0.3) returns 5.5511e-17 - exactly the number you report. eps(0.3)返回5.5511e-17您报告的确切数字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM