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 ?
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Sam Cook
2018-6-13
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!