function entropy = entropy_function(sampleSet, epsilon2, totalSampleCount, affine);
[dimension sampleCount] = size(sampleSet);
if affine
    sampleMean = mean(sampleSet,2);
    sampleSet = sampleSet - sampleMean * ones(1, sampleCount);
    A = sampleSet * sampleSet' / sampleCount;
    entropy = dimension * log2(1 + sum(sampleMean .^ 2) / epsilon2 ) /2 ...
        +(dimension + sampleCount) * log2(det(eye(dimension, dimension) + A * dimension / epsilon2)) /2 ...
        - sampleCount * log2(sampleCount / totalSampleCount);
else
       A = sampleSet * sampleSet' / sampleCount;
       entropy = (dimension + sampleCount) * log2(det(eye(dimension, dimension) + A * dimension / epsilon2)) /2 - sampleCount * log2(sampleCount / totalSampleCount);

end
