How to solve the problem that the demeaning of X gives a variable Y that has not exactly a zero mean, probably due to very small values ?
15 views (last 30 days)
Show older comments
Hello together, I have the problem that I want to standardize a vector X. I do this by firstly demeaning X.
if true
% Y=(X-mean(X))
end
However now I have the problem that the mean of Y is not exactly zero like it should be, but really close to zero like 1.8*e-18. I attached the values of X as a file here. If I only considereing the first 6 values of X its fine
Y=(X(1:6)-mean(X(1:6)),
mean(Y)=0
but if I include the really small value of X(7), I get this different result.
if true
% Y=(X(1:7)-mean(X(1:7)),
mean(Y)=1.8e-10
end
Does anybody of you know what matlab is doing here? (rounding problem, too small number...)
0 Comments
Accepted Answer
Sam Cook
on 13 Jun 2018
This is a result of the accuracy of floating-point numbers. If you need to account for this, you can use the eps function to determine the degree of accuracy you are working with.
0 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!