user466534
user466534

Reputation:

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

  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

  -5.5511e-017 =0 ?

approximately of course

Upvotes: 1

Views: 266

Answers (2)

bdecaf
bdecaf

Reputation: 4732

Actually you can refer to the eps command. Although matlab uses double that can encode numbers down to 2.2251e-308 the precission is determined size of the number.

Use it in the format eps(number) - it tell you the how large is the influence of the least significant bit.

on my machine eg. eps(0.3) returns 5.5511e-17 - exactly the number you report.

Upvotes: 1

fatihk
fatihk

Reputation: 7919

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

format long;

you will see the real precision used by Matlab

Upvotes: 1

Related Questions