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 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Sam Cook
le 13 Juin 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!