function res=gen_HG(n)
% Cos (teta) generator for Rayleigh scattering
% phase function
% BY Krzysztof Markowicz, Nov 2003
q=4*rand(n,1)-2;
u=(-q+sqrt(1+q.^2)).^(1/3);
res=u-1./u;

