필터 지우기
필터 지우기

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 ?

조회 수: 7 (최근 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...)

채택된 답변

Sam Cook
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개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by