function [velPDFBoth, speedPDF, velPDFX, velPDFY] = velocityPDF(data,smoothing)
% Function to calculate the velocity PDF for both components (velPDFBoth), 
% the speed PDF, and the PDF for the individual components. Use smoothing
% to obtain a smooth function.
velX2=abs(data(1:end,7));
velY2=abs(data(1:end,8));
speed=sqrt(velX2.^2+velY2.^2);
    N=1000;
    h2=histogram([velY2;velX2],N,'Normalization','pdf');
    k2=h2.Values;
    x3=h2.BinEdges-h2.BinWidth/2;
    l2=smoothdata(k2,'gaussian',smoothing);
    h3=histogram(speed,N,'Normalization','pdf');
    k3=h3.Values;
    x4=h3.BinEdges-h3.BinWidth/2;
    l3=smoothdata(k3,'gaussian',smoothing);
    h4=histogram(velX2,N,'Normalization','pdf');
    k4=h4.Values;
    x5=h4.BinEdges-h4.BinWidth/2;
    l4=smoothdata(k4,'gaussian',smoothing);
    h5=histogram(velY2,N,'Normalization','pdf');
    k5=h5.Values;
    x6=h5.BinEdges-h5.BinWidth/2;
    l5=smoothdata(k5,'gaussian',smoothing);
    semilogy(x3(1:N),l2, 'LineWidth', 1.5)
    hold on
    semilogy(x4(1:N),l3, 'LineWidth', 1.5)
    semilogy(x5(1:N),l4, 'LineWidth', 1.5)
    semilogy(x6(1:N),l5, 'LineWidth', 1.5)
    legend('both components','speed','V_x','V_y');
velPDFBoth=[x3(1:N)', l2'];
speedPDF=[x4(1:N)', l3'];
velPDFX=[x5(1:N)', l4'];
velPDFY=[x6(1:N)', l5'];
end