function [ a ] = ComputeSpectrum(a)

            if((a.Type == 0) || (a.Type == 3))
                Hs = 2*a.A;
              %  a.freq = a.df:a.df:a.fmax;
                if(a.Type == 0)  %Pierson Moskowitz
                    alpha = .0081;
                    beta = 0.74; %1.25;
                    f0 = sqrt(0.21*a.g/Hs)/(2*pi);
                    a.spectrum = (alpha*a.g^2/(2*pi)^4)*exp(-beta*(f0./a.freq).^4)./a.freq.^5;                                       
                end
                if(a.Type == 3)  %Modified Pierson Moskowitz
                    alpha = 5/16;
                    f0 =  1.005/a.T;
                    a.spectrum = alpha*Hs^2*f0^4*a.freq.^(-5).*exp(-1.25*(f0./a.freq).^4);
                end
                    
                s = RandStream('mt19937ar','Seed', 5489);
                RandStream.setGlobalStream(s);
                phasea = 0;
                phaseb = 2*pi; 
                a.phases = phasea + (phaseb-phasea).*rand(a.n_freq,1);
            end
            
            if(a.Type == 1)  %Monochromatic
                a.freq = 1/a.T;
                a.n_freq = 1;
                a.spectrum = a.A^2/(2*(a.fmax-a.fmin));
            end


end

