function similarity = my_distance2(x_freq,y_freq,Type_distance)
% returns the distance between two vector x_freq and y_freq.
% --input
%   x_freq   
%   y_freq
%   Type_distance  --here are 7 methods to choose

switch Type_distance
    case 'p2'
        temp = (x_freq-y_freq).*(x_freq-y_freq);

        dis = sqrt(sum(temp,2));
        similarity = dis;
    case 'p1'
        temp = (abs(x_freq-y_freq)).^1;
        tempSum = sum(temp);
        similarity = power(tempSum,1/1);
    case 'p3'
        temp = (abs(x_freq-y_freq)).^3;
        tempSum = sum(temp);
        similarity = power(tempSum,1/3);
    case 'p4'
        temp = (abs(x_freq-y_freq)).^4;
        tempSum = sum(temp);
        similarity = power(tempSum,1/4);
    case 'p5'
        temp = (abs(x_freq-y_freq)).^5;
        tempSum = sum(temp);
        similarity = power(tempSum,1/5);
    case 'cs'
        temp = sum(x_freq.*y_freq);
        normtemp = norm(x_freq)*norm(y_freq);
        similarity = 1-(temp/normtemp);
    case 'IS'
        similarity=1 - sum(min(x_freq,y_freq));      
end
