function res = my_std(samples, mu)
% Computes Standard deviation of samples with respect to the mean given by
% mu. This does the same as std(samples) if mu=mean(samples), otherwise the
% result will be different.
% This function can be used to see what is the STD of a set of samples when a
% number of outiers is removed, or to see what is the STD of the outliers
% without including the inliers.

if nargin < 2,
    res = std(samples);
else
    N = size(samples,1);
    normalised_samples = samples-repmat(mu, N, 1);
    res = sqrt(sum(normalised_samples.^2)/(N-1));
end

return 