% function s=pam(N,M,src_var);
%
% This function generates N signals from an M-PAM alphabet 
% with source variance src_var

function s=pam(N,M,src_var);

M=M/2;
if floor(M)~=M, error('Alphabet size must be even for pam'),end
s=2*floor(2*M*rand(N,1))-2*M+1;      % raw sequence
norm2=(4*M^2-1)/3;                   % norm square of the raw sequence
s=sqrt(src_var/norm2)*s;              % normalize and apply desired variance