看了很多帖子都没有,自己记录一下
对数中心变换(函数需要另起文件保存,别忘了):
function clr_transformed_data = center_log_ratio(data)%把要处理的数据导入命名为data
% Calculate the geometric mean of the data
geo_mean = geomean(data);
% Take the natural logarithm of each component
log_data = log(data);
% Subtract the logarithm of the geometric mean from each component
clr_transformed_data = log_data - log(geo_mean);
end
逆变换:
function original_data = inverse_center_log_ratio(clr_transformed_data, geo_mean)
% Add the logarithm of the geometric mean to each component
log_data = clr_data + log(geo_mean);
% Take the exponential to revert the natural logarithm
original_data = exp(log_data);
end