function [ s ] = fPoissrnd( N,changePnt )
% Poisson sample generator with Gaussian approximation.
% 
%   changePnt - the mean at which the Gaussian approximation is
%   used. A good rule of thumb is 1000.
%
%
%   N - the mean and variance. Can be a vector or matrix. The output will
%   be the same size as N.

ind = find(N < changePnt);
ind2 = find(N >= changePnt);

s1 = zeros(size(N));
s2 = s1;

if ~isempty(ind)
    s1(ind) = N(ind);
end
if ~isempty(ind2)
    s2(ind2) = N(ind2);
end

s2 = round(sqrt(s2).*randn(size(N)) + s2);
s2(s2<0) = 0;

s1 = poissrnd(s1,size(N));

s = s1+s2;

end

